From 78667b156328dfe500330aa3bf83bf84e3116948 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 11 Jun 2016 01:11:23 -0400 Subject: 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. --- app/class/user.class.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'app/class/user.class.php') 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; + } } ?> -- cgit v1.2.3 From 7fd20cd4e15aec3079377e48f18ba91bbda462eb Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 13 Sep 2016 23:32:37 -0400 Subject: Move function User::getHeadImage() to Object class Increase the scope of this function so it may be used by groups. --- app/class/user.class.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index 3239568..44b4b5f 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -213,14 +213,6 @@ class User extends Object return "glyphicon glyphicon-user"; } - /* - * Get this user's head image - */ - function getHeadImage() - { - return $this->ar() . "/file.php?d=img/heads&f=" . $this->guid; - } - /* * Remove this user's head image */ -- cgit v1.2.3 From 35da301d31045b0974100307a7f0f4128b482170 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 18 Sep 2016 11:59:11 -0400 Subject: Move function User::rmHeadImage() to Object class --- app/class/user.class.php | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'app/class/user.class.php') diff --git a/app/class/user.class.php b/app/class/user.class.php index 44b4b5f..b8143a9 100644 --- a/app/class/user.class.php +++ b/app/class/user.class.php @@ -213,17 +213,6 @@ class User extends Object return "glyphicon glyphicon-user"; } - /* - * Remove this user's head image - */ - function rmHeadImage() - { - if (!is_file("assets/img/heads/" . $this->guid)) - return true; - - return unlink("assets/img/heads/" . $this->guid); - } - /* * Get all groups this user owns or is a member of */ -- cgit v1.2.3