コード例 #1
0
 /**
  * Moves all threads with the given ids into the board with the given board id.
  */
 public static function moveAll($threadIDs, $newBoardID)
 {
     if (empty($threadIDs)) {
         return;
     }
     // remove thread links
     $sql = "DELETE FROM\twbb" . WBB_N . "_thread\n\t\t\tWHERE\t\tboardID = " . $newBoardID . "\n\t\t\t\t\tAND movedThreadID IN (" . $threadIDs . ")";
     WCF::getDB()->sendQuery($sql);
     // update user posts & activity points (threads)
     self::updateUserStats($threadIDs, 'move', $newBoardID);
     // get post ids
     $postIDs = '';
     $sql = "SELECT\tpostID\n\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\tWHERE\tthreadID IN (" . $threadIDs . ")";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (!empty($postIDs)) {
             $postIDs .= ',';
         }
         $postIDs .= $row['postID'];
     }
     // update user posts & activity points (posts)
     PostEditor::updateUserStats($postIDs, 'move', $newBoardID);
     // move threads
     $sql = "UPDATE \twbb" . WBB_N . "_thread\n\t\t\tSET\tboardID = " . $newBoardID . "\n\t\t\tWHERE \tthreadID IN (" . $threadIDs . ")\n\t\t\t\tAND boardID <> " . $newBoardID;
     WCF::getDB()->sendQuery($sql);
     // check prefixes
     self::checkPrefixes($threadIDs, $newBoardID);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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;
 }