/** * @see Action::execute() */ public function execute() { parent::execute(); // count board $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_board"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get board ids $boardIDs = ''; $sql = "SELECT\t\tboardID\n\t\t\tFROM\t\twbb" . WBB_N . "_board\n\t\t\tORDER BY\tboardID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); while ($row = WCF::getDB()->fetchArray($result)) { $boardIDs .= ',' . $row['boardID']; // update last post $board = new BoardEditor($row['boardID']); $board->setLastPosts(); } if (empty($boardIDs)) { // clear board cache WCF::getCache()->clear(WBB_DIR . 'cache', 'cache.boardData.php'); $this->calcProgress(); $this->finish(); } // update boards $sql = "UPDATE\twbb" . WBB_N . "_board board\n\t\t\tSET\tthreads = (\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\t\t\tWHERE\tboardID = board.boardID\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t),\n\t\t\t\tposts = (\n\t\t\t\t\tSELECT\tIFNULL(SUM(replies), 0) + COUNT(*)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread thread\n\t\t\t\t\tWHERE\tboardID = board.boardID\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t)\n\t\t\tWHERE\tboard.boardID IN (0" . $boardIDs . ")"; WCF::getDB()->sendQuery($sql); $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // add edit note $postData = array(); if (!$this->board->getPermission('canHideEditNote') && (WCF::getUser()->userID != $this->post->userID || $this->post->time <= TIME_NOW - POST_EDIT_HIDE_EDIT_NOTE_PERIOD * 60)) { $postData['editor'] = WCF::getUser()->username; $postData['editorID'] = WCF::getUser()->userID; $postData['lastEditTime'] = TIME_NOW; $postData['editCount'] = $this->post->editCount + 1; $postData['editReason'] = ''; } // update message $this->post->updateMessage($this->text, $postData); if ($this->thread->firstPostID == $this->post->postID) { // update first post preview $this->post->updateFirstPostPreview($this->post->threadID, $this->post->postID, $this->text, array('enableSmilies' => $this->post->enableSmilies, 'enableHtml' => $this->post->enableHtml, 'enableBBCodes' => $this->post->enableBBCodes)); } $this->executed(); // get new formatted message and return it $postList = new PostList(); $postList->sqlConditions = 'post.postID = ' . $this->postID; $postList->readPosts(); $post = reset($postList->posts); HeaderUtil::sendHeaders(); echo $post->getFormattedMessage(); }
/** * Removes a thread. */ public function removeThread() { self::resetCache(); // refresh board last post $this->board->refresh(); if ($this->thread->lastPostTime >= $this->board->getLastPostTime($this->thread->languageID)) { $this->board->setLastPosts(); } }
/** * Merges posts. */ public function merge() { if ($this->post === null || empty($this->postIDs)) { throw new IllegalLinkException(); } // remove target post from source $postIDArray = explode(',', $this->postIDs); if (($key = array_search($this->post->postID, $postIDArray)) !== false) { unset($postIDArray[$key]); $this->postIDs = implode(',', $postIDArray); } // get thread ids $threadIDs = PostEditor::getThreadIDs($this->postIDs); // get boards list($boards, $boardIDs) = ThreadEditor::getBoards($threadIDs); // check permissions $this->board->checkModeratorPermission('canMergePost'); foreach ($boards as $board) { $board->checkModeratorPermission('canMergePost'); } // remove user stats ThreadEditor::updateUserStats($threadIDs, 'delete'); PostEditor::updateUserStats(ThreadEditor::getAllPostIDs($threadIDs), 'delete'); // merge posts PostEditor::mergeAll($this->postIDs, $this->post->postID); PostEditor::unmarkAll(); // handle threads (check for empty, deleted and hidden threads) ThreadEditor::checkVisibilityAll($threadIDs); // refresh last post, replies, attachments, polls in threads ThreadEditor::refreshAll($threadIDs); // re-add user stats ThreadEditor::updateUserStats($threadIDs, 'enable'); PostEditor::updateUserStats(ThreadEditor::getAllPostIDs($threadIDs), 'enable'); // refresh counts BoardEditor::refreshAll($boardIDs); // refresh last post in boards $this->board->setLastPosts(); foreach ($boards as $board) { $board->setLastPosts(); } HeaderUtil::redirect($this->url); exit; }
/** * @see Page::show() */ public function show() { $this->loadAvailableLanguages(); // get max text length $this->maxTextLength = WCF::getUser()->getPermission('user.board.maxPostLength'); if (MODULE_POLL != 1 || !$this->board->getPermission('canStartPoll')) { $this->showPoll = false; } if (MODULE_ATTACHMENT != 1 || !$this->board->getPermission('canUploadAttachment')) { $this->showAttachments = false; } // get attachments editor if ($this->attachmentListEditor == null) { $this->attachmentListEditor = new MessageAttachmentListEditor(array(), 'post', PACKAGE_ID, WCF::getUser()->getPermission('user.board.maxAttachmentSize'), WCF::getUser()->getPermission('user.board.allowedAttachmentExtensions'), WCF::getUser()->getPermission('user.board.maxAttachmentCount')); } // get poll editor if ($this->pollEditor == null) { $this->pollEditor = new PollEditor(0, 0, 'post', WCF::getUser()->getPermission('user.board.canStartPublicPoll')); } // show form parent::show(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // check permission WCF::getUser()->checkPermission('admin.board.canEditBoard'); // delete old positions $sql = "TRUNCATE wbb" . WBB_N . "_board_structure"; WCF::getDB()->sendQuery($sql); // update postions foreach ($this->positions as $boardID => $data) { foreach ($data as $parentID => $position) { BoardEditor::updatePosition(intval($boardID), intval($parentID), $position); } } // insert default values $sql = "INSERT IGNORE INTO\twbb" . WBB_N . "_board_structure\n\t\t\t\t\t\t(parentID, boardID)\n\t\t\tSELECT\t\t\tparentID, boardID\n\t\t\tFROM\t\t\twbb" . WBB_N . "_board"; WCF::getDB()->sendQuery($sql); // reset cache WCF::getCache()->clearResource('board'); $this->executed(); // forward to list page HeaderUtil::redirect('index.php?page=BoardList&successfulSorting=1&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); exit; }
/** * @see Form::save() */ public function save() { parent::save(); // save board if (WCF::getUser()->getPermission('admin.board.canAddBoard')) { $this->board = BoardEditor::create($this->parentID, $this->position ? $this->position : null, $this->title, $this->description, $this->boardType, $this->image, $this->imageNew, $this->imageShowAsBackground, $this->imageBackgroundRepeat, $this->externalURL, TIME_NOW, $this->prefixes, $this->prefixMode, $this->prefixRequired, $this->styleID, $this->enforceStyle, $this->daysPrune, $this->sortField, $this->sortOrder, $this->postSortOrder, $this->closed, $this->countUserPosts, $this->invisible, $this->showSubBoards, $this->allowDescriptionHtml, $this->enableRating, $this->threadsPerPage, $this->postsPerPage, $this->searchable, $this->searchableForSimilarThreads, $this->ignorable, $this->enableMarkingAsDone, $this->additionalFields); } // save permissions if (WCF::getUser()->getPermission('admin.board.canEditPermissions')) { $this->savePermissions(); } // save moderators if (WCF::getUser()->getPermission('admin.board.canEditModerators')) { $this->saveModerators(); } // reset cache $this->resetCache(); $this->saved(); // reset values $this->boardType = $this->parentID = $this->prefixRequired = $this->styleID = $this->threadsPerPage = $this->postsPerPage = 0; $this->enforceStyle = $this->daysPrune = $this->closed = $this->invisible = $this->allowDescriptionHtml = $this->prefixMode = 0; $this->enableMarkingAsDone = 0; $this->countUserPosts = $this->showSubBoards = $this->imageShowAsBackground = $this->searchable = $this->searchableForSimilarThreads = $this->ignorable = 1; $this->position = $this->title = $this->description = $this->image = $this->imageNew = $this->externalURL = $this->prefixes = $this->sortField = $this->sortOrder = $this->postSortOrder = ''; $this->permissions = $this->moderators = array(); $this->enableRating = -1; $this->imageBackgroundRepeat = 'no-repeat'; // show success message WCF::getTPL()->assign(array('board' => $this->board, 'success' => true)); }
/** * Creates a new board. * * @return BoardEditor */ public static function create($parentID, $position, $title, $description = '', $boardType = 0, $image = '', $imageNew = '', $imageShowAsBackground = 1, $imageBackgroundRepeat = 'no', $externalURL = '', $time = TIME_NOW, $prefixes = '', $prefixMode = 0, $prefixRequired = 0, $styleID = 0, $enforceStyle = 0, $daysPrune = 0, $sortField = '', $sortOrder = '', $postSortOrder = '', $isClosed = 0, $countUserPosts = 1, $isInvisible = 0, $showSubBoards = 1, $allowDescriptionHtml = 0, $enableRating = -1, $threadsPerPage = 0, $postsPerPage = 0, $searchable = 1, $searchableForSimilarThreads = 1, $ignorable = 1, $enableMarkingAsDone = 0, $additionalFields = array()) { // save data $boardID = self::insert($title, array_merge($additionalFields, array('parentID' => $parentID, 'description' => $description, 'boardType' => $boardType, 'image' => $image, 'externalURL' => $externalURL, 'time' => $time, 'prefixes' => $prefixes, 'prefixMode' => $prefixMode, 'prefixRequired' => $prefixRequired, 'styleID' => $styleID, 'enforceStyle' => $enforceStyle, 'daysPrune' => $daysPrune, 'sortField' => $sortField, 'sortOrder' => $sortOrder, 'postSortOrder' => $postSortOrder, 'isClosed' => $isClosed, 'countUserPosts' => $countUserPosts, 'isInvisible' => $isInvisible, 'showSubBoards' => $showSubBoards, 'allowDescriptionHtml' => $allowDescriptionHtml, 'enableRating' => $enableRating, 'threadsPerPage' => $threadsPerPage, 'postsPerPage' => $postsPerPage, 'imageNew' => $imageNew, 'imageShowAsBackground' => $imageShowAsBackground, 'imageBackgroundRepeat' => $imageBackgroundRepeat, 'searchable' => $searchable, 'searchableForSimilarThreads' => $searchableForSimilarThreads, 'ignorable' => $ignorable, 'enableMarkingAsDone' => $enableMarkingAsDone))); // get board $board = new BoardEditor($boardID, null, null, false); // save position $board->addPosition($parentID, $position); // return new board return $board; }