/**
  * Moves thread
  * @request destinationBoardId - id of destination board
  * @request rootMessageId - thread id
  */
 public function moveThread()
 {
     // permission check needed here
     if (!$this->wg->User->isAllowed('wallmessagemove')) {
         $this->displayRestrictionError();
         return false;
         // skip rendering
     }
     $this->status = 'error';
     $destinationId = $this->getVal('destinationBoardId', '');
     $threadId = $this->getVal('rootMessageId', '');
     if (empty($destinationId)) {
         $this->errormsg = wfMsg('wall-action-move-validation-select-wall');
         return true;
     }
     $wall = Wall::newFromId($destinationId);
     $thread = WallThread::newFromId($threadId);
     if (empty($wall)) {
         $this->errormsg = 'unknown';
     }
     $thread->move($wall, $this->wg->User);
     $this->status = 'ok';
 }
Example #2
0
 private function loadThreads()
 {
     wfProfileIn(__METHOD__);
     $this->threads = array();
     foreach ($this->mThreadMapping as $tTitle => $tId) {
         $thread = WallThread::newFromId($tId);
         $this->threads[$tId] = $thread;
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * 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;
 }
Example #4
0
 public function getThreads($page = 1, $master = false)
 {
     wfProfileIn(__METHOD__);
     // get list of threads (article IDs) on Message Wall
     $db = wfGetDB($master ? DB_MASTER : DB_SLAVE);
     $offset = ($page - 1) * $this->mMaxPerPage;
     $out = array();
     $where = $this->getWhere();
     if ($where) {
         $where .= ' and parent_comment_id = 0 ';
         $orderBy = $this->getOrderBy();
         $query = "\n\t\t\tSELECT comment_id FROM comments_index\n\t\t\t\tWHERE {$where}\n\t\t\t\tORDER BY {$orderBy}\n\t\t\t\tLIMIT {$offset}, {$this->mMaxPerPage}\n\t\t\t";
         $res = $db->query($query);
         while ($row = $db->fetchObject($res)) {
             $out[] = WallThread::newFromId($row->comment_id);
         }
     }
     wfProfileOut(__METHOD__);
     return $out;
 }
 public function getThread($filterid)
 {
     wfProfileIn(__METHOD__);
     $wallthread = WallThread::newFromId($filterid);
     $wallthread->loadIfCached();
     $this->threads = array($filterid => $wallthread);
     $this->title = $this->wg->Title;
     wfProfileOut(__METHOD__);
 }
Example #6
0
 public function getThread()
 {
     $wm = $this;
     if ($this->isMain() == false) {
         $wm = $this->getTopParentObj();
     }
     return WallThread::newFromId($wm->getId());
 }
Example #7
0
 /**
  * @brief Gets wall comments from memc/db
  *
  * @param integer $parentId if not null returns only last two comments
  *
  * @return array first element is a counter, second is an array with comments
  *
  * @author Andrzej 'nAndy' Lukaszewski
  */
 public function getWallComments($parentId = null)
 {
     wfProfileIn(__METHOD__);
     $comments = array();
     $commentsCount = 0;
     if (!is_null($parentId)) {
         $parent = WallMessage::newFromId($parentId);
         if (!$parent instanceof WallMessage) {
             // this should never happen
             Wikia::log(__METHOD__, false, 'No WallMessage instance article id: ' . $parentId, true);
             wfProfileOut(__METHOD__);
             return array('count' => $commentsCount, 'comments' => $comments);
         }
         $wallThread = WallThread::newFromId($parentId);
         $topMessage = $wallThread->getThreadMainMsg();
         $comments = $wallThread->getRepliesWallMessages();
         if (!empty($comments)) {
             // top message has replies
             // in wiki activity we display amount of messages
             // not only replies (comments), so we add 1 which is top message
             $commentsCount = count($comments) + 1;
             $revComments = array_reverse($comments);
             $comments = array();
             $i = 0;
             foreach ($revComments as $comment) {
                 if (!in_array(true, array($comment->isRemove(), $comment->isAdminDelete()))) {
                     $comments[] = $comment;
                     $i++;
                 }
                 if ($i === 2) {
                     break;
                 }
             }
             if (count($comments) < 2) {
                 // if there is only one reply we add the top message
                 // and the order is correct
                 array_unshift($comments, $topMessage);
             } else {
                 // when there are more replies than one, we need to change
                 // the order again
                 $comments = array_reverse($comments);
             }
             $comments = $this->getCommentsData($comments);
         } else {
             // top message doesn't have replies yet -- it's a new wall message
             $comments = $this->getCommentsData(array($topMessage));
         }
     }
     wfProfileOut(__METHOD__);
     return array('count' => $commentsCount, 'comments' => $comments);
 }
 public function boardThread()
 {
     wfProfileIn(__METHOD__);
     $wallMessage = $this->getWallMessage();
     if (!$wallMessage instanceof WallMessage) {
         wfProfileOut(__METHOD__);
         $this->forward(__CLASS__, 'message_error');
         return true;
     }
     $this->response->setVal('id', $wallMessage->getId());
     $this->response->setVal('feedtitle', htmlspecialchars($wallMessage->getMetaTitle()));
     $this->response->setVal('isWatched', $wallMessage->isWatched($this->wg->User) || $this->request->getVal('new', false));
     $this->response->setVal('fullpageurl', $wallMessage->getMessagePageUrl());
     $this->response->setVal('kudosNumber', $wallMessage->getVoteCount());
     $replies = $this->getVal('replies', array());
     $repliesCount = count($replies) + 1;
     $this->response->setVal('repliesNumber', $repliesCount);
     $thread = WallThread::newFromId($wallMessage->getId());
     $lastReply = $thread->getLastMessage($replies);
     if ($lastReply === null) {
         $lastReply = $wallMessage;
     }
     // even though $data['author'] is a User object already
     // it's a cached object, and we need to make sure that we are
     // using newest RealName
     // cache invalidation in this case would require too many queries
     $authorUser = User::newFromName($lastReply->getUser()->getName());
     if ($authorUser) {
         $name = $authorUser->getName();
     } else {
         $name = $lastReply->getUser()->getName();
     }
     if ($lastReply->getUser()->getId() == 0) {
         // anynymous contributor
         $displayname = wfMessage('oasis-anon-user')->escaped();
         $displayname2 = $lastReply->getUser()->getName();
         $url = Skin::makeSpecialUrl('Contributions') . '/' . $lastReply->getUser()->getName();
     } else {
         $displayname = $name;
         $displayname2 = '';
         $url = Title::newFromText($name, $this->wg->EnableWallExt ? NS_USER_WALL : NS_USER_TALK)->getFullUrl();
     }
     $this->response->setVal('username', $name);
     $this->response->setVal('displayname', $displayname);
     $this->response->setVal('displayname2', $displayname2);
     $this->response->setVal('user_author_url', $url);
     $this->response->setVal('iso_timestamp', $lastReply->getCreatTime(TS_ISO_8601));
     $this->response->setVal('fmt_timestamp', $this->wg->Lang->timeanddate($lastReply->getCreatTime(TS_MW)));
     wfProfileOut(__METHOD__);
 }
 public function getArticlesRelatedMessgesSnippet($pageId, $messageCount, $replyCount)
 {
     $messages = $this->getArticlesRelatedMessgesIds($pageId, 'last_update desc', $messageCount);
     $out = array();
     $update = array(0);
     $helper = new WallHelper();
     foreach ($messages as $value) {
         $wallThread = WallThread::newFromId($value['comment_id']);
         if (empty($wallThread)) {
             continue;
         }
         $wallMessage = $wallThread->getThreadMainMsg();
         if (empty($wallMessage)) {
             continue;
         }
         $wallMessage->load();
         $update[] = $wallMessage->getCreateTime(TS_UNIX);
         $row = array();
         $row['metaTitle'] = $wallMessage->getMetaTitle();
         $row['threadUrl'] = $wallMessage->getMessagePageUrl();
         $row['totalReplies'] = $wallThread->getRepliesCount();
         $row['displayName'] = $wallMessage->getUserDisplayName();
         $row['userName'] = $wallMessage->getUser()->getName();
         $row['userUrl'] = $wallMessage->getUserWallUrl();
         $strippedText = $helper->strip_wikitext($wallMessage->getRawText(), $wallMessage->getTitle());
         $row['messageBody'] = $helper->shortenText($strippedText);
         $row['timeStamp'] = $wallMessage->getCreateTime();
         $row['replies'] = array();
         $replies = array_reverse($wallThread->getRepliesWallMessages(2, "DESC"));
         foreach ($replies as $reply) {
             /** @var WallMessage $reply */
             $reply->load();
             $update[] = $reply->getCreateTime(TS_UNIX);
             if (!$reply->isRemove() && !$reply->isAdminDelete()) {
                 $strippedText = $helper->strip_wikitext($reply->getRawText(), $reply->getTitle());
                 $replyRow = array('displayName' => $reply->getUserDisplayName(), 'userName' => $reply->getUser()->getName(), 'userUrl' => $reply->getUserWallUrl(), 'messageBody' => $helper->shortenText($strippedText), 'timeStamp' => $reply->getCreateTime());
                 $row['replies'][] = $replyRow;
             }
         }
         $out[] = $row;
     }
     $out['lastupdate'] = max($update);
     return $out;
 }