/** * 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); } }
/** * Creates a new news item * @param integer $instanceID * @param string $subject * @param string $text * @param boolean $enableSmileys * @param boolean $enableHtml * @param boolean $enableBBCodes * @param integer $lastEdit * @param string $lastEditor * @param integer $editCount * @param integer $timestamp * @param integer $authorID * @param string $username * @param boolean $isPublic * @param boolean $isDeleted */ public static function create($instanceID, $subject, $text, $enableSmileys = true, $enableHtml = false, $enableBBCodes = true, $lastEdit = 0, $lastEditor = '', $editCount = 0, $timestamp = 0, $authorID = 0, $username = '', $isPublic = true, $isDeleted = false, $attachments) { $attachmentsAmount = $attachments != null ? count($attachments->getAttachments()) : 0; $sql = "INSERT INTO\r\n\t\t\t\t\twcf" . WCF_N . "_page_module_news_item (instanceID,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsubject,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttext,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tenableSmileys,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tenableHtml,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tenableBBCodes,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlastEdit,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlastEditor,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\teditCount,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttimestamp,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tauthorID,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tusername,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tattachments,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tisPublic,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tisDeleted)\r\n\t\t\t\tVALUES\r\n\t\t\t\t\t(" . $instanceID . ",\r\n\t\t\t\t\t '" . escapeString($subject) . "',\r\n\t\t\t\t\t '" . escapeString($text) . "',\r\n\t\t\t\t\t " . ($enableSmileys ? 1 : 0) . ",\r\n\t\t\t\t\t " . ($enableHtml ? 1 : 0) . ",\r\n\t\t\t\t\t " . ($enableBBCodes ? 1 : 0) . ",\r\n\t\t\t\t\t " . $lastEdit . ",\r\n\t\t\t\t\t '" . escapeString($lastEditor) . "',\r\n\t\t\t\t\t " . $editCount . ",\r\n\t\t\t\t\t " . $timestamp . ",\r\n\t\t\t\t\t " . $authorID . ",\r\n\t\t\t\t\t '" . escapeString($username) . "',\r\n\t\t\t\t\t " . $attachmentsAmount . ",\r\n\t\t\t\t\t " . ($isPublic ? 1 : 0) . ",\r\n\t\t\t\t\t " . ($isDeleted ? 1 : 0) . ")"; WCF::getDB()->sendQuery($sql); $item = new DynamicNewsItemEditor(WCF::getDB()->getInsertID()); // assign attachments if ($attachments != null) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($attachments->getSortedAttachments()); } // update attachments & poll if ($attachments != null) { $attachments->updateContainerID($item->itemID); $attachments->findEmbeddedAttachments($text); } return $item; }
/** * 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); } }
/** * 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); } } }
/** * 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); } }
/** * Gets a list of attachments. */ protected function readAttachments() { // read attachments if (MODULE_ATTACHMENT == 1 && count($this->attachmentPostIDArray) > 0) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $this->attachmentList = new MessageAttachmentList($this->attachmentPostIDArray, 'post'); $this->attachmentList->readObjects(); $this->attachments = $this->attachmentList->getSortedAttachments($this->canViewAttachmentPreview); // set embedded attachments if ($this->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); } } }
/** * @see Form::submit() */ public function submit() { // call submit event EventHandler::fireAction($this, 'submit'); $this->readFormParameters(); try { // attachment handling if ($this->showAttachments) { $this->attachmentListEditor->handleRequest(); } // poll handling if ($this->showPoll) { $this->pollEditor->readParams(); } // preview if ($this->preview) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachmentListEditor->getSortedAttachments()); WCF::getTPL()->assign('preview', PostEditor::createPreview($this->subject, $this->text, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes)); } // send message or save as draft if ($this->send) { $this->validate(); // no errors $this->save(); } } catch (UserInputException $e) { $this->errorField = $e->getField(); $this->errorType = $e->getType(); } }
/** * @see Form::submit() */ public function submit() { EventHandler::fireAction($this, 'submit'); $this->readFormParameters(); try { // attachment handling if ($this->showAttachments) { $this->attachmentsEditor->handleRequest(); } // preview if ($this->preview || $this->upload) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachmentsEditor->getSortedAttachments()); $this->wantedPosterPreview = MessageParser::getInstance()->parse($this->text, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, false); if ($this->preview) { $this->validate(); } } else { $this->validate(); $this->save(); } } catch (UserInputException $e) { $this->errorField = $e->getField(); $this->errorType = $e->getType(); } }
/** * 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); }
/** * 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(); }
/** * @see Page::show() */ public function show() { // check permission if (!WCF::getUser()->getPermission('user.wantedPoster.canViewWantedPoster')) { require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php'; throw new PermissionDeniedException(); } else { if ($this->user->ignoredUser) { require_once WCF_DIR . 'lib/system/exception/NamedUserException.class.php'; throw new NamedUserException(WCF::getLanguage()->get('wcf.user.profile.error.ignoredUser', array('$username' => StringUtil::encodeHTML($this->user->username)))); } } if (WCF::getUser()->getPermission('user.wantedPoster.canViewMembersListTab') && WCF::getUser()->getPermission('user.membersList.canView')) { HeaderMenu::setActiveMenuItem('wcf.header.menu.memberslist'); } else { if (WCF::getUser()->getPermission('user.wantedPoster.canViewHeaderMenu')) { HeaderMenu::setActiveMenuItem('wcf.header.menu.userWantedPoster'); } } require_once WCF_DIR . 'lib/page/util/menu/UserProfileMenu.class.php'; UserProfileMenu::getInstance()->userID = $this->userID; UserProfileMenu::getInstance()->setActiveMenuItem('wcf.user.profile.menu.link.wantedPoster'); // get attachments require_once WCF_DIR . 'lib/data/message/attachment/Attachments.class.php'; $attachments = new Attachments($this->userID, 'wantedPoster'); $this->attachmentList = $attachments->getSortedAttachments(); require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachmentList); parent::show(); }
/** * @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); }