Exemplo n.º 1
0
 /**
  * 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;
 }