/** * Merges the threads with the given thread ids with this thread. */ public function merge($threadIDs) { if (empty($threadIDs)) { return; } $threadIDArray = explode(',', $threadIDs); if (in_array($this->threadID, $threadIDArray)) { unset($threadIDArray[array_search($this->threadID, $threadIDArray)]); $threadIDs = implode(',', $threadIDArray); if (empty($threadIDs)) { return; } } // add views $sql = "SELECT\tSUM(views) AS views\n\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\tWHERE\tthreadID IN (" . $threadIDs . ")"; $row = WCF::getDB()->getFirstRow($sql); if ($row['views']) { $sql = "UPDATE\twbb" . WBB_N . "_thread\n\t\t\t\tSET\tviews = views + " . $row['views'] . "\n\t\t\t\tWHERE\tthreadID = " . $this->threadID; WCF::getDB()->sendQuery($sql); } // update tags if (MODULE_TAGGING) { require_once WCF_DIR . 'lib/data/tag/TagEngine.class.php'; $taggable = TagEngine::getInstance()->getTaggable('com.woltlab.wbb.thread'); $sql = "UPDATE IGNORE\twcf" . WCF_N . "_tag_to_object\n\t\t\t\tSET\t\tobjectID = " . $this->threadID . "\n\t\t\t\tWHERE\t\ttaggableID = " . $taggable->getTaggableID() . "\n\t\t\t\t\t\tAND languageID = " . $this->languageID . "\n\t\t\t\t\t\tAND objectID IN (" . $threadIDs . ")"; WCF::getDB()->sendQuery($sql); $sql = "DELETE FROM\twcf" . WCF_N . "_tag_to_object\n\t\t\t\tWHERE\t\ttaggableID = " . $taggable->getTaggableID() . "\n\t\t\t\t\t\tAND objectID IN (" . $threadIDs . ")"; WCF::getDB()->sendQuery($sql); } // remove user stats $postIDs = self::getAllPostIDs($threadIDs); self::updateUserStats($threadIDs . ',' . $this->threadID, 'delete'); PostEditor::updateUserStats($postIDs . ',' . self::getAllPostIDs($this->threadID), 'delete'); // move posts PostEditor::moveAll($postIDs, $this->threadID, $this->boardID, false); // re-add user stats $this->refresh(); self::updateUserStats($this->threadID, 'enable'); PostEditor::updateUserStats(self::getAllPostIDs($this->threadID), 'enable'); // delete threads self::deleteAllCompletely($threadIDs, false, false); }
/** * Moves the marked posts. */ public function move() { if ($this->thread == null) { throw new IllegalLinkException(); } $this->board->checkModeratorPermission('canMovePost'); // get threadids $threadIDs = PostEditor::getThreadIDs($this->postIDs); // get boards list($boards, $boardIDs) = ThreadEditor::getBoards($threadIDs); // check permissions foreach ($boards as $board) { $board->checkModeratorPermission('canMovePost'); } // remove user stats ThreadEditor::updateUserStats($threadIDs . ',' . $this->thread->threadID, 'delete'); PostEditor::updateUserStats(ThreadEditor::getAllPostIDs($threadIDs . ',' . $this->thread->threadID), 'delete'); // move posts PostEditor::moveAll($this->postIDs, $this->thread->threadID, $this->thread->boardID, false); 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 . ',' . $this->thread->threadID); // re-add user stats ThreadEditor::updateUserStats($threadIDs . ',' . $this->thread->threadID, 'enable'); PostEditor::updateUserStats(ThreadEditor::getAllPostIDs($threadIDs . ',' . $this->thread->threadID), 'enable'); // refresh counts BoardEditor::refreshAll($boardIDs . ',' . $this->board->boardID); // refresh last post in boards $this->board->setLastPosts(); foreach ($boards as $board) { $board->setLastPosts(); } // reset cache ThreadAction::resetCache(); HeaderUtil::redirect('index.php?page=Thread&threadID=' . $this->thread->threadID . SID_ARG_2ND_NOT_ENCODED); exit; }
/** * Moves and inserts the marked posts in a new thread. */ public function moveAndInsert() { if ($this->board == null) { throw new IllegalLinkException(); } // check permission $this->board->checkModeratorPermission('canMovePost'); // get threadids $threadIDs = PostEditor::getThreadIDs($this->postIDs); // get boards list($boards, $boardIDs) = ThreadEditor::getBoards($threadIDs); // check permissions foreach ($boards as $board) { $board->checkModeratorPermission('canMovePost'); } // remove user stats ThreadEditor::updateUserStats($threadIDs, 'delete'); PostEditor::updateUserStats(ThreadEditor::getAllPostIDs($threadIDs), 'delete'); // create new thread $thread = ThreadEditor::createFromPosts($this->postIDs, $this->board->boardID); // move posts PostEditor::moveAll($this->postIDs, $thread->threadID, $thread->boardID); PostEditor::unmarkAll(); // check threads ThreadEditor::checkVisibilityAll($threadIDs . ',' . $thread->threadID); // refresh ThreadEditor::refreshAll($threadIDs . ',' . $thread->threadID); // re-add user stats ThreadEditor::updateUserStats($threadIDs, 'enable'); PostEditor::updateUserStats($this->postIDs, 'enable'); PostEditor::updateUserStats(ThreadEditor::getAllPostIDs($threadIDs), 'enable'); // refresh counts BoardEditor::refreshAll($boardIDs . ',' . $this->board->boardID); // set last post $this->board->setLastPosts(); foreach ($boards as $board) { $board->setLastPosts(); } self::resetCache(); HeaderUtil::redirect($this->url); exit; }