/**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->format = 'json';
     $this->count = 5000;
     // max 5000, completely arbitrary...
     $this->target = $this->getTargetProfile($this->arg('id'));
     if (!$this->target instanceof Profile) {
         // TRANS: Client error displayed when requesting a list of followers for a non-existing user.
         $this->clientError(_('No such user.'), 404);
     }
     $this->profiles = $this->getProfiles();
     $this->groups = $this->getGroups();
     $this->blocks = QvitterBlocked::getBlockedIDs($this->target->id, 0, 10000);
     // profiles: only keep id, name, nickname and avatar URL
     foreach ($this->profiles as $p) {
         try {
             $avatar = Avatar::urlByProfile($p, AVATAR_STREAM_SIZE);
         } catch (Exception $e) {
             $avatar = false;
         }
         $this_user = array($p->fullname, $p->nickname, $avatar);
         if (!$p->isLocal()) {
             $this_user[3] = $p->getUrl();
         } else {
             $this_user[3] = false;
         }
         $this->users_stripped[$p->id] = $this_user;
     }
     // groups: only keep id, name, nickname, avatar and local aliases
     foreach ($this->groups as $user_group) {
         $p = $user_group->getProfile();
         $avatar = $user_group->stream_logo;
         $this_group = array($p->fullname, $p->nickname, $avatar);
         if (!$user_group->isLocal()) {
             $this_group[3] = $p->getUrl();
         } else {
             $this_group[3] = false;
         }
         $this->groups_stripped[$user_group->id] = $this_group;
     }
     return true;
 }
Esempio n. 2
0
 function qvitterTwitterUserArray($profile)
 {
     $twitter_user = array();
     try {
         $user = $profile->getUser();
     } catch (NoSuchUserException $e) {
         $user = null;
     }
     $twitter_user['id'] = intval($profile->id);
     $twitter_user['name'] = $profile->getBestName();
     $twitter_user['screen_name'] = $profile->nickname;
     $twitter_user['location'] = $profile->location ? $profile->location : null;
     $twitter_user['description'] = $profile->bio ? $profile->bio : null;
     // TODO: avatar url template (example.com/user/avatar?size={x}x{y})
     $twitter_user['profile_image_url'] = Avatar::urlByProfile($profile, AVATAR_STREAM_SIZE);
     $twitter_user['profile_image_url_https'] = $twitter_user['profile_image_url'];
     // START introduced by qvitter API, not necessary for StatusNet API
     $twitter_user['profile_image_url_profile_size'] = Avatar::urlByProfile($profile, AVATAR_PROFILE_SIZE);
     try {
         $avatar = Avatar::getUploaded($profile);
         $origurl = $avatar->displayUrl();
     } catch (Exception $e) {
         $origurl = $twitter_user['profile_image_url_profile_size'];
     }
     $twitter_user['profile_image_url_original'] = $origurl;
     $twitter_user['groups_count'] = $profile->getGroupCount();
     foreach (array('linkcolor', 'backgroundcolor') as $key) {
         $twitter_user[$key] = Profile_prefs::getConfigData($profile, 'theme', $key);
     }
     // END introduced by qvitter API, not necessary for StatusNet API
     $twitter_user['url'] = $profile->homepage ? $profile->homepage : null;
     $twitter_user['protected'] = !empty($user) && $user->private_stream ? true : false;
     $twitter_user['followers_count'] = $profile->subscriberCount();
     // Note: some profiles don't have an associated user
     $twitter_user['friends_count'] = $profile->subscriptionCount();
     $twitter_user['created_at'] = ApiAction::dateTwitter($profile->created);
     $timezone = 'UTC';
     if (!empty($user) && $user->timezone) {
         $timezone = $user->timezone;
     }
     $t = new DateTime();
     $t->setTimezone(new DateTimeZone($timezone));
     $twitter_user['utc_offset'] = $t->format('Z');
     $twitter_user['time_zone'] = $timezone;
     $twitter_user['statuses_count'] = $profile->noticeCount();
     // Is the requesting user following this user?
     $twitter_user['following'] = false;
     $twitter_user['statusnet_blocking'] = false;
     $logged_in_profile = null;
     if (common_logged_in()) {
         $logged_in_profile = Profile::current();
         $twitter_user['following'] = $logged_in_profile->isSubscribed($profile);
         $twitter_user['statusnet_blocking'] = $logged_in_profile->hasBlocked($profile);
     }
     // StatusNet-specific
     $twitter_user['statusnet_profile_url'] = $profile->profileurl;
     Event::handle('TwitterUserArray', array($profile, &$twitter_user, $logged_in_profile, array()));
     return $twitter_user;
 }
Esempio n. 3
0
 function twitterUserArray($profile, $get_notice = false)
 {
     $twitter_user = array();
     try {
         $user = $profile->getUser();
     } catch (NoSuchUserException $e) {
         $user = null;
     }
     $twitter_user['id'] = intval($profile->id);
     $twitter_user['name'] = $profile->getBestName();
     $twitter_user['screen_name'] = $profile->nickname;
     $twitter_user['location'] = $profile->location ? $profile->location : null;
     $twitter_user['description'] = $profile->bio ? $profile->bio : null;
     // TODO: avatar url template (example.com/user/avatar?size={x}x{y})
     $twitter_user['profile_image_url'] = Avatar::urlByProfile($profile, AVATAR_STREAM_SIZE);
     $twitter_user['profile_image_url_https'] = $twitter_user['profile_image_url'];
     // START introduced by qvitter API, not necessary for StatusNet API
     $twitter_user['profile_image_url_profile_size'] = Avatar::urlByProfile($profile, AVATAR_PROFILE_SIZE);
     try {
         $avatar = Avatar::getUploaded($profile);
         $origurl = $avatar->displayUrl();
     } catch (Exception $e) {
         $origurl = $twitter_user['profile_image_url_profile_size'];
     }
     $twitter_user['profile_image_url_original'] = $origurl;
     $twitter_user['groups_count'] = $profile->getGroupCount();
     foreach (array('linkcolor', 'backgroundcolor') as $key) {
         $twitter_user[$key] = Profile_prefs::getConfigData($profile, 'theme', $key);
     }
     // END introduced by qvitter API, not necessary for StatusNet API
     $twitter_user['url'] = $profile->homepage ? $profile->homepage : null;
     $twitter_user['protected'] = !empty($user) && $user->private_stream ? true : false;
     $twitter_user['followers_count'] = $profile->subscriberCount();
     // Note: some profiles don't have an associated user
     $twitter_user['friends_count'] = $profile->subscriptionCount();
     $twitter_user['created_at'] = $this->dateTwitter($profile->created);
     $timezone = 'UTC';
     if (!empty($user) && $user->timezone) {
         $timezone = $user->timezone;
     }
     $t = new DateTime();
     $t->setTimezone(new DateTimeZone($timezone));
     $twitter_user['utc_offset'] = $t->format('Z');
     $twitter_user['time_zone'] = $timezone;
     $twitter_user['statuses_count'] = $profile->noticeCount();
     // Is the requesting user following this user?
     // These values might actually also mean "unknown". Ambiguity issues?
     $twitter_user['following'] = false;
     $twitter_user['statusnet_blocking'] = false;
     $twitter_user['notifications'] = false;
     if ($this->scoped instanceof Profile) {
         try {
             $sub = Subscription::getSubscription($this->scoped, $profile);
             // Notifications on?
             $twitter_user['following'] = true;
             $twitter_user['statusnet_blocking'] = $this->scoped->hasBlocked($profile);
             $twitter_user['notifications'] = $sub->jabber || $sub->sms;
         } catch (NoResultException $e) {
             // well, the values are already false...
         }
     }
     if ($get_notice) {
         $notice = $profile->getCurrentNotice();
         if ($notice instanceof Notice) {
             // don't get user!
             $twitter_user['status'] = $this->twitterStatusArray($notice, false);
         }
     }
     // StatusNet-specific
     $twitter_user['statusnet_profile_url'] = $profile->profileurl;
     // The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array
     Event::handle('TwitterUserArray', array($profile, &$twitter_user, $this->scoped, array()));
     return $twitter_user;
 }
Esempio n. 4
0
 function avatarUrl($size = AVATAR_PROFILE_SIZE)
 {
     return Avatar::urlByProfile($this, $size);
 }