/** * Chat entry point - rendered via Ajax or pre-rendered in JS variable */ public function executeContents() { global $wgUser, $wgSitename, $wgOut, $wgExtensionsPath, $wgContLang, $wgReadOnly, $wgEnableWallExt; wfProfileIn(__METHOD__); // Since there is no chat in the backup datacenter yet, if we're in read-only, disable the entry-point. // Depending on the actual failure, chat may or may not work, but the user would have to get there via URL which // is essentially saying that they accept some risk since they're going somewhere our interface doesn't direct them to. // If it's just, eg: a database problem, then they may get lucky and be able to use most of the chat features (kickbanning wouldn't work, etc.). if (empty($wgReadOnly)) { // Main variables $this->profileType = !empty($wgEnableWallExt) ? 'message-wall' : 'talk-page'; $this->linkToSpecialChat = SpecialPage::getTitleFor("Chat")->escapeLocalUrl(); $this->isLoggedIn = $wgUser->isLoggedIn(); $this->profileAvatarUrl = $this->isLoggedIn ? AvatarService::getAvatarUrl($wgUser->getName(), ChatRailController::AVATAR_SIZE) : ''; // List of other people in chat $this->totalInRoom = 0; // Gets array of users currently in chat to populate rail module and user stats menus $chattersIn = NodeApiClient::getChatters($this->totalInRoom); $this->totalInRoom = count($chattersIn); $chatters = array(); foreach ($chattersIn as $i => $val) { $chatters[$i] = array(); $cacheChatter = $this->getCachedUser($val); if (!empty($cacheChatter)) { $chatters[$i] = $cacheChatter; continue; } $chatters[$i]['username'] = $val; $chatters[$i]['avatarUrl'] = AvatarService::getAvatarUrl($chatters[$i]['username'], ChatRailController::AVATAR_SIZE); // get stats for edit count and member since $user = User::newFromName($val); if (is_object($user)) { $userStatsService = new UserStatsService($user->getId()); $stats = $userStatsService->getStats(); // edit count $chatters[$i]['editCount'] = $wgContLang->formatNum((int) $stats['edits']); // member since $chatters[$i]['showSince'] = $chatters[$i]['editCount'] != 0; $date = getdate(strtotime($stats['date'])); global $wgLang; $chatters[$i]['since'] = $wgLang->getMonthAbbreviation($date['mon']) . ' ' . $date['year']; // profile page if ($this->profileType == 'message-wall') { $chatters[$i]['profileUrl'] = Title::makeTitle(NS_USER_WALL, $chatters[$i]['username'])->getFullURL(); } else { $chatters[$i]['profileUrl'] = Title::makeTitle(NS_USER_TALK, $chatters[$i]['username'])->getFullURL(); } // contribs page $chatters[$i]['contribsUrl'] = SpecialPage::getTitleFor('Contributions', $chatters[$i]['username'])->getFullURL(); } $this->cacheUser($val, $chatters[$i]); } $this->chatters = $chatters; } // Cache the entire call in varnish (and browser). $this->response->setCacheValidity(self::CACHE_DURATION, self::CACHE_DURATION, array(WikiaResponse::CACHE_TARGET_BROWSER, WikiaResponse::CACHE_TARGET_VARNISH)); wfProfileOut(__METHOD__); }
/** * Related to PowerUser lifetime type. It is triggered * on every edit and checks if a user has enough edits * to become a PowerUser (see PowerUser.class.php). * * @param $oArticle * @param $oRevision * @param $iBaseRevId * @param \User $oUser * @return bool */ public function onNewRevisionFromEditComplete($oArticle, $oRevision, $iBaseRevId, \User $oUser) { $oUserStatsService = new \UserStatsService($oUser->getId()); if (!$oUser->isSpecificPowerUser(PowerUser::TYPE_LIFETIME) && $oUserStatsService->getEditCountGlobal() > PowerUser::MIN_LIFETIME_EDITS) { $oPowerUser = new PowerUser($oUser); $oPowerUser->addPowerUserProperty(PowerUser::TYPE_LIFETIME); } return true; }
/** * Refresh cache when article is edited */ static function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId) { wfProfileIn(__METHOD__); if ($revision !== NULL) { // // do not count null edits // tell service to update cached data for user who edited the page if (!$user->isAnon()) { $service = new UserStatsService($user->getId()); $service->increaseEditsCount(); } } wfProfileOut(__METHOD__); return true; }
/** * Increment the user's edit-count field. * Will have no effect for anonymous users. */ public function incEditCount() { global $wgMemc, $wgCityId, $wgEnableEditCountLocal; if (!$this->isAnon()) { // wikia change, load always from first cluster when we use // shared users database // @author Lucas Garczewski (tor) global $wgExternalSharedDB, $wgSharedDB; if (isset($wgSharedDB)) { $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB); } else { $dbw = wfGetDB(DB_MASTER); } $dbw->update('`user`', array('user_editcount=user_editcount+1'), array('user_id' => $this->getId()), __METHOD__); $dbw->commit(); /** * Wikia change * Update editcount for wiki * @since Feb 2013 * @author Kamil Koterba */ if (!empty($wgEnableEditCountLocal)) { $userStatsService = new UserStatsService($this->getId()); $userStatsService->increaseEditsCount(); } /* end of change */ } // edit count in user cache too $this->invalidateCache(); }
/** * First edit of a user * * @param int $uid The user ID to check * @return array */ function editFirstDate($uid) { global $wgLang; $ret = ""; $service = new UserStatsService($uid); $stats = $service->getStats(); if (!empty($stats)) { /* @var Language $wgLang */ $ret = $wgLang->timeanddate(wfTimestamp(TS_MW, $stats['date']), true); } return $ret; }
function testUserStatsService() { global $wgArticle; $user = User::newFromName('QATestsBot'); $service = new UserStatsService($user->getId()); $stats = $service->getStats(); $this->assertType('int', $stats['edits']); $this->assertType('int', $stats['likes']); $this->assertType('string', $stats['date']); // edits increase - perform fake edit $edits = $stats['edits']; $flags = $status = false; UserStatsService::onArticleSaveComplete($wgArticle, $user, false, false, false, false, false, $flags, false, $status, false); $stats = $service->getStats(); $this->assertEquals($edits+1, $stats['edits']); // edits increase ("manual") $edits = $stats['edits']; $service->increaseEditsCount(); $stats = $service->getStats(); $this->assertEquals($edits+1, $stats['edits']); }
/** * get avatars for wiki admins * @param integer $wikiId * @return array wikiAdminAvatars */ public function getWikiAdminAvatars($wikiId) { $adminAvatars = array(); if (!empty($wikiId)) { $wikiService = new WikiService(); try { //this try-catch block is here because of devbox environments //where we don't have all wikis imported $adminAvatars = $wikiService->getMostActiveAdmins($wikiId, self::AVATAR_SIZE); if (count($adminAvatars) > self::LIMIT_ADMIN_AVATARS) { $adminAvatars = array_slice($adminAvatars, 0, self::LIMIT_ADMIN_AVATARS); } foreach ($adminAvatars as &$admin) { $userStatService = new UserStatsService($admin['userId']); $admin['edits'] = $userStatService->getEditCountWiki($wikiId); } } catch (Exception $e) { $adminAvatars = array(); } } return $adminAvatars; }
/** * Get user info ( user name, avatar url, user page url ) on given wiki * if the user has avatar * @param integer $userId * @param integer $wikiId * @param integer $avatarSize * @param callable $checkUserCallback * @return array userInfo * */ public function getUserInfo($userId, $wikiId, $avatarSize, $checkUserCallback) { $userInfo = array(); $user = User::newFromId($userId); if ($user instanceof User && $checkUserCallback($user)) { $username = $user->getName(); $userInfo['avatarUrl'] = AvatarService::getAvatarUrl($user, $avatarSize); $userInfo['edits'] = 0; $userInfo['name'] = $username; /** @var $userProfileTitle GlobalTitle */ $userProfileTitle = GlobalTitle::newFromTextCached($username, NS_USER, $wikiId); $userInfo['userPageUrl'] = $userProfileTitle instanceof Title ? $userProfileTitle->getFullURL() : '#'; $userContributionsTitle = GlobalTitle::newFromTextCached('Contributions/' . $username, NS_SPECIAL, $wikiId); $userInfo['userContributionsUrl'] = $userContributionsTitle instanceof Title ? $userContributionsTitle->getFullURL() : '#'; $userInfo['userId'] = $userId; $userStatsService = new UserStatsService($userId); $stats = $userStatsService->getGlobalStats($wikiId); if (!empty($stats['date'])) { $date = getdate(strtotime($stats['date'])); } else { $date = getdate(strtotime('2005-06-01')); } $userInfo['lastRevision'] = $stats['lastRevision']; $userInfo['since'] = F::App()->wg->Lang->getMonthAbbreviation($date['mon']) . ' ' . $date['year']; } return $userInfo; }
/** * @brief Adds to memchached top wikis new wiki * * @param integer $wikiId wiki id * * @return void */ public function addTopWiki($wikiId) { global $wgUser; wfProfileIn(__METHOD__); $wikiName = WikiFactory::getVarValueByName('wgSitename', $wikiId); $wikiTitle = GlobalTitle::newFromText($this->user->getName(), NS_USER_TALK, $wikiId); if ($wikiTitle instanceof Title) { $wikiUrl = $wikiTitle->getFullUrl(); /** @var $userStatsService UserStatsService */ $userStatsService = new UserStatsService($wgUser->getId()); $userStats = $userStatsService->getStats(); //adding new wiki to topWikis in cache $wiki = array('id' => $wikiId, 'wikiName' => $wikiName, 'wikiUrl' => $wikiUrl, 'edits' => $userStats['edits'] + 1); $this->storeEditsWikis($wikiId, $wiki); } wfProfileOut(__METHOD__); }
/** * @group UsingDB */ function testUserStatsService() { $this->markTestSkipped('This is not a unit test'); $user = User::newFromName('QATestsBot'); $service = new UserStatsService($user->getId()); $stats = $service->getStats(); $this->assertInternalType('int', $stats['edits']); $this->assertInternalType('int', $stats['likes']); $this->assertInternalType('string', $stats['date']); // edits increase - perform fake edit $edits = $stats['edits']; $service->increaseEditsCount(); $stats = $service->getStats(); $this->assertEquals($edits + 1, $stats['edits']); }
public function newMessage() { $wall_username = $this->helper->getUser()->getName(); // only use realname if user made edits (use logic from masthead) $userStatsService = new UserStatsService($this->helper->getUser()->getID()); $userStats = $userStatsService->getStats(); if (empty($userStats['edits']) || $userStats['edits'] == 0) { $wall_username = $this->helper->getUser()->getName(); } $username = $this->wg->User->getName(); $this->response->setVal('username', $username); $this->response->setVal('wall_username', $wall_username); wfRunHooks('WallNewMessage', array($this->wg->Title, &$this->response)); $notifyEveryone = $this->helper->isAllowedNotifyEveryone($this->wg->Title->getNamespace(), $this->wg->User); $this->response->setVal('notify_everyone', $notifyEveryone); $wall_message = $this->response->getVal('wall_message'); if (empty($wall_message)) { $wall_message = User::isIP($wall_username) ? wfMessage('wall-placeholder-message-anon')->escaped() : wfMessage('wall-placeholder-message', $wall_username)->escaped(); $this->response->setVal('wall_message', $wall_message); } $this->checkAndSetUserBlockedStatus($this->helper->getUser()); }
/** * Return information about users present in the chat channel. This method has its internal cache. Method returns * an array, where each of the users is described by the following attributes: * * username - chatter login * * avatarUrl - chatter avatar url * * editCount - number of chatter's edits * * showSince - flag indicating if we can display the information when the chatter joined the wiki * * since_year && since_month - month and year, when chatter joined this wiki * * profileUrl - link to chatter talk page (or message wall, if it's enabled) * * contribsUrl - link to chatter contribution page * @return array array containing chatters info */ public static function getChatUsersInfo() { ChatHelper::info(__METHOD__ . ': Method called'); global $wgReadOnly; wfProfileIn(__METHOD__); $chatters = []; if (empty($wgReadOnly)) { // cache the whole response // individual users are cached anyway, but still we gain performance making just one memcache request instead of several $chatters = WikiaDataAccess::cache(self::getChatUsersMemcKey(), ChatEntryPoint::CHAT_USER_LIST_CACHE, function () { global $wgEnableWallExt; $chatters = []; // Gets array of users currently in chat to populate rail module and user stats menus $chattersIn = NodeApiClient::getChatters(); foreach ($chattersIn as $i => $val) { $chatters[$i] = WikiaDataAccess::cache(wfMemcKey('chatavatars', $val, 'v2'), 60 * 60, function () use($wgEnableWallExt, $val) { $chatter = ['username' => $val, 'avatarUrl' => AvatarService::getAvatarUrl($val, ChatRailController::AVATAR_SIZE)]; // get stats for edit count and member since $user = User::newFromName($val); if ($user instanceof User) { $userStatsService = new UserStatsService($user->getId()); $stats = $userStatsService->getStats(); // edit count $chatter['editCount'] = $stats['edits']; // member since $chatter['showSince'] = $chatter['editCount'] != 0; if ($chatter['showSince']) { $date = getdate(strtotime($stats['date'])); $chatter['since_year'] = $date['year']; $chatter['since_month'] = $date['mon']; } if (!empty($wgEnableWallExt)) { $chatter['profileUrl'] = Title::makeTitle(NS_USER_WALL, $chatter['username'])->getFullURL(); } else { $chatter['profileUrl'] = Title::makeTitle(NS_USER_TALK, $chatter['username'])->getFullURL(); } $chatter['contribsUrl'] = SpecialPage::getTitleFor('Contributions', $chatter['username'])->getFullURL(); } return $chatter; }); } return $chatters; }); } wfProfileOut(__METHOD__); return $chatters; }
/** * This is the ajax-endpoint that the node server will connect to in order to get the currently logged-in user's info. * The node server will pass the same cookies that the client has set, and this will allow this ajax request to be * part of the same sesssion that the user already has going. By doing this, the user's existing wikia login session * can be used, so they don't need to re-login for us to know that they are legitimately authorized to use the chat or not. * * The returned info is just a custom subset of what the node server needs and does not contain an exhaustive list of rights. * * The 'isLoggedIn' field and 'canChat' field of the result should be checked by the calling code before allowing * the user to chat. This is the last line of security against any users attemptin to circumvent our protections. Otherwise, * a banned user could copy the entire client code (HTML/JS/etc.) from an unblocked user, then run that code while logged in as * under a banned account, and they would still be given access. * * The returned 'isChatMod' field is boolean based on whether the user is a chat moderator on the current wiki. * * If the user is not allowed to chat, an error message is returned (which can be shown to the user). */ public static function getUserInfo() { global $wgMemc, $wgServer, $wgArticlePath, $wgRequest, $wgCityId, $wgContLang, $wgIP; wfProfileIn(__METHOD__); $data = $wgMemc->get($wgRequest->getVal('key'), false); if (empty($data)) { return array('errorMsg' => wfMsg('chat-room-is-not-on-this-wiki')); } $user = User::newFromId($data['user_id']); if (empty($user) || !$user->isLoggedIn() || $user->getName() != $wgRequest->getVal('name', '')) { wfProfileOut(__METHOD__); return array('errorMsg' => wfMsg('chat-room-is-not-on-this-wiki')); } $isCanGiveChatMode = false; $userChangeableGroups = $user->changeableGroups(); if (in_array('chatmoderator', $userChangeableGroups['add'])) { $isCanGiveChatMode = true; } // First, check if they can chat on this wiki. $retVal = array('canChat' => Chat::canChat($user), 'isLoggedIn' => $user->isLoggedIn(), 'isChatMod' => $user->isAllowed('chatmoderator'), 'isCanGiveChatMode' => $isCanGiveChatMode, 'isStaff' => $user->isAllowed('chatstaff'), 'username' => $user->getName(), 'avatarSrc' => AvatarService::getAvatarUrl($user->getName(), self::CHAT_AVATAR_DIMENSION), 'editCount' => "", 'since' => '', 'activeBasket' => ChatHelper::getServerBasket(), 'wgCityId' => $wgCityId, 'wgServer' => $wgServer, 'wgArticlePath' => $wgArticlePath); // Figure out the error message to return (i18n is done on this side). if ($retVal['isLoggedIn'] === false) { $retVal['errorMsg'] = wfMsg('chat-no-login'); } else { if ($retVal['canChat'] === false) { $retVal['errorMsg'] = wfMsg('chat-you-are-banned-text'); } } // If the user is approved to chat, make sure the roomId provided is for this wiki. // Users may be banned on the wiki of the room, but not on this wiki for example, so this prevents cross-wiki chat hacks. if ($retVal['canChat']) { $roomId = $wgRequest->getVal('roomId'); $cityIdOfRoom = NodeApiClient::getCityIdForRoom($roomId); if ($wgCityId !== $cityIdOfRoom) { $retVal['canChat'] = false; // don't let the user chat in the room they requested. $retVal['errorMsg'] = wfMsg('chat-room-is-not-on-this-wiki'); } } // If the user can chat, dig up some other stats which are a little more expensive to compute. if ($retVal['canChat']) { $userStatsService = new UserStatsService($user->getId()); $stats = $userStatsService->getStats(); // NOTE: This is attached to the user so it will be in the wiki's content language instead of wgLang (which it normally will). $stats['edits'] = $wgContLang->formatNum($stats['edits']); if (empty($stats['date'])) { // If the user has not edited on this wiki, don't show anything $retVal['since'] = ""; } else { // this results goes to chat server, which obiously has no user lang // so we just return a short month name key - it has to be translated on client side $date = getdate(wfTimestamp(TS_UNIX, $stats['date'])); $retVal['since'] = $date; } $retVal['editCount'] = $stats['edits']; } if ($retVal['isLoggedIn'] && $retVal['canChat']) { // record the IP of the connecting user. // use memcache so we order only one (user, ip) pair each day $ip = $wgRequest->getVal('address'); $memcKey = self::getUserIPMemcKey($data['user_id'], $ip, date("Y-m-d")); $entry = $wgMemc->get($memcKey, false); if (empty($entry)) { $wgMemc->set($memcKey, true, 86400); $log = WF::build('LogPage', array('chatconnect', false, false)); $log->addEntry('chatconnect', SpecialPage::getTitleFor('Chat'), '', array($ip), $user); $dbw = wfGetDB(DB_MASTER); $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq'); $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => NS_SPECIAL, 'cuc_title' => 'Chat', 'cuc_minor' => 0, 'cuc_user' => $user->getID(), 'cuc_user_text' => $user->getName(), 'cuc_actiontext' => wfMsgForContent('chat-checkuser-join-action'), 'cuc_comment' => '', 'cuc_this_oldid' => 0, 'cuc_last_oldid' => 0, 'cuc_type' => CUC_TYPE_CHAT, 'cuc_timestamp' => $dbw->timestamp(), 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => '', 'cuc_xff_hex' => null, 'cuc_agent' => null); $dbw->insert('cu_changes', $rcRow, __METHOD__); $dbw->commit(); } } wfProfileOut(__METHOD__); return $retVal; }
/** * Reset local editcount for renamed user and fake user * @author Kamil Koterba * @since Feb 2014 */ private function resetEditCountWiki() { // Renamed user $uss = new UserStatsService($this->mUserId); $uss->resetEditCountWiki(); // FakeUser if ($this->mFakeUserId != 0) { $uss = new UserStatsService($this->mFakeUserId); $uss->resetEditCountWiki(); } else { // use OldUsername if FakeUser isn't set $oldUser = User::newFromName($this->mOldUsername); $uss = new UserStatsService($oldUser->getId()); $uss->resetEditCountWiki(); } }
/** * This is the ajax-endpoint that the node server will connect to in order to get the currently logged-in user's info. * The node server will pass the same cookies that the client has set, and this will allow this ajax request to be * part of the same sesssion that the user already has going. By doing this, the user's existing wikia login session * can be used, so they don't need to re-login for us to know that they are legitimately authorized to use the chat or not. * * The returned info is just a custom subset of what the node server needs and does not contain an exhaustive list of rights. * * The 'isLoggedIn' field and 'canChat' field of the result should be checked by the calling code before allowing * the user to chat. This is the last line of security against any users attempting to circumvent our protections. Otherwise, * a banned user could copy the entire client code (HTML/JS/etc.) from an unblocked user, then run that code while logged in as * under a banned account, and they would still be given access. * * The returned 'isChatMod' field is boolean based on whether the user is a chat moderator on the current wiki. * * If the user is not allowed to chat, an error message is returned (which can be shown to the user). */ public static function getUserInfo() { ChatHelper::info(__METHOD__ . ': Method called'); global $wgMemc, $wgServer, $wgArticlePath, $wgRequest, $wgCityId, $wgContLang; wfProfileIn(__METHOD__); $data = $wgMemc->get($wgRequest->getVal('key'), false); if (empty($data)) { wfProfileOut(__METHOD__); return array('errorMsg' => "Key not found"); } $user = User::newFromId($data['user_id']); if (empty($user) || !$user->isLoggedIn() || $user->getName() != urldecode($wgRequest->getVal('name', ''))) { wfProfileOut(__METHOD__); return array('errorMsg' => "User not found"); } $isCanGiveChatMod = false; $userChangeableGroups = $user->changeableGroups(); if (in_array('chatmoderator', $userChangeableGroups['add'])) { $isCanGiveChatMod = true; } // First, check if they can chat on this wiki. $retVal = array('canChat' => Chat::canChat($user), 'isLoggedIn' => $user->isLoggedIn(), 'isChatMod' => $user->isAllowed('chatmoderator'), 'isCanGiveChatMod' => $isCanGiveChatMod, 'isStaff' => $user->isAllowed('chatstaff'), 'username' => $user->getName(), 'username_encoded' => rawurlencode($user->getName()), 'avatarSrc' => AvatarService::getAvatarUrl($user->getName(), self::CHAT_AVATAR_DIMENSION), 'editCount' => "", 'since' => '', 'activeBasket' => ChatHelper::getServerBasket(), 'wgCityId' => $wgCityId, 'wgServer' => $wgServer, 'wgArticlePath' => $wgArticlePath); // Figure out the error message to return (i18n is done on this side). if ($retVal['isLoggedIn'] === false) { $retVal['errorMsg'] = wfMsg('chat-no-login'); } else { if ($retVal['canChat'] === false) { $retVal['errorMsg'] = wfMsg('chat-you-are-banned-text'); } } // If the user is approved to chat, make sure the roomId provided is for this wiki. // Users may be banned on the wiki of the room, but not on this wiki for example, so this prevents cross-wiki chat hacks. if ($retVal['canChat']) { $roomId = $wgRequest->getVal('roomId'); $cityIdOfRoom = NodeApiClient::getCityIdForRoom($roomId); if ($wgCityId !== $cityIdOfRoom) { $retVal['canChat'] = false; // don't let the user chat in the room they requested. $retVal['errorMsg'] = wfMsg('chat-room-is-not-on-this-wiki'); } } // If the user can chat, dig up some other stats which are a little more expensive to compute. if ($retVal['canChat']) { // new user joins the chat, purge the cache ChatEntryPoint::purgeChatUsersCache(); $userStatsService = new UserStatsService($user->getId()); $stats = $userStatsService->getStats(); // NOTE: This is attached to the user so it will be in the wiki's content language instead of wgLang (which it normally will). $stats['edits'] = $wgContLang->formatNum($stats['edits']); if (empty($stats['date'])) { // If the user has not edited on this wiki, don't show anything $retVal['since'] = ""; } else { // this results goes to chat server, which obiously has no user lang // so we just return a short month name key - it has to be translated on client side $date = getdate(wfTimestamp(TS_UNIX, $stats['date'])); $retVal['since'] = $date; } $retVal['editCount'] = $stats['edits']; } wfProfileOut(__METHOD__); return $retVal; }
/** * Get and format stats for given user */ private function getStats($userName) { wfProfileIn(__METHOD__); global $wgLang; $user = User::newFromName($userName); $stats = array(); if (!empty($user) && $user->isLoggedIn()) { $userStatsService = new UserStatsService($user->getId()); $stats = $userStatsService->getStats(); if (!empty($stats)) { // date and points formatting if (!empty($stats['date'])) { $stats['date'] = $wgLang->date(wfTimestamp(TS_MW, $stats['date'])); } $stats['edits'] = $wgLang->formatNum($stats['edits']); } } wfProfileOut(__METHOD__); return $stats; }
/** * @brief Returns true if full masthead should be displayed * @return bool */ public function shouldDisplayFullMasthead() { global $wgCityId; $userId = $this->user->getId(); if (empty($this->userStats)) { /** @var $userStatsService UserStatsService */ $userStatsService = new UserStatsService($userId); $this->userStats = $userStatsService->getStats(); } $iEdits = $this->userStats['edits']; $iEdits = is_null($iEdits) ? 0 : intval($iEdits); $hasUserEverEditedMastheadBefore = $this->hasUserEverEditedMasthead(); $hasUserEditedMastheadBeforeOnThisWiki = $this->hasUserEditedMastheadBefore($wgCityId); if ($hasUserEditedMastheadBeforeOnThisWiki || $iEdits > 0 && $hasUserEverEditedMastheadBefore) { return true; } else { return false; } }