/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $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(); // only keep id, name, nickname and avatar URL foreach ($this->profiles as $p) { try { $avatar = Avatar::byProfile($p, AVATAR_STREAM_SIZE); $avatar = $avatar->url; } 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; } return true; }
public function asActivityObject() { $object = new ActivityObject(); if (Event::handle('StartActivityObjectFromProfile', array($this, &$object))) { $object->type = $this->getObjectType(); $object->id = $this->getUri(); $object->title = $this->getBestName(); $object->link = $this->getUrl(); $object->summary = $this->getDescription(); try { $avatar = Avatar::getUploaded($this); $object->avatarLinks[] = AvatarLink::fromAvatar($avatar); } catch (NoAvatarException $e) { // Could not find an original avatar to link } $sizes = array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE); foreach ($sizes as $size) { $alink = null; try { $avatar = Avatar::byProfile($this, $size); $alink = AvatarLink::fromAvatar($avatar); } catch (NoAvatarException $e) { $alink = new AvatarLink(); $alink->type = 'image/png'; $alink->height = $size; $alink->width = $size; $alink->url = Avatar::defaultImage($size); } $object->avatarLinks[] = $alink; } if (isset($this->lat) && isset($this->lon)) { $object->geopoint = (double) $this->lat . ' ' . (double) $this->lon; } $object->poco = PoCo::fromProfile($this); if ($this->isLocal()) { $object->extra[] = array('followers', array('url' => common_local_url('subscribers', array('nickname' => $this->getNickname())))); } Event::handle('EndActivityObjectFromProfile', array($this, &$object)); } return $object; }