summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-01-21 12:19:23 -0500
committerEvan Prodromou <evan@controlyourself.ca>2009-01-21 12:19:23 -0500
commitfb6e9dda8e2066e25e9103dc3715cb56c6abeacd (patch)
tree4757fd1efe403f9957e64bf75cd7a359f563b89e /classes
parent785fb0a08fe74f746367d937be527b7f3f76fb8d (diff)
A method on User for getting groups
Diffstat (limited to 'classes')
-rw-r--r--classes/User.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php
index 51e23fccf..e507e082f 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -520,4 +520,26 @@ class User extends Memcached_DataObject
return false;
}
}
+
+ function getGroups($offset, $limit)
+ {
+ $qry =
+ 'SELECT user_group.* ' .
+ 'FROM user_group JOIN group_member '.
+ 'ON user_group.id = group_member.group_id ' .
+ 'WHERE group_member.profile_id = %d ' .
+ 'ORDER BY group_member.created DESC ';
+
+ 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;
+ }
}