/**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // add cache resources
     WCF::getCache()->addResource('bbcodes', WCF_DIR . 'cache/cache.bbcodes.php', WCF_DIR . 'lib/system/cache/CacheBuilderBBCodes.class.php');
     WCF::getCache()->addResource('smileys', WCF_DIR . 'cache/cache.smileys.php', WCF_DIR . 'lib/system/cache/CacheBuilderSmileys.class.php');
     // count threads
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_thread";
     $row = WCF::getDB()->getFirstRow($sql);
     $count = $row['count'];
     // get thread ids
     $threadIDs = '';
     $sql = "SELECT\t\tthreadID\n\t\t\tFROM\t\twbb" . WBB_N . "_thread\n\t\t\tORDER BY\tthreadID";
     $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $threadIDs .= ',' . $row['threadID'];
     }
     if (empty($threadIDs)) {
         $this->calcProgress();
         $this->finish();
     }
     // get data
     $sql = "SELECT\t\tthread.threadID,\n\t\t\t\t\tpost.postID, post.message, post.enableSmilies, post.enableHtml, post.enableBBCodes\n\t\t\tFROM\t\twbb" . WBB_N . "_thread thread\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_post post\n\t\t\tON\t\t(post.postID = thread.firstPostID)\n\t\t\tWHERE\t\tthread.threadID IN (0" . $threadIDs . ")";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if ($row['postID']) {
             PostEditor::updateFirstPostPreview($row['threadID'], $row['postID'], $row['message'], $row);
         }
     }
     $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();
 }
 /**
  * Creates a new thread.
  */
 public static function createFromPosts($postIDs, $boardID)
 {
     // get post
     $sql = "SELECT \t\tpost.*, thread.languageID\n\t\t\tFROM \t\twbb" . WBB_N . "_post post\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\tWHERE \t\tpost.postID IN (" . $postIDs . ")\n\t\t\tORDER BY \tpost.time ASC";
     $row = WCF::getDB()->getFirstRow($sql);
     $post = new Post(null, $row);
     $sql = "INSERT INTO \twbb" . WBB_N . "_thread\n\t\t\t\t\t(boardID, topic, firstPostID, time, userID, username, languageID)\n\t\t\tVALUES\t\t(" . $boardID . ",\n\t\t\t\t\t'" . escapeString($post->subject ? $post->subject : substr($post->message, 0, 255)) . "',\n\t\t\t\t\t" . $post->postID . ",\n\t\t\t\t\t" . $post->time . ",\n\t\t\t\t\t" . $post->userID . ",\n\t\t\t\t\t'" . escapeString($post->username) . "',\n\t\t\t\t\t" . intval($row['languageID']) . ")";
     WCF::getDB()->sendQuery($sql);
     $threadID = WCF::getDB()->getInsertID();
     // update user posts & activity points
     self::updateUserStats($threadID, 'copy', $boardID);
     // update first post preview
     PostEditor::updateFirstPostPreview($threadID, $post->postID, $post->message, array('enableSmilies' => $post->enableSmilies, 'enableHtml' => $post->enableHtml, 'enableBBCodes' => $post->enableBBCodes));
     return new ThreadEditor($threadID);
 }