123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
-
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ApiQvitterAllFollowingAction extends ApiBareAuthAction
- {
- var $profiles = null;
- var $users_stripped = null;
- var $groups_stripped = null;
- var $blocks = null;
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $this->format = 'json';
- $this->count = 5000;
- $this->target = $this->getTargetProfile($this->arg('id'));
- if (!($this->target instanceof Profile)) {
-
- $this->clientError(_('No such user.'), 404);
- }
- $this->profiles = $this->getProfiles();
- $this->groups = $this->getGroups();
- $this->blocks = QvitterBlocked::getBlockedIDs($this->target->id,0,10000);
-
- 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;
- }
-
- 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;
- }
-
- protected function handle()
- {
- parent::handle();
- $this->initDocument('json');
- $this->showJsonObjects(array('users'=>$this->users_stripped,'groups'=>$this->groups_stripped,'blocks'=>$this->blocks));
- $this->endDocument('json');
- }
-
- protected function getProfiles()
- {
- $offset = ($this->page - 1) * $this->count;
- $limit = $this->count + 1;
- $subs = null;
- $subs = $this->target->getSubscribed(
- $offset,
- $limit
- );
- $profiles = array();
- while ($subs->fetch()) {
- $profiles[] = clone($subs);
- }
- return $profiles;
- }
-
- function getGroups()
- {
- $groups = array();
- $group = $this->target->getGroups(
- ($this->page - 1) * $this->count,
- $this->count,
- $this->since_id,
- $this->max_id
- );
- if(!empty($group)) {
- while ($group->fetch()) {
- $groups[] = clone($group);
- }
- }
- return $groups;
- }
- }
|