summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/class/user.class.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/class/user.class.php b/app/class/user.class.php
index 9892277..97309f8 100644
--- a/app/class/user.class.php
+++ b/app/class/user.class.php
@@ -250,6 +250,34 @@ class user extends agent
$this->emailVer = substr(self::getBlob(), 0, 8);
$this->emailConf = 0;
}
+
+ /*
+ * Get all groups this user owns or is a member of. This isn't necessarily
+ * all groups this user cas access permissions for. Results are sorted by
+ * ownership, then by name.
+ */
+ public function getGroups_ordByOwnByName() : array
+ {
+ $groups = array();
+
+ /* owner */
+ $query = "SELECT guid FROM objects WHERE objtype = 'group' AND owner = '" . database::esc($this->guid) . "' " .
+ "ORDER BY name";
+ $res = database::query($query);
+
+ foreach ($res as $g)
+ $groups[] = new group($g['guid']);
+
+ /* member */
+ $query = "SELECT o.guid FROM objects o JOIN members m ON o.guid = m.guid WHERE o.objtype = 'group' AND " .
+ "m.member = '" . database::esc($this->guid) . "' ORDER BY o.name";
+ $res = database::query($query);
+
+ foreach ($res as $g)
+ $groups[] = new group($g['guid']);
+
+ return $groups;
+ }
}
?>