/** * @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() { if (!$this->canEditPost()) { throw new PermissionDeniedException(); } // 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(); // update subscription $this->thread->setSubscription($this->subscription); // save poll if ($this->showPoll) { $this->pollEditor->save(); } // add edit note $postData = array(); if (!$this->hideEditNote && (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'] = $this->editReason; } else { if (!empty($this->editReason)) { $postData['editReason'] = $this->editReason; } } // update database entry $this->post->update($this->subject, $this->text, $this->getOptions(), $this->attachmentListEditor, $this->pollEditor, $postData); // reset language if ($this->userInterfaceLanguageID !== null) { $this->setLanguage($this->userInterfaceLanguageID, true); } $threadData = array(); if ($this->thread->firstPostID == $this->post->postID) { // update thread topic if (!empty($this->subject)) { $threadData['topic'] = $this->subject; } // update thread prefix if ($this->board->getPermission('canUsePrefix')) { $threadData['prefix'] = $this->prefix; } // save tags if (MODULE_TAGGING && THREAD_ENABLE_TAGS && $this->board->getPermission('canSetTags')) { $this->thread->updateTags(TaggingUtil::splitString($this->tags)); } // announcement if ($this->board->getModeratorPermission('canStartAnnouncement')) { if ($this->thread->isAnnouncement) { $this->thread->removeAssignedBoards(); } if ($this->isImportant == 2) { $this->thread->assignBoards($this->boardIDs); } $threadData['isAnnouncement'] = intval($this->isImportant == 2); } // pin thread if ($this->board->getModeratorPermission('canPinThread')) { $threadData['isSticky'] = intval($this->isImportant == 1); } // set language if ($this->languageID != $this->thread->languageID) { $threadData['languageID'] = $this->languageID; } } // close / open thread if ($this->board->getModeratorPermission('canCloseThread')) { if (!$this->thread->isClosed && $this->closeThread) { $threadData['isClosed'] = 1; } else { if ($this->thread->isClosed && !$this->closeThread) { $threadData['isClosed'] = 0; } } } // update thread $this->thread->update($threadData); // update last posts if ($this->thread->firstPostID == $this->post->postID && $this->languageID != $this->thread->languageID) { $this->board->setLastPosts(); WCF::getCache()->clearResource('boardData'); } $this->saved(); // forward to post $url = 'index.php?page=Thread&postID=' . $this->postID . SID_ARG_2ND_NOT_ENCODED . '#post' . $this->postID; HeaderUtil::redirect($url); exit; }