diff options
author | Malf Furious <m@lfurio.us> | 2016-06-11 01:11:23 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-06-11 01:11:23 -0400 |
commit | 78667b156328dfe500330aa3bf83bf84e3116948 (patch) | |
tree | 18f3e6981e70366825089b685d5dc81bff6d2002 /app/class/user.class.php | |
parent | 112a510bb7ba358fd4195b5b2f3c8203ab4fb91d (diff) | |
download | scrott-78667b156328dfe500330aa3bf83bf84e3116948.tar.gz scrott-78667b156328dfe500330aa3bf83bf84e3116948.zip |
Add function User::getGroups()
This function returns all groups the user either owns or is a member of.
This is not necessarily the same as all groups the user has access
permission to. The *not-yet-implemented* object explorer feature should
be used to browse those.
Diffstat (limited to 'app/class/user.class.php')
-rw-r--r-- | app/class/user.class.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/class/user.class.php b/app/class/user.class.php index 1185f45..3239568 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -15,6 +15,7 @@ */ require_once "class/object.class.php"; +require_once "class/group.class.php"; /* * Application users @@ -230,6 +231,30 @@ class User extends Object return unlink("assets/img/heads/" . $this->guid); } + + /* + * Get all groups this user owns or is a member of + */ + function getGroups() + { + /* owner */ + $query = "SELECT guid FROM object WHERE type = 'group' AND owner = '" . $this->db->esc($this->guid) . "'"; + $result = $this->db->query($query); + + $groups = array(); + + foreach ($result as $g) + $groups[] = new Group($g['guid']); + + /* member */ + $query = "SELECT o.guid FROM object o JOIN obj_member om ON o.guid = om.guid WHERE o.type = 'group' AND member = '" . $this->db->esc($this->guid) . "'"; + $result = $this->db->query($query); + + foreach ($result as $g) + $groups[] = new Group($g['guid']); + + return $groups; + } } ?> |