/** * Creates a bar * @param $article Article * @param $outputDone bool * @param $pcache string * @return bool */ public static function renderBar(&$article, &$outputDone, &$pcache) { global $wgOnlineStatusBarCacheTime; // Update status of all users who wants to be tracked OnlineStatusBar_StatusCheck::updateStatus(); // Performace fix $title = $article->getTitle(); if ($title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK) { return true; } // Retrieve status of user parsed from title $result = OnlineStatusBar::getUserInfoFromTitle($title); // In case that status can't be parsed we check if it isn't anon if ($result === false && User::isIP($title->getBaseText())) { $result = OnlineStatusBar::getAnonFromTitle($title); } // In case we were unable to get a status let's quit if ($result === false) { return true; } // Don't display status of those who don't want to show bar but only use magic if ($result->getOption('OnlineStatusBar_hide', false) == true) { return true; } $context = $article->getContext(); $context->getOutput()->addHtml(OnlineStatusBar::getStatusBarHtml()); return true; }
/** * Returns the status and User element * * @param string $username name of user * @return array|bool Array containing the status and User object */ public static function getUserInfoFromString( $username ) { // We create an user object using name of user parsed from title $user = User::newFromName( $username ); // Invalid user if ( !($user instanceof User) ) { return false; } if ( !self::isValid( $user ) ) { return false; } $status = OnlineStatusBar_StatusCheck::getStatus( $user ); return array( $status, $user ); }