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 setMessageParentUserData(stdClass $data, WallMessage $parent) { $parentUser = $parent->getUser(); if ($parentUser instanceof User) { $data->parent_username = $parentUser->getName(); $data->parent_user_id = $parentUser->getId(); if ($data->parent_user_id > 0) { $data->parent_displayname = $data->parent_username; } else { $data->parent_displayname = wfMessage('oasis-anon-user')->escaped(); } } else { /* parent was deleted and somehow reply stays in the system * the only way I've reproduced it was: I deleted a thread * then I went to Special:Log/delete and restored only its reply * an edge case but it needs to be handled * --nAndy */ $data->parent_username = wfMessage('oasis-anon-user')->escaped(); $data->parent_displayname = $data->parent_username; $data->parent_user_id = 0; } }