/** * @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; }