/**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (WCF::getUser()->userID && $eventObj->board->countUserPosts && $eventObj->disablePost) {
         WBBUser::updateUserPosts(WCF::getUser()->userID, 1);
         if (ACTIVITY_POINTS_PER_POST) {
             UserRank::updateActivityPoints(ACTIVITY_POINTS_PER_POST);
         }
     }
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if ($eventObj->action == 'enable') {
         if ($eventObj->post->userID && $eventObj->board->countUserPosts && $eventObj->board->getModeratorPermission('canEnableThread') && !$eventObj->post->everEnabled) {
             WBBUser::updateUserPosts($eventObj->post->userID, -1);
             if (ACTIVITY_POINTS_PER_POST) {
                 UserRank::updateActivityPoints(ACTIVITY_POINTS_PER_POST * -1, $eventObj->post->userID);
             }
         }
     }
 }
 public function save()
 {
     parent::save();
     if ($this->server == null) {
         $this->server = new Server($this->serverID);
     }
     $comment = ServerCommentEditor::create($this->server->serverID, BASHCore::getUser()->userID, $this->username, $this->text, TIME_NOW, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, BASHCore::getUser()->userID > 0 ? false : true);
     if (MODULE_USER_RANK and BASHCore::getUser()->userID > 0) {
         require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
         UserRank::updateActivityPoints(SERVER_COMMENT_USER_ACTIVITY_POINTS);
     }
     HeaderUtil::redirect('index.php?page=ServerDetail&serverID=' . $comment->serverID . SID_ARG_2ND_NOT_ENCODED . '#comment' . $comment->commentID);
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if ($eventObj->action == 'enable') {
         if ($eventObj->thread->userID && $eventObj->board->countUserPosts && $eventObj->board->getModeratorPermission('canEnableThread') && !$eventObj->thread->everEnabled) {
             WBBUser::updateUserPosts($eventObj->thread->userID, -1);
             if (ACTIVITY_POINTS_PER_THREAD) {
                 UserRank::updateActivityPoints(ACTIVITY_POINTS_PER_THREAD * -1, $eventObj->thread->userID);
             }
             $postIDs = explode(',', ThreadEditor::getAllPostIDs((string) $eventObj->thread->threadID));
             foreach ($postIDs as $postID) {
                 $post = new Post($postID);
                 if ($post->postID != $eventObj->thread->firstPostID && !$post->everEnabled) {
                     WBBUser::updateUserPosts($post->userID, -1);
                     if (ACTIVITY_POINTS_PER_POST) {
                         UserRank::updateActivityPoints(ACTIVITY_POINTS_PER_POST * -1, $post->userID);
                     }
                 }
             }
         }
     }
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     // get userIDs
     $userIDs = '';
     $sql = "SELECT\t\tuserID\n\t\t\tFROM\t\twbb" . WBB_N . "_user\n\t\t\tORDER BY\tuserID";
     $result = WCF::getDB()->sendQuery($sql, $eventObj->limit, $eventObj->limit * $eventObj->loop);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $userIDs .= ',' . $row['userID'];
     }
     if (empty($userIDs)) {
         return;
     }
     // get boardIDs
     $boardIDs = '';
     $sql = "SELECT\tboardID\n\t\t\tFROM\twbb" . WBB_N . "_board\n\t\t\tWHERE\tboardType = 0\n\t\t\t\tAND countUserPosts = 1";
     $result2 = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result2)) {
         $boardIDs .= ',' . $row['boardID'];
     }
     // update users posts
     $sql = "UPDATE\twbb" . WBB_N . "_user user\n\t\t\tSET\tposts = (\n\t\t\t\t\tSELECT\t\tCOUNT(*)\n\t\t\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\t\t\tWHERE\t\tpost.userID = user.userID\n\t\t\t\t\t\t\tAND thread.boardID IN (0" . $boardIDs . ")\n\t\t\t\t)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")";
     WCF::getDB()->sendQuery($sql);
     // update activity points
     $sql = "SELECT\t\twbb_user.userID,\n\t\t\t\t\twbb_user.posts,\n\t\t\t\t\tuser.activityPoints,\n\t\t\t\t\tCOUNT(thread.threadID) AS threads\n\t\t\tFROM\t\twbb" . WBB_N . "_user wbb_user\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = wbb_user.userID)\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\tON\t\t(thread.userID = wbb_user.userID AND thread.boardID IN (0" . $boardIDs . "))\n\t\t\tWHERE\t\twbb_user.userID IN (0" . $userIDs . ")\n\t\t\tGROUP BY\twbb_user.userID";
     $result2 = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result2)) {
         $activityPoints = $row['threads'] * ACTIVITY_POINTS_PER_THREAD + ($row['posts'] - $row['threads']) * ACTIVITY_POINTS_PER_POST;
         // update activity points for this package
         $sql = "REPLACE INTO\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\t\t(userID, packageID, activityPoints)\n\t\t\t\tVALUES \t\t(" . $row['userID'] . ", " . PACKAGE_ID . ", " . $activityPoints . ")";
         WCF::getDB()->sendQuery($sql);
     }
     // update global activity points
     $sql = "UPDATE\twcf" . WCF_N . "_user user\n\t\t\tSET\tuser.activityPoints = (\n\t\t\t\t\tSELECT\tSUM(activityPoints)\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\tWHERE\tuserID = user.userID\n\t\t\t\t)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")";
     WCF::getDB()->sendQuery($sql);
     // update user rank
     WCF::getDB()->seekResult($result, 0);
     while ($row = WCF::getDB()->fetchArray($result)) {
         UserRank::updateActivityPoints(0, $row['userID']);
     }
 }
 /**
  * Updates the user stats (user posts, activity points & user rank).
  * 
  * @param	string		$threadIDs		changed threads
  * @param 	string		$mode			(enable|copy|move|delete)
  * @param 	integer		$destinationBoardID
  */
 public static function updateUserStats($threadIDs, $mode, $destinationBoardID = 0)
 {
     if (empty($threadIDs)) {
         return;
     }
     // get destination board
     $destinationBoard = null;
     if ($destinationBoardID) {
         $destinationBoard = Board::getBoard($destinationBoardID);
     }
     if ($mode == 'copy' && !$destinationBoard->countUserPosts) {
         return;
     }
     // update user posts, activity points
     $userPosts = array();
     $userActivityPoints = array();
     $sql = "SELECT\tboardID, userID\n\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\tWHERE\tthreadID IN (" . $threadIDs . ")\n\t\t\t\t" . ($mode != 'enable' ? "AND everEnabled = 1" : '') . "\n\t\t\t\tAND userID <> 0";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $board = Board::getBoard($row['boardID']);
         switch ($mode) {
             case 'enable':
                 if ($board->countUserPosts) {
                     // posts
                     if (!isset($userPosts[$row['userID']])) {
                         $userPosts[$row['userID']] = 0;
                     }
                     $userPosts[$row['userID']]++;
                     // activity points
                     if (!isset($userActivityPoints[$row['userID']])) {
                         $userActivityPoints[$row['userID']] = 0;
                     }
                     $userActivityPoints[$row['userID']] += ACTIVITY_POINTS_PER_THREAD;
                 }
                 break;
             case 'copy':
                 if ($destinationBoard->countUserPosts) {
                     // posts
                     if (!isset($userPosts[$row['userID']])) {
                         $userPosts[$row['userID']] = 0;
                     }
                     $userPosts[$row['userID']]++;
                     // activity points
                     if (!isset($userActivityPoints[$row['userID']])) {
                         $userActivityPoints[$row['userID']] = 0;
                     }
                     $userActivityPoints[$row['userID']] += ACTIVITY_POINTS_PER_THREAD;
                 }
                 break;
             case 'move':
                 if ($board->countUserPosts != $destinationBoard->countUserPosts) {
                     // posts
                     if (!isset($userPosts[$row['userID']])) {
                         $userPosts[$row['userID']] = 0;
                     }
                     $userPosts[$row['userID']] += $board->countUserPosts ? -1 : 1;
                     // activity points
                     if (!isset($userActivityPoints[$row['userID']])) {
                         $userActivityPoints[$row['userID']] = 0;
                     }
                     $userActivityPoints[$row['userID']] += $board->countUserPosts ? ACTIVITY_POINTS_PER_THREAD * -1 : ACTIVITY_POINTS_PER_THREAD;
                 }
                 break;
             case 'delete':
                 if ($board->countUserPosts) {
                     // posts
                     if (!isset($userPosts[$row['userID']])) {
                         $userPosts[$row['userID']] = 0;
                     }
                     $userPosts[$row['userID']]--;
                     // activity points
                     if (!isset($userActivityPoints[$row['userID']])) {
                         $userActivityPoints[$row['userID']] = 0;
                     }
                     $userActivityPoints[$row['userID']] -= ACTIVITY_POINTS_PER_THREAD;
                 }
                 break;
         }
     }
     // save posts
     if (count($userPosts)) {
         require_once WBB_DIR . 'lib/data/user/WBBUser.class.php';
         foreach ($userPosts as $userID => $posts) {
             WBBUser::updateUserPosts($userID, $posts);
         }
     }
     // save activity points
     if (count($userActivityPoints)) {
         require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
         foreach ($userActivityPoints as $userID => $points) {
             UserRank::updateActivityPoints($points, $userID);
         }
     }
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // count users
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_user";
     $row = WCF::getDB()->getFirstRow($sql);
     $count = $row['count'];
     // get user ids
     $userIDs = '';
     $sql = "SELECT\t\tuserID\n\t\t\tFROM\t\twbb" . WBB_N . "_user\n\t\t\tORDER BY\tuserID";
     $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $userIDs .= ',' . $row['userID'];
         // update last posts
         if (PROFILE_SHOW_LAST_POSTS) {
             // delete old entries
             $sql = "DELETE FROM\twbb" . WBB_N . "_user_last_post\n\t\t\t\t\tWHERE\t\tuserID = " . $row['userID'];
             WCF::getDB()->sendQuery($sql);
             // get new entries
             $sql = "SELECT\t\tpostID, time\n\t\t\t\t\tFROM\t\twbb" . WBB_N . "_post\n\t\t\t\t\tWHERE\t\tuserID = " . $row['userID'] . "\n\t\t\t\t\tORDER BY\ttime DESC";
             $result2 = WCF::getDB()->sendQuery($sql, 20);
             while ($row2 = WCF::getDB()->fetchArray($result2)) {
                 $sql = "INSERT INTO\twbb" . WBB_N . "_user_last_post\n\t\t\t\t\t\t\t\t(userID, postID, time)\n\t\t\t\t\t\tVALUES\t\t(" . $row['userID'] . ", " . $row2['postID'] . ", " . $row2['time'] . ")";
                 WCF::getDB()->sendQuery($sql);
             }
         }
     }
     if (empty($userIDs)) {
         $this->calcProgress();
         $this->finish();
     }
     // get boards
     $boardIDs = '';
     $sql = "SELECT\tboardID\n\t\t\tFROM\twbb" . WBB_N . "_board\n\t\t\tWHERE\tboardType = 0\n\t\t\t\tAND countUserPosts = 1";
     $result2 = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result2)) {
         $boardIDs .= ',' . $row['boardID'];
     }
     // update users posts
     $sql = "UPDATE\twbb" . WBB_N . "_user user\n\t\t\tSET\tposts = (\n\t\t\t\t\tSELECT\t\tCOUNT(*)\n\t\t\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\t\t\tWHERE\t\tpost.userID = user.userID\n\t\t\t\t\t\t\tAND post.isDeleted = 0\n\t\t\t\t\t\t\tAND post.isDisabled = 0\n\t\t\t\t\t\t\tAND thread.boardID IN (0" . $boardIDs . ")\n\t\t\t\t)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")";
     WCF::getDB()->sendQuery($sql);
     // update activity points
     $sql = "SELECT\t\twbb_user.userID, wbb_user.posts, user.activityPoints, COUNT(thread.threadID) AS threads\n\t\t\tFROM\t\twbb" . WBB_N . "_user wbb_user\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = wbb_user.userID)\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\tON\t\t(thread.userID = wbb_user.userID AND thread.boardID IN (0" . $boardIDs . ") AND thread.isDeleted = 0 AND thread.isDisabled = 0)\n\t\t\tWHERE\t\twbb_user.userID IN (0" . $userIDs . ")\n\t\t\tGROUP BY\twbb_user.userID";
     $result2 = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result2)) {
         $activityPoints = $row['threads'] * ACTIVITY_POINTS_PER_THREAD + ($row['posts'] - $row['threads']) * ACTIVITY_POINTS_PER_POST;
         // update activity points for this package
         $sql = "REPLACE INTO\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\t\t(userID, packageID, activityPoints)\n\t\t\t\tVALUES \t\t(" . $row['userID'] . ", " . PACKAGE_ID . ", " . $activityPoints . ")";
         WCF::getDB()->sendQuery($sql);
     }
     // remove obsolet activity points
     $sql = "DELETE FROM\twcf" . WCF_N . "_user_activity_point\n\t\t\tWHERE\t\tpackageID NOT IN (\n\t\t\t\t\t\tSELECT\tpackageID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\t\t)";
     WCF::getDB()->sendQuery($sql);
     // update global activity points
     $sql = "UPDATE\twcf" . WCF_N . "_user user\n\t\t\tSET\tuser.activityPoints = (\n\t\t\t\t\tSELECT\tSUM(activityPoints)\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\tWHERE\tuserID = user.userID\n\t\t\t\t)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")";
     WCF::getDB()->sendQuery($sql);
     // update pm counts
     $sql = "UPDATE\twcf" . WCF_N . "_user user\n\t\t\tSET\tpmUnreadCount = (\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM \twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tWHERE \trecipientID = user.userID\n\t\t\t\t\t\tAND isDeleted < 2\n\t\t\t\t\t\tAND isViewed = 0\n\t\t\t\t),\n\t\t\t\tpmTotalCount = (\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM \twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tWHERE \trecipientID = user.userID\n\t\t\t\t\t\tAND isDeleted < 2)\n\t\t\t\t\t\t+ (\n\t\t\t\t\tSELECT\t\tCOUNT(*)\n\t\t\t\t\tFROM \t\twcf" . WCF_N . "_pm pm\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_pm_to_user pm_to_user\n\t\t\t\t\tON\t\t(pm_to_user.pmID = pm.pmID\n\t\t\t\t\t\t\tAND pm_to_user.recipientID = pm.userID\n\t\t\t\t\t\t\tAND pm_to_user.isDeleted < 2)\n\t\t\t\t\tWHERE \t\tuserID = user.userID\n\t\t\t\t\t\t\tAND (saveInOutBox = 1\n\t\t\t\t\t\t\tOR isDraft = 1)\n\t\t\t\t\t\t\tAND pm_to_user.pmID IS NULL)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")";
     WCF::getDB()->sendQuery($sql);
     // update user rank
     require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
     WCF::getDB()->seekResult($result, 0);
     while ($row = WCF::getDB()->fetchArray($result)) {
         UserRank::updateActivityPoints(0, $row['userID']);
     }
     $this->executed();
     $this->calcProgress($this->limit * $this->loop, $count);
     $this->nextLoop();
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     // set the language temporarily to the thread language
     if ($this->languageID && $this->languageID != WCF::getLanguage()->getLanguageID()) {
         $this->setLanguage($this->languageID);
     }
     parent::save();
     // search for double posts
     if ($postID = PostEditor::test($this->subject, $this->text, WCF::getUser()->userID, $this->username)) {
         HeaderUtil::redirect('index.php?page=Thread&postID=' . $postID . SID_ARG_2ND_NOT_ENCODED . '#post' . $postID);
         exit;
     }
     // save poll
     if ($this->showPoll) {
         $this->pollEditor->save();
     }
     // save thread in database
     $this->newThread = ThreadEditor::create($this->board->boardID, $this->languageID, $this->prefix, $this->subject, $this->text, WCF::getUser()->userID, $this->username, intval($this->isImportant == 1), intval($this->isImportant == 2), $this->closeThread, $this->getOptions(), $this->subscription, $this->attachmentListEditor, $this->pollEditor, intval($this->disableThread || !$this->board->getPermission('canStartThreadWithoutModeration')));
     if ($this->isImportant == 2) {
         $this->newThread->assignBoards($this->boardIDs);
     }
     // save tags
     if (MODULE_TAGGING && THREAD_ENABLE_TAGS && $this->board->getPermission('canSetTags')) {
         $tagArray = TaggingUtil::splitString($this->tags);
         if (count($tagArray)) {
             $this->newThread->updateTags($tagArray);
         }
     }
     // reset language
     if ($this->userInterfaceLanguageID !== null) {
         $this->setLanguage($this->userInterfaceLanguageID, true);
     }
     if (!$this->disableThread && $this->board->getPermission('canStartThreadWithoutModeration')) {
         // update user posts
         if (WCF::getUser()->userID && $this->board->countUserPosts) {
             require_once WBB_DIR . 'lib/data/user/WBBUser.class.php';
             WBBUser::updateUserPosts(WCF::getUser()->userID, 1);
             if (ACTIVITY_POINTS_PER_THREAD) {
                 require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
                 UserRank::updateActivityPoints(ACTIVITY_POINTS_PER_THREAD);
             }
         }
         // refresh counter and last post
         $this->board->addThreads();
         $this->board->setLastPost($this->newThread);
         // reset stat cache
         WCF::getCache()->clearResource('stat');
         WCF::getCache()->clearResource('boardData');
         // send notifications
         $this->newThread->sendNotification(new Post(null, array('postID' => $this->newThread->firstPostID, 'message' => $this->text, 'enableSmilies' => $this->enableSmilies, 'enableHtml' => $this->enableHtml, 'enableBBCodes' => $this->enableBBCodes)), $this->attachmentListEditor);
         $this->saved();
         // forward to post
         HeaderUtil::redirect('index.php?page=Thread&threadID=' . $this->newThread->threadID . SID_ARG_2ND_NOT_ENCODED);
     } else {
         $this->saved();
         if ($this->disableThread) {
             // forward to post
             HeaderUtil::redirect('index.php?page=Thread&threadID=' . $this->newThread->threadID . SID_ARG_2ND_NOT_ENCODED);
         } else {
             WCF::getTPL()->assign(array('url' => 'index.php?page=Board&boardID=' . $this->boardID . SID_ARG_2ND_NOT_ENCODED, 'message' => WCF::getLanguage()->get('wbb.threadAdd.moderation.redirect'), 'wait' => 5));
             WCF::getTPL()->display('redirect');
         }
     }
     exit;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     // set the language temporarily to the thread language
     if ($this->thread->languageID && $this->thread->languageID != WCF::getLanguage()->getLanguageID()) {
         $this->setLanguage($this->thread->languageID);
     }
     MessageForm::save();
     if ($this->thread->isDisabled) {
         $this->disablePost = 1;
     }
     // search for double posts
     if ($postID = PostEditor::test($this->subject, $this->text, WCF::getUser()->userID, $this->username, $this->threadID)) {
         HeaderUtil::redirect('index.php?page=Thread&postID=' . $postID . SID_ARG_2ND_NOT_ENCODED . '#post' . $postID);
         exit;
     }
     // save poll
     if ($this->showPoll) {
         $this->pollEditor->save();
     }
     // save post in database
     $this->newPost = PostEditor::create($this->thread->threadID, $this->subject, $this->text, WCF::getUser()->userID, $this->username, $this->getOptions(), $this->attachmentListEditor, $this->pollEditor, null, intval($this->disablePost || !$this->board->getPermission('canReplyThreadWithoutModeration')));
     // reset language
     if ($this->userInterfaceLanguageID !== null) {
         $this->setLanguage($this->userInterfaceLanguageID, true);
     }
     // remove quotes
     $sessionVars = WCF::getSession()->getVars();
     if (isset($sessionVars['quotes'][$this->threadID])) {
         unset($sessionVars['quotes'][$this->threadID]);
         WCF::getSession()->register('quotes', $sessionVars['quotes']);
     }
     if (!$this->disablePost && $this->board->getPermission('canReplyThreadWithoutModeration')) {
         // refresh thread
         $this->thread->addPost($this->newPost, $this->closeThread);
         // update subscription
         $this->thread->setSubscription($this->subscription);
         // update user posts
         if (WCF::getUser()->userID && $this->board->countUserPosts) {
             WBBUser::updateUserPosts(WCF::getUser()->userID, 1);
             if (ACTIVITY_POINTS_PER_POST) {
                 require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
                 UserRank::updateActivityPoints(ACTIVITY_POINTS_PER_POST);
             }
         }
         // refresh counter and last post
         $this->board->addPosts();
         $this->board->setLastPost($this->thread);
         // close / open thread
         if (!$this->thread->isClosed && $this->closeThread) {
             $this->thread->close();
         } else {
             if ($this->thread->isClosed && !$this->closeThread) {
                 $this->thread->open();
             }
         }
         // mark as done
         if ($this->markAsDone == 1) {
             $this->thread->markAsDone();
         } else {
             if (MODULE_THREAD_MARKING_AS_DONE && $this->board->enableMarkingAsDone && $this->thread->isDone && WCF::getUser()->userID && WCF::getUser()->userID == $this->thread->userID) {
                 $this->thread->markAsUndone();
             }
         }
         // reset stat cache
         WCF::getCache()->clearResource('stat');
         WCF::getCache()->clearResource('boardData');
         // send notifications
         $this->newPost->sendNotification($this->thread, $this->board, $this->attachmentListEditor);
         $this->saved();
         // forward to post
         $url = 'index.php?page=Thread&postID=' . $this->newPost->postID . SID_ARG_2ND_NOT_ENCODED . '#post' . $this->newPost->postID;
         HeaderUtil::redirect($url);
     } else {
         $this->saved();
         if ($this->disablePost) {
             HeaderUtil::redirect('index.php?page=Thread&postID=' . $this->newPost->postID . SID_ARG_2ND_NOT_ENCODED . '#post' . $this->newPost->postID);
         } else {
             WCF::getTPL()->assign(array('url' => 'index.php?page=Thread&threadID=' . $this->threadID . SID_ARG_2ND_NOT_ENCODED, 'message' => WCF::getLanguage()->get('wbb.postAdd.moderation.redirect'), 'wait' => 5));
             WCF::getTPL()->display('redirect');
         }
     }
     exit;
 }
 /**
  * @see	Form:.save()
  */
 public function save()
 {
     parent::save();
     $entry = BashEntryEditor::create(BASHCore::getUser()->userID, $this->username, $this->serverID, $this->serverName, $this->text, TIME_NOW, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes);
     if (MODULE_USER_RANK and BASHCore::getUser()->userID > 0) {
         require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php';
         UserRank::updateActivityPoints(BASH_USER_ACTIVITY_POINTS);
     }
     if (WCF::getUser()->userID > 0) {
         HeaderUtil::redirect('index.php?page=BashEntry&entryID=' . $entry->entryID . SID_ARG_2ND_NOT_ENCODED);
     } else {
         // redirect to index
         WCF::getTPL()->assign(array('url' => 'index.php' . SID_ARG_1ST, 'message' => WCF::getLanguage()->get('bash.page.bashEntryAdd.guestRedirect'), 'wait' => 10));
         WCF::getTPL()->display('redirect');
         exit;
     }
     // call event
     $this->saved();
 }