summaryrefslogtreecommitdiff
path: root/classes/Profile.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-15 11:59:31 -0800
committerBrion Vibber <brion@pobox.com>2010-12-15 11:59:31 -0800
commitbf20258f4b61dd8396db9a1980463c060dab292c (patch)
treef43d7d73e9877bb40fe373afcf3849f9cd5c3398 /classes/Profile.php
parent9df856e667a12cd217576263efbc72fff12692d9 (diff)
parent6c671141982c5837a2e5bf1e90de389c728d5dee (diff)
Merge branch '0.9.x' into 1.0.x
Diffstat (limited to 'classes/Profile.php')
-rw-r--r--classes/Profile.php77
1 files changed, 15 insertions, 62 deletions
diff --git a/classes/Profile.php b/classes/Profile.php
index 05df8899e..1f959eb0d 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -380,79 +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;
- }
- }
- }
-
- $profile = new Profile();
+ $subs = Subscription::bySubscribed($this->id,
+ $offset,
+ $limit);
- $cnt = $profile->query(sprintf($qry, $this->id));
-
- return $profile;
- }
+ $profiles = array();
- function getConnectedApps($offset = 0, $limit = null)
- {
- $qry =
- 'SELECT u.* ' .
- 'FROM oauth_application_user u, oauth_application a ' .
- 'WHERE u.profile_id = %d ' .
- 'AND a.id = u.application_id ' .
- 'AND u.access_type > 0 ' .
- 'ORDER BY u.created DESC ';
-
- if ($offset > 0) {
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ while ($subs->fetch()) {
+ $profiles[] = Profile::staticGet($subs->subscriber);
}
- $apps = new Oauth_application_user();
-
- $cnt = $apps->query(sprintf($qry, $this->id));
-
- return $apps;
+ return new ArrayWrapper($profiles);
}
function subscriptionCount()