summaryrefslogtreecommitdiff
path: root/classes/User.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-01-21 13:00:30 -0500
committerEvan Prodromou <evan@controlyourself.ca>2009-01-21 13:00:30 -0500
commit00f6f4fb67f728289041bb1e676f7801ea3bb21b (patch)
tree9ca9a7c0a829f747f22d88185d122b07e5882788 /classes/User.php
parentab2dca20ff2f2dad8cec6205af47cc7dbf1831b4 (diff)
user subscriptions methods
Diffstat (limited to 'classes/User.php')
-rw-r--r--classes/User.php58
1 files changed, 54 insertions, 4 deletions
diff --git a/classes/User.php b/classes/User.php
index c1849abc6..9a1ebddc4 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -521,7 +521,7 @@ class User extends Memcached_DataObject
}
}
- function getGroups($offset, $limit)
+ function getGroups($offset=0, $limit=null)
{
$qry =
'SELECT user_group.* ' .
@@ -530,16 +530,66 @@ class User extends Memcached_DataObject
'WHERE group_member.profile_id = %d ' .
'ORDER BY group_member.created DESC ';
+ if ($offset) {
+ if (common_config('db','type') == 'pgsql') {
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+ }
+ }
+
+ $groups = new User_group();
+
+ $cnt = $groups->query(sprintf($qry, $this->id));
+
+ return $groups;
+ }
+
+ 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 (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
- $groups = new User_group();
+ $profile = new Profile();
- $cnt = $groups->query(sprintf($qry, $this->id));
+ $profile->query(sprintf($qry, $this->id));
- return $groups;
+ return $profile;
+ }
+
+ 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) {
+ if (common_config('db','type') == 'pgsql') {
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+ }
+ }
+
+ $profile = new Profile();
+
+ $cnt = $profile->query(sprintf($qry, $this->id));
+
+ return $profile;
}
}