/** * Enables the threads with the given thread ids. */ public static function enableAll($threadIDs, $enablePosts = true) { if (empty($threadIDs)) { return; } // send notifications $statThreadIDs = ''; $sql = "SELECT\t*\n\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\tWHERE\tthreadID IN (" . $threadIDs . ")\n\t\t\t\tAND isDisabled = 1\n\t\t\t\tAND everEnabled = 0"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!empty($statThreadIDs)) { $statThreadIDs .= ','; } $statThreadIDs .= $row['threadID']; // send notifications $thread = new ThreadEditor(null, $row); $thread->sendNotification(); } // update user posts & activity points self::updateUserStats($statThreadIDs, 'enable'); // enable thread $sql = "UPDATE \twbb" . WBB_N . "_thread\n\t\t\tSET\tisDisabled = 0,\n\t\t\t\teverEnabled = 1\n\t\t\tWHERE \tthreadID IN (" . $threadIDs . ")"; WCF::getDB()->registerShutdownUpdate($sql); // enable post if ($enablePosts) { PostEditor::enableAll(self::getAllPostIDs($threadIDs)); } }
/** * @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; }