public function board() { $ns = $this->wg->Title->getNamespace(); if ($ns == NS_WIKIA_FORUM_TOPIC_BOARD) { $topicTitle = $this->getTopicTitle(); if (empty($topicTitle) || !$topicTitle->exists()) { if (!$topicTitle->exists()) { $this->redirectToIndex(); return false; } } } parent::index(self::BOARD_PER_PAGE); JSMessages::enqueuePackage('Wall', JSMessages::EXTERNAL); $this->response->addAsset('forum_js'); $this->response->addAsset('extensions/wikia/Forum/css/ForumBoard.scss'); $this->response->addAsset('extensions/wikia/Wall/css/MessageTopic.scss'); // VOLDEV-36: separate monobook styling if ($this->app->checkSkin('monobook')) { $this->response->addAsset('extensions/wikia/Forum/css/monobook/ForumMonobook.scss'); $this->response->addAsset('extensions/wikia/Forum/css/monobook/ForumBoardMonobook.scss'); } $this->addMiniEditorAssets(); $this->description = ''; if ($ns == NS_WIKIA_FORUM_TOPIC_BOARD) { $board = ForumBoard::getEmpty(); $this->response->setVal('activeThreads', $board->getTotalActiveThreads($this->wall->getRelatedPageId())); $this->response->setVal('isTopicPage', true); $this->app->wg->Out->setPageTitle(wfMessage('forum-board-topic-title', $this->wg->title->getBaseText())->plain()); } else { $boardId = $this->wall->getId(); $board = ForumBoard::newFromId($boardId); if (empty($board)) { $this->redirectToIndex(); return false; } $this->response->setVal('activeThreads', $board->getTotalActiveThreads()); $this->response->setVal('isTopicPage', false); $this->description = $board->getDescription(); $this->app->wg->Out->setPageTitle(wfMessage('forum-board-title', $this->wg->title->getBaseText())->plain()); } $this->response->setVal('boardNamespace', NS_WIKIA_FORUM_BOARD); //TODO: keep the varnish cache and do purging on post $this->response->setCacheValidity(WikiaResponse::CACHE_DISABLED); $this->app->wg->SuppressPageHeader = true; }
/** * Remove and merge board * @request boardId - board to remove * @request boardTitle - board Title for validation * @request destinationBoardId - board to merge existing threads to * @response status - [ok|error|accessdenied] * @response errorfield - optional error field. nullable * @response errormsg - optional error message. �nullable */ public function removeBoard() { $this->status = self::checkAdminAccess(); if (!empty($this->status)) { return; } $boardId = $this->getVal('boardId', ''); $boardTitle = $this->getVal('boardTitle', ''); $destinationBoardId = $this->getVal('destinationBoardId', ''); if ($destinationBoardId == '') { $this->status = 'error'; $this->errormsg = ''; $this->errorfield = 'destinationBoardId'; return true; } /** * @var ForumBoard $board * @var ForumBoard $destinationBoard */ $board = ForumBoard::newFromId($boardId); $destinationBoard = ForumBoard::newFromId($destinationBoardId); if (empty($boardId) || empty($destinationBoardId)) { $this->status = 'error'; $this->errormsg = ''; return true; } if ($boardTitle != $board->getTitle()->getText()) { $this->status = 'error'; $this->errorfield = 'boardTitle'; $this->errormsg = ''; return true; } $board->moveAllThread($destinationBoard); $board->clearCacheBoardInfo(); $destinationBoard->clearCacheBoardInfo(); $forum = new Forum(); $forum->deleteBoard($board); $this->status = 'ok'; $this->errorfield = ''; $this->errormsg = ''; }
/** * purge memc and vernish cache for pages releated to this thread * * in case of edit this hook is run two time before (WallBeforeEdit) edit and after edit (WallAction) * */ public static function onWallAction($action, $parent, $comment_id) { $title = Title::newFromId($comment_id, Title::GAID_FOR_UPDATE); if (!empty($title) && MWNamespace::getSubject($title->getNamespace()) == NS_WIKIA_FORUM_BOARD) { $threadId = empty($parent) ? $comment_id : $parent; RelatedForumDiscussionController::purgeCache($threadId); //cleare board info $commentsIndex = CommentsIndex::newFromId($comment_id); if (empty($commentsIndex)) { return true; } $board = ForumBoard::newFromId($commentsIndex->getParentPageId()); if (empty($board)) { return true; } $thread = WallThread::newFromId($threadId); if (!empty($thread)) { $thread->purgeLastMessage(); } } return true; }
public function removeBoardModal() { wfProfileIn(__METHOD__); if (!$this->wg->User->isAllowed('forumadmin')) { $this->displayRestrictionError(); wfProfileOut(__METHOD__); return false; // skip rendering } $boardId = $this->getVal('boardId', -1); $board = ForumBoard::newFromId($boardId); if (empty($board)) { WikiaLogger::instance()->error('Error reporter: failed to find board', ['jiraTicket' => 'SOC-590', 'boardId' => $boardId, 'method' => __METHOD__]); $this->response->setCode(404); return true; } $boardTitle = $board->getTitle()->getText(); $forum = new Forum(); $list = $forum->getBoardList(); $this->destinationBoards = array(array('value' => '', 'content' => wfMessage('forum-board-destination-empty')->escaped())); foreach ($list as $value) { if ($boardId != $value['id']) { $this->destinationBoards[] = array('value' => $value['id'], 'content' => htmlspecialchars($value['name'])); } } $this->setVal('title', wfMessage('forum-admin-delete-and-merge-board-modal-heading', $boardTitle)->plain()); $this->setVal('submitLabel', wfMessage('forum-admin-delete-and-merge-button-label')->plain()); $form = array('inputs' => array(array('type' => 'text', 'name' => 'boardTitle', 'isRequired' => true, 'label' => wfMessage('forum-admin-delete-board-title')->plain()), array('type' => 'custom', 'output' => wfMessage('forum-admin-merge-board-warning')->plain()), array('type' => 'select', 'name' => 'destinationBoardId', 'class' => 'destinationBoardId', 'isRequired' => true, 'label' => wfMessage('forum-admin-merge-board-destination', $boardTitle)->plain(), 'options' => $this->destinationBoards)), 'method' => 'post', 'action' => ''); $this->setVal('html', $this->app->renderView('WikiaStyleGuideForm', 'index', array('form' => $form))); wfProfileOut(__METHOD__); }