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; }
private function getFormatedHistoryData($history, $threadId = 0) { 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 = F::build('WallMessage', array($title)); $user = $value['user']; $username = $user->getName(); $url = F::build('Title', array($username, NS_USER_WALL), 'newFromText')->getFullUrl(); if ($user->isAnon()) { $name = wfMsg('oasis-anon-user'); $history[$key]['displayname'] = wfMsg('wall-history-username-full', array('$1' => $name, '$2' => $username, '$3' => $url)); } else { $history[$key]['displayname'] = wfMsg('wall-history-username-short', array('$1' => $username, '$2' => $url)); } $history[$key]['authorurl'] = $url; $history[$key]['username'] = $user->getName(); $history[$key]['userpage'] = $url; $history[$key]['type'] = $type; $history[$key]['usertimeago'] = $this->wg->Lang->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(); $history[$key]['msguserurl'] = F::build('Title', array($msgUser->getName(), NS_USER_WALL), 'newFromText')->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' => wfMsg('diff')); } } else { $msgUrl = $wm->getMessagePageUrl(true); $history[$key]['msgurl'] = $msgUrl; $history[$key]['historyLink'] = Xml::element('a', array('href' => $msgUrl . '?action=history'), wfMsg('wall-history-action-thread-history')); } if ($type == WH_REMOVE && !$wm->isAdminDelete() || $type == WH_DELETE && $wm->isAdminDelete()) { if ($wm->canRestore($this->app->wg->User)) { if ($this->isThreadLevel) { $restoreActionMsg = $isReply === '1' ? wfMsg('wall-history-action-restore-reply') : wfMsg('wall-history-action-restore-thread'); } else { $restoreActionMsg = wfMsg('wall-history-action-restore'); } $history[$key]['actions'][] = array('class' => 'message-restore', 'data-id' => $value['page_id'], 'data-mode' => 'restore' . ($wm->canFastrestore($this->app->wg->User) ? '-fast' : ''), 'href' => '#', 'msg' => $restoreActionMsg); } } $userid = $user->getId(); if ($user->isAnon()) { WallRailController::addAnon($userid, $user); } else { WallRailController::addUser($userid, $user); } } return $history; }