/** * @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; }
/** * @brief Redirects to current title if it is in NS_USER_WALL namespace * * @return void * * @author Andrzej 'nAndy' Łukaszewski */ protected static function doSelfRedirect() { $app = F::App(); $title = $app->wg->Title; if ($app->wg->Request->getVal('action') == 'history' || $app->wg->Request->getVal('action') == 'historysubmit') { return true; } if ($title->getNamespace() === NS_USER_WALL) { $app->wg->Out->redirect($title->getLocalUrl(), 301); $app->wg->Out->enableRedirects(false); } if ($title->getNamespace() === NS_USER_WALL_MESSAGE) { $wm = new WallMessage($title); $owner = $wm->getWallOwner(); $title = Title::newFromText($owner->getName(), NS_USER_WALL); $app->wg->Out->redirect($title->getFullUrl(), 301); $app->wg->Out->enableRedirects(false); } }
private function setWallUserData(stdClass $data, WallMessage $wm, $useMasterDB) { $wallUser = $wm->getWallOwner($useMasterDB); if (empty($wallUser)) { WikiaLogger::instance()->error('Wall owner not found', ['method' => __METHOD__, 'notificationEntityId' => $this->id]); return false; } $data->wall_username = $wallUser->getName(); $data->wall_userid = $wallUser->getId(); $data->wall_displayname = $data->wall_username; return true; }