コード例 #1
0
	public function execute() {
		$params = $this->extractRequestParams();
		$result = OnlineStatusBar::getUserInfoFromString( $params['user'] );
		// if user is IP and we track them
		if ( User::isIP( $params['user'] ) && $result === false ) {
			$result = OnlineStatusBar::getAnonFromString( $params['user'] );
		}
		if ( $result === false ) {
			$ret = 'unknown';
		} else {
			$ret = $result[0];
		}

		$this->getResult()->addValue(
			null, $this->getModuleName(), array( 'result' => $ret ) );
	}
コード例 #2
0
 /**
  * @param $parser Parser
  * @param $varCache ??
  * @param $index ??
  * @param $ret string?
  * @return bool
  */
 public static function parserGetVariable(&$parser, &$varCache, &$index, &$ret)
 {
     global $wgOnlineStatusBarCacheTime;
     if ($index != 'ISONLINE') {
         return true;
     }
     // get a status of user parsed from title
     $result = OnlineStatusBar::getUserInfoFromString($parser->getTitle()->getBaseText());
     // if user is IP and we track them
     if (User::isIP($parser->getTitle()->getBaseText()) && $result === false) {
         $result = OnlineStatusBar::getAnonFromString($parser->getTitle()->getBaseText());
     }
     if ($result === false) {
         $ret = 'unknown';
         return true;
     }
     // if user is tracked we need to remove parser cache so that page update when status change
     if ($result !== false) {
         $parser->getOutput()->updateCacheExpiry($wgOnlineStatusBarCacheTime[$result[0]] * 60);
     }
     $ret = $result[0];
     return true;
 }