summaryrefslogtreecommitdiff
path: root/classes/Profile.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Profile.php')
-rw-r--r--classes/Profile.php54
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)