/**
  * @brief Adjusting recent changes for Wall
  *
  * This method doesn't let display diff history links
  *
  * @param ChangesList $list
  * @param $diffLink
  * @param $historyLink
  * @param string $s
  * @param RecentChange $rc
  * @param boolean $unpatrolled
  *
  * @internal param string $articleLink
  * @return true because this is a hook
  *
  * @author Andrzej 'nAndy' Lukaszewski
  */
 public static function onChangesListInsertDiffHist($list, &$diffLink, &$historyLink, &$s, $rc, $unpatrolled)
 {
     wfProfileIn(__METHOD__);
     $app = F::app();
     if (in_array(MWNamespace::getSubject(intval($rc->getAttribute('rc_namespace'))), $app->wg->WallNS)) {
         $rcTitle = $rc->getTitle();
         if (!$rcTitle instanceof Title) {
             // it can be media wiki deletion of an article -- we ignore them
             Wikia::log(__METHOD__, false, "WALL_NOTITLE_FOR_DIFF_HIST " . print_r(array($rc), true));
             wfProfileOut(__METHOD__);
             return true;
         }
         if (in_array($rc->getAttribute('rc_log_action'), static::$rcWallActionTypes)) {
             // delete, remove, restore
             $parts = explode('/@', $rcTitle->getText());
             $isThread = count($parts) === 2 ? true : false;
             if ($isThread) {
                 $wallTitleObj = Title::newFromText($parts[0], NS_USER_WALL);
                 $historyLink = !empty($parts[0]) && $wallTitleObj instanceof Title ? $wallTitleObj->getFullURL(array('action' => 'history')) : '#';
                 $historyLink = Xml::element('a', array('href' => $historyLink), wfMessage(static::getMessagePrefix($rc->getAttribute('rc_namespace')) . '-history-link')->text());
             } else {
                 $wallMessage = new WallMessage($rcTitle);
                 $historyLink = $wallMessage->getMessagePageUrl(true) . '?action=history';
                 $historyLink = Xml::element('a', array('href' => $historyLink), wfMessage(static::getMessagePrefix($rc->getAttribute('rc_namespace')) . '-thread-history-link')->text());
             }
             $s = '(' . $historyLink . ')';
         } else {
             // new, edit
             if ($rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG) {
                 $diffLink = wfMessage('diff')->escaped();
             } else {
                 if (!ChangesList::userCan($rc, Revision::DELETED_TEXT)) {
                     $diffLink = wfMessage('diff')->escaped();
                 } else {
                     $query = array('curid' => $rc->mAttribs['rc_cur_id'], 'diff' => $rc->mAttribs['rc_this_oldid'], 'oldid' => $rc->mAttribs['rc_last_oldid']);
                     if ($unpatrolled) {
                         $query['rcid'] = $rc->mAttribs['rc_id'];
                     }
                     $diffLink = Xml::element('a', array('href' => $rcTitle->getLocalUrl($query), 'tabindex' => $rc->counter, 'class' => 'known noclasses'), wfMessage('diff')->text());
                 }
             }
             $wallMessage = new WallMessage($rcTitle);
             $historyLink = $wallMessage->getMessagePageUrl(true) . '?action=history';
             $historyLink = Xml::element('a', array('href' => $historyLink), wfMessage('hist')->text());
             $s = '(' . $diffLink . wfMessage('pipe-separator')->escaped() . $historyLink . ') . . ';
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 private function getFormatedHistoryData($history, $threadId = 0)
 {
     // VOLDEV-39: Store whether Wall is enabled
     $ns = $this->wg->EnableWallExt ? NS_USER_WALL : NS_USER_TALK;
     foreach ($history as $key => $value) {
         $type = intval($value['action']);
         if (!$this->isThreadLevel && !in_array($type, array(WH_NEW, WH_REMOVE, WH_RESTORE, WH_DELETE))) {
             unset($history[$key]);
             continue;
         }
         $title = $value['title'];
         $wm = new WallMessage($title);
         $user = $value['user'];
         $username = $user->getName();
         $userTalk = Title::newFromText($username, $ns);
         $url = $userTalk->getFullUrl();
         if ($user->isAnon()) {
             $history[$key]['displayname'] = Linker::linkKnown($userTalk, wfMessage('oasis-anon-user')->escaped());
             $history[$key]['displayname'] .= ' ' . Linker::linkKnown($userTalk, Html::element('small', array(), $username), array('class' => 'username'));
         } else {
             $history[$key]['displayname'] = Linker::linkKnown($userTalk, $username);
         }
         $history[$key]['authorurl'] = $url;
         $history[$key]['username'] = $user->getName();
         $history[$key]['userpage'] = $url;
         $history[$key]['type'] = $type;
         $history[$key]['usertimeago'] = $this->getContext()->getLanguage()->timeanddate($value['event_mw']);
         $history[$key]['reason'] = $value['reason'];
         $history[$key]['actions'] = array();
         if ($this->isThreadLevel) {
             $history[$key]['isreply'] = $isReply = $value['is_reply'];
             $history[$key]['prefix'] = $isReply === '1' ? 'reply-' : 'thread-';
             if (intval($value['page_id']) === $threadId) {
                 // if the entry is about change in top message
                 // hardcode the order number to 1
                 $history[$key]['msgid'] = 1;
             } else {
                 $history[$key]['msgid'] = $wm->getOrderId();
             }
             $wm->load();
             $messagePageUrl = $wm->getMessagePageUrl();
             $history[$key]['msgurl'] = $messagePageUrl;
             $msgUser = $wm->getUser();
             $msgPage = Title::newFromText($msgUser->getName(), $ns);
             if (empty($msgPage)) {
                 // SOC-586, SOC-578 : There is an edge case where $msgUser->getName can be empty
                 // because of a rev_deleted flag on the revision loaded by ArticleComment via the
                 // WallMessage $wm->load() above.  ArticleComment overwrites the User objects mName
                 // usertext with the first revision's usertext to preserve the thread author but in
                 // rare occasions this revision can have its user hidden via a DELETED_USER flag.
                 $history[$key]['msguserurl'] = '';
                 $history[$key]['msgusername'] = '';
             } else {
                 $history[$key]['msguserurl'] = $msgPage->getFullUrl();
                 $history[$key]['msgusername'] = $msgUser->getName();
             }
             if ($type == WH_EDIT) {
                 $rev = Revision::newFromTitle($title);
                 // mech: fixing 20617 - revision_id is available only for new entries
                 $query = array('diff' => 'prev', 'oldid' => $history[$key]['revision_id'] ? $history[$key]['revision_id'] : $title->getLatestRevID());
                 $history[$key]['actions'][] = array('href' => $rev->getTitle()->getLocalUrl($query), 'msg' => wfMessage('diff')->text());
             }
         } else {
             $msgUrl = $wm->getMessagePageUrl(true);
             $history[$key]['msgurl'] = $msgUrl;
             $history[$key]['historyLink'] = Xml::element('a', array('href' => $msgUrl . '?action=history'), wfMessage('wall-history-action-thread-history')->text());
         }
         if ($type == WH_REMOVE && !$wm->isAdminDelete() || $type == WH_DELETE && $wm->isAdminDelete()) {
             if ($wm->canRestore($this->getContext()->getUser())) {
                 if ($this->isThreadLevel) {
                     $restoreActionMsg = $isReply === '1' ? wfMessage('wall-history-action-restore-reply')->text() : wfMessage('wall-history-action-restore-thread')->text();
                 } else {
                     $restoreActionMsg = wfMessage('wall-history-action-restore')->text();
                 }
                 $history[$key]['actions'][] = array('class' => 'message-restore', 'data-id' => $value['page_id'], 'data-mode' => 'restore' . ($wm->canFastrestore($this->getContext()->getUser()) ? '-fast' : ''), 'href' => '#', 'msg' => $restoreActionMsg);
             }
         }
         $userid = $user->getId();
         if ($user->isAnon()) {
             WallRailController::addAnon($userid, $user);
         } else {
             WallRailController::addUser($userid, $user);
         }
     }
     return $history;
 }
示例#3
0
 /**
  * @brief Filtring message wall data and spliting it to parents and childs
  *
  * @param Title $title title object instance
  * @param array $res a referance to array returned from recent changes
  *
  * @return array | boolean returns false if ArticleComment class does not exist
  *
  * @author Andrzej 'nAndy' Łukaszewski
  */
 public function wikiActivityFilterMessageWall($title, &$res)
 {
     wfProfileIn(__METHOD__);
     $item = array();
     $item['type'] = 'new';
     $item['wall'] = true;
     $item['ns'] = $res['ns'];
     $item['timestamp'] = $res['timestamp'];
     $item['wall-comment'] = $res['rc_params']['intro'];
     $item['article-id'] = $title->getArticleID();
     $wmessage = new WallMessage($title);
     $parent = $wmessage->getTopParentObj();
     if (!in_array(true, array($wmessage->isAdminDelete(), $wmessage->isRemove()))) {
         $item['wall-title'] = $wmessage->getArticleTitle()->getPrefixedText();
         $owner = $wmessage->getWallOwner();
         $item['wall-owner'] = $owner->getName();
         $item['wall-msg'] = '';
         if (empty($parent)) {
             // parent
             $metaTitle = $wmessage->getMetaTitle();
             if (!empty($metaTitle)) {
                 $item['title'] = $metaTitle;
             } else {
                 $wmessage->load();
                 $metaTitle = $wmessage->getMetaTitle();
                 $item['title'] = empty($metaTitle) ? wfMessage('wall-no-title')->escaped() : $metaTitle;
             }
             $item['url'] = $wmessage->getMessagePageUrl();
             $res['title'] = 'message-wall-thread-#' . $title->getArticleID();
             $item['wall-msg'] = wfMessage('wall-wiki-activity-on', $item['wall-title'], $item['wall-owner'])->parse();
         } else {
             // child
             $parent->load();
             if (!in_array(true, array($parent->isRemove(), $parent->isAdminDelete()))) {
                 $title = wfMessage('wall-no-title')->escaped();
                 // in case metadata does not include title field
                 if (isset($parent->mMetadata['title'])) {
                     $title = $wmessage->getMetaTitle();
                 }
                 $this->mapParentData($item, $parent, $title);
                 $res['title'] = 'message-wall-thread-#' . $parent->getTitle()->getArticleID();
                 $item['wall-msg'] = wfMessage('wall-wiki-activity-on', $item['wall-title'], $item['wall-owner'])->parse();
             } else {
                 // message was removed or deleted
                 $item = array();
             }
         }
     } else {
         // message was removed or deleted
         $item = array();
     }
     wfRunHooks('AfterWallWikiActivityFilter', array(&$item, $wmessage));
     wfProfileOut(__METHOD__);
     return $item;
 }