diff options
author | Evan Prodromou <evan@status.net> | 2010-12-11 11:03:02 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-12-11 11:03:02 -0500 |
commit | 8dea5144a948a1c5dbf51ad8b3f39f4bd2e2fb30 (patch) | |
tree | d8384d1c0426b71e03e20e943b704cf9a5dac45b /classes/Profile.php | |
parent | 37c447be4637dc639f586846d35e14a4bfce069d (diff) | |
parent | af4ee1d490b86e5d50cfcb62db3b886c9305da8c (diff) |
Merge branch '0.9.x' into activityatompub
Diffstat (limited to 'classes/Profile.php')
-rw-r--r-- | classes/Profile.php | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/classes/Profile.php b/classes/Profile.php index 8dbdcbd97..239c368ca 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -380,54 +380,32 @@ class Profile extends Memcached_DataObject function getSubscriptions($offset=0, $limit=null) { - $qry = - 'SELECT profile.* ' . - 'FROM profile JOIN subscription ' . - 'ON profile.id = subscription.subscribed ' . - 'WHERE subscription.subscriber = %d ' . - 'AND subscription.subscribed != subscription.subscriber ' . - 'ORDER BY subscription.created DESC '; - - if ($offset>0 && !is_null($limit)){ - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } - } + $subs = Subscription::bySubscriber($this->id, + $offset, + $limit); - $profile = new Profile(); + $profiles = array(); - $profile->query(sprintf($qry, $this->id)); + while ($subs->fetch()) { + $profiles[] = Profile::staticGet($subs->subscribed); + } - return $profile; + return new ArrayWrapper($profiles); } function getSubscribers($offset=0, $limit=null) { - $qry = - 'SELECT profile.* ' . - 'FROM profile JOIN subscription ' . - 'ON profile.id = subscription.subscriber ' . - 'WHERE subscription.subscribed = %d ' . - 'AND subscription.subscribed != subscription.subscriber ' . - 'ORDER BY subscription.created DESC '; - - if ($offset>0 && !is_null($limit)){ - if ($offset) { - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } - } - } + $subs = Subscription::bySubscribed($this->id, + $offset, + $limit); - $profile = new Profile(); + $profiles = array(); - $cnt = $profile->query(sprintf($qry, $this->id)); + while ($subs->fetch()) { + $profiles[] = Profile::staticGet($subs->subscriber); + } - return $profile; + return new ArrayWrapper($profiles); } function getConnectedApps($offset = 0, $limit = null) |