/** * Gets the posts for the feed. */ protected function readPosts() { // accessible boards $accessibleBoardIDArray = Board::getAccessibleBoardIDArray(array('canViewBoard', 'canEnterBoard', 'canReadThread')); if (!count($accessibleBoardIDArray)) { throw new PermissionDeniedException(); } // get posts $attachmentPostIDArray = array(); $sql = "SELECT\t\tpost.*\n\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\tWHERE\t\tpost.threadID IN (" . implode(',', $this->threadIDArray) . ")\n\t\t\t\t\tAND post.threadID IN (SELECT threadID FROM wbb" . WBB_N . "_thread WHERE boardID IN (" . implode(',', $accessibleBoardIDArray) . "))\n\t\t\t\t\tAND post.isDeleted = 0\n\t\t\t\t\tAND post.isDisabled = 0\n\t\t\t\t\t" . ($this->hours ? "AND post.time > " . (TIME_NOW - $this->hours * 3600) : '') . "\n\t\t\tORDER BY\tpost.time DESC"; $result = WCF::getDB()->sendQuery($sql, $this->limit); while ($row = WCF::getDB()->fetchArray($result)) { $this->posts[] = new FeedPost(null, $row); // attachments if ($row['attachments'] != 0) { $attachmentPostIDArray[] = $row['postID']; } } // read attachments if (MODULE_ATTACHMENT == 1 && count($attachmentPostIDArray) > 0 && (WCF::getUser()->getPermission('user.board.canViewAttachmentPreview') || WCF::getUser()->getPermission('user.board.canDownloadAttachment'))) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $attachmentList = new MessageAttachmentList($attachmentPostIDArray, 'post'); $attachmentList->readObjects(); $attachments = $attachmentList->getSortedAttachments(); // set embedded attachments require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($attachments); } }
/** * @see Form::readData() */ public function readData() { parent::readData(); if ($this->sendPickNotification) { $this->solutionObj->getEditor()->sendPickNotification(); } // init todo list $this->todoList = new ContestParticipantTodoList(); $this->todoList->sqlConditions .= 'contest_participant.contestID = ' . intval($this->contestID); $this->todoList->readObjects(); // read comments $this->commentList->sqlOffset = ($this->pageNo - 1) * $this->itemsPerPage; $this->commentList->sqlLimit = $this->itemsPerPage; $this->commentList->readObjects(); // read ratings $this->ratingList->readObjects(); // read attachments if (MODULE_ATTACHMENT == 1 && $this->solutionObj->attachments > 0) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $this->attachmentList = new MessageAttachmentList($this->solutionObj->solutionID, 'contestSolutionEntry', '', WCF::getPackageID('de.easy-coding.wcf.contest')); $this->attachmentList->readObjects(); $this->attachments = $this->attachmentList->getSortedAttachments(WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')); // set embedded attachments if (WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachments); } // remove embedded attachments from list if (count($this->attachments) > 0) { MessageAttachmentList::removeEmbeddedAttachments($this->attachments); } } // init sidebar $this->sidebar = new ContestSidebar($this->entry); }
/** * Gets a list of attachments. */ protected function readAttachments() { // read attachments if (MODULE_ATTACHMENT == 1 && count($this->attachmentPMIDArray)) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $this->attachmentList = new MessageAttachmentList($this->attachmentPMIDArray, 'pm', '', WCF::getPackageID('com.woltlab.wcf.data.message.pm')); $this->attachmentList->readObjects(); $this->attachments = $this->attachmentList->getSortedAttachments(); require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachments); if (count($this->attachments) > 0) { MessageAttachmentList::removeEmbeddedAttachments($this->attachments); } } }
/** * @see Page::readData() */ public function readData() { parent::readData(); // show 5 entries on first page, but 20 on the following pages $this->eventmixList->sqlLimit = $this->pageNo <= 1 ? $this->itemsOnLandingpage : $this->itemsPerPage; $this->eventmixList->sqlOffset = $this->pageNo <= 1 ? 0 : ($this->pageNo - 2) * $this->itemsPerPage + $this->itemsOnLandingpage; // fire sql query $this->eventmixList->readObjects(); // get previous entry $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_contest\n\t\t\tWHERE\t\tuserID = " . intval($this->entry->userID) . "\n\t\t\t\t\tAND (\n\t\t\t\t\t\ttime > " . intval($this->entry->time) . "\n\t\t\t\t\t\tOR (time = " . intval($this->entry->time) . " AND contestID < " . intval($this->entry->contestID) . ")\n\t\t\t\t\t)\n\t\t\tORDER BY\ttime ASC, contestID DESC"; $this->previousEntry = new Contest(null, WCF::getDB()->getFirstRow($sql)); if (!$this->previousEntry->contestID) { $this->previousEntry = null; } // get next entry $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_contest\n\t\t\tWHERE\t\tuserID = " . intval($this->entry->userID) . "\n\t\t\t\t\tAND (\n\t\t\t\t\t\ttime < " . intval($this->entry->time) . "\n\t\t\t\t\t\tOR (time = " . intval($this->entry->time) . " AND contestID > " . intval($this->entry->contestID) . ")\n\t\t\t\t\t)\n\t\t\tORDER BY\ttime DESC, contestID ASC"; $this->nextEntry = new Contest(null, WCF::getDB()->getFirstRow($sql)); if (!$this->nextEntry->contestID) { $this->nextEntry = null; } // read attachments if (MODULE_ATTACHMENT == 1 && $this->entry->attachments > 0) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $this->attachmentList = new MessageAttachmentList($this->contestID, 'contestEntry', '', WCF::getPackageID('de.easy-coding.wcf.contest')); $this->attachmentList->readObjects(); $this->attachments = $this->attachmentList->getSortedAttachments(WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')); // set embedded attachments if (WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachments); } // remove embedded attachments from list if (count($this->attachments) > 0) { MessageAttachmentList::removeEmbeddedAttachments($this->attachments); } } if ($this->entry->isOwner()) { // init todo list require_once WCF_DIR . 'lib/data/contest/owner/todo/ContestOwnerTodoList.class.php'; $this->todoList = new ContestOwnerTodoList(); $this->todoList->sqlConditions .= 'contest.contestID = ' . intval($this->contestID); $this->todoList->readObjects(); } // init sidebar $this->sidebar = new ContestSidebar($this->entry); }
/** * Gets a list of attachments. */ protected function readAttachments() { // read attachments if (MODULE_ATTACHMENT == 1 && count($this->attachmentEntryIDArray) > 0) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $this->attachmentList = new MessageAttachmentList($this->attachmentEntryIDArray, 'contestEntry', '', WCF::getPackageID('de.easy-coding.wcf.contest')); $this->attachmentList->readObjects(); $this->attachments = $this->attachmentList->getSortedAttachments(WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')); // set embedded attachments if (WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachments); } // remove embedded attachments from list if (count($this->attachments) > 0) { MessageAttachmentList::removeEmbeddedAttachments($this->attachments); } } }
/** * Gets the threads for the feed. */ protected function readThreads() { $boardIDArray = $this->boardIDArray; // include subboards if (count($boardIDArray)) { $boardIDArray = array_merge($boardIDArray, Board::getSubBoardIDArray($boardIDArray)); } // accessible boards $accessibleBoardIDArray = Board::getAccessibleBoardIDArray(array('canViewBoard', 'canEnterBoard', 'canReadThread')); if (count($boardIDArray)) { $boardIDArray = array_intersect($boardIDArray, $accessibleBoardIDArray); } else { $boardIDArray = $accessibleBoardIDArray; foreach ($boardIDArray as $key => $boardID) { if (WCF::getUser()->isIgnoredBoard($boardID)) { unset($boardIDArray[$key]); } } } // get threads $attachmentPostIDArray = array(); if (count($boardIDArray)) { $sql = "SELECT\t\tpost.*, thread.*, post.attachments\n\t\t\t\tFROM\t\twbb" . WBB_N . "_thread thread\n\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_post post\n\t\t\t\tON\t\t(post.postID = thread.firstPostID)\n\t\t\t\tWHERE\t\tthread.boardID IN (" . implode(',', $boardIDArray) . ")\n\t\t\t\t\t\tAND thread.isDeleted = 0\n\t\t\t\t\t\tAND thread.isDisabled = 0\n\t\t\t\t\t\tAND thread.movedThreadID = 0\n\t\t\t\t\t\tAND thread.time > " . ($this->hours ? TIME_NOW - $this->hours * 3600 : TIME_NOW - 30 * 86400) . "\n\t\t\t\tORDER BY\tthread.time DESC"; $result = WCF::getDB()->sendQuery($sql, $this->limit); while ($row = WCF::getDB()->fetchArray($result)) { $this->threads[] = new FeedThread($row); // attachments if ($row['attachments'] != 0) { $attachmentPostIDArray[] = $row['postID']; } } } // read attachments if (MODULE_ATTACHMENT == 1 && count($attachmentPostIDArray) > 0 && (WCF::getUser()->getPermission('user.board.canViewAttachmentPreview') || WCF::getUser()->getPermission('user.board.canDownloadAttachment'))) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $attachmentList = new MessageAttachmentList($attachmentPostIDArray, 'post'); $attachmentList->readObjects(); $attachments = $attachmentList->getSortedAttachments(); // set embedded attachments require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($attachments); } }
/** * Sends the email notification. */ public function sendNotification($post = null, $attachmentList = null) { $sql = "SELECT\t\tuser.*\n\t\t\tFROM\t\twbb" . WBB_N . "_board_subscription subscription\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = subscription.userID)\n\t\t\tWHERE\t\tsubscription.boardID = " . $this->boardID . "\n\t\t\t\t\tAND subscription.enableNotification = 1\n\t\t\t\t\tAND subscription.emails = 0\n\t\t\t\t\tAND subscription.userID <> " . $this->userID . "\n\t\t\t\t\tAND user.userID IS NOT NULL"; $result = WCF::getDB()->sendQuery($sql); if (WCF::getDB()->countRows($result)) { // get first post if ($post === null) { require_once WBB_DIR . 'lib/data/post/Post.class.php'; $post = new Post($this->firstPostID); } // get attachments if ($attachmentList === null) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $attachmentList = new MessageAttachmentList($this->firstPostID); $attachmentList->readObjects(); } // set attachments require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($attachmentList->getSortedAttachments()); // parse text require_once WCF_DIR . 'lib/data/message/bbcode/MessageParser.class.php'; $parser = MessageParser::getInstance(); $parser->setOutputType('text/plain'); $parsedText = $parser->parse($post->message, $post->enableSmilies, $post->enableHtml, $post->enableBBCodes, false); // truncate message if (!POST_NOTIFICATION_SEND_FULL_MESSAGE && StringUtil::length($parsedText) > 500) { $parsedText = StringUtil::substring($parsedText, 0, 500) . '...'; } // send notifications $languages = array(); $languages[WCF::getLanguage()->getLanguageID()] = WCF::getLanguage(); $languages[0] = WCF::getLanguage(); require_once WCF_DIR . 'lib/data/mail/Mail.class.php'; require_once WCF_DIR . 'lib/data/user/User.class.php'; require_once WBB_DIR . 'lib/data/board/Board.class.php'; $board = Board::getBoard($this->boardID); while ($row = WCF::getDB()->fetchArray($result)) { $recipient = new User(null, $row); // get language if (!isset($languages[$recipient->languageID])) { $languages[$recipient->languageID] = new Language($recipient->languageID); } // enable language $languages[$recipient->languageID]->setLocale(); // send mail $data = array('PAGE_TITLE' => $languages[$recipient->languageID]->get(PAGE_TITLE), 'PAGE_URL' => PAGE_URL, '$recipient' => $recipient->username, '$author' => $this->username, '$boardTitle' => $languages[$recipient->languageID]->get($board->title), '$topic' => $this->topic, '$threadID' => $this->threadID, '$text' => $parsedText); $mail = new Mail(array($recipient->username => $recipient->email), $languages[$recipient->languageID]->get('wbb.threadAdd.notification.subject', array('$title' => $languages[$recipient->languageID]->get($board->title))), $languages[$recipient->languageID]->get('wbb.threadAdd.notification.mail', $data)); $mail->send(); } // enable user language WCF::getLanguage()->setLocale(); // update notification count $sql = "UPDATE\twbb" . WBB_N . "_board_subscription\n\t\t\t\tSET \temails = emails + 1\n\t\t\t\tWHERE\tboardID = " . $this->boardID . "\n\t\t\t\t\tAND enableNotification = 1\n\t\t\t\t\tAND emails = 0"; WCF::getDB()->registerShutdownUpdate($sql); } }
/** * Sends e-mail notifications to all given recipients. * * @param array<User> */ public function sendNotifications($recipients) { require_once WCF_DIR . 'lib/data/mail/Mail.class.php'; require_once WCF_DIR . 'lib/system/language/Language.class.php'; // get attachments if ($this->attachments > 0) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; $attachmentList = new MessageAttachmentList($this->pmID, 'pm'); AttachmentBBCode::setAttachments($attachmentList->getSortedAttachments()); } // get parsed text require_once WCF_DIR . 'lib/data/message/bbcode/MessageParser.class.php'; $parser = MessageParser::getInstance(); $parser->setOutputType('text/plain'); $parsedText = $parser->parse($this->message, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, false); // send notifications $languages = array(); $languages[0] = $languages[WCF::getLanguage()->getLanguageID()] = WCF::getLanguage(); foreach ($recipients as $recipient) { // no notification for the author if ($recipient->userID == $this->userID) { continue; } // get language if (!isset($languages[$recipient->languageID])) { $languages[$recipient->languageID] = Language::getLanguageObjectByID($recipient->languageID); } // enable language $languages[$recipient->languageID]->setLocale(); // send mail $subjectData = array('$author' => $this->username, 'PAGE_TITLE' => $languages[$recipient->languageID]->get(PAGE_TITLE)); $messageData = array('PAGE_TITLE' => $languages[$recipient->languageID]->get(PAGE_TITLE), '$recipient' => $recipient->username, '$author' => $this->username, 'PAGE_URL' => PAGE_URL, '$subject' => $this->subject, '$text' => $parsedText); $mail = new Mail(array($recipient->username => $recipient->email), $languages[$recipient->languageID]->get('wcf.pm.notification.subject', $subjectData), $languages[$recipient->languageID]->get('wcf.pm.notification.mail', $messageData)); $mail->send(); } // enable user language WCF::getLanguage()->setLocale(); }