From ea0b5e57956985b360afae948553aaad5cbb75d7 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Mon, 16 Jan 2017 04:01:49 -0500 Subject: Add object class --- app/class/object.class.php | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/class/object.class.php diff --git a/app/class/object.class.php b/app/class/object.class.php new file mode 100644 index 0000000..a000a10 --- /dev/null +++ b/app/class/object.class.php @@ -0,0 +1,89 @@ +fields['objects'] = array( + "guid", + "owner", + "parent", + "name", + "created", + "updated", + + "membModify", + "membMemb", + "membAccs", + "membCres", + "membModifys", + "membMembs", + "pubAcc", + "pubAccs", + "pubCres", + + "objtype", + ); + + parent::__construct($guid); + } + + /* + * Get the owner of this object. Either a user object or a group + * object will be returned. If this object does not have an owner, + * NULL will be returned. + */ + public function getOwner() : agent + { + if (!isset($this->owner) || $this->owner == "") + return NULL; + + $obj = new object($this->owner); + + if ($obj->objtype == "group") + return new group($this->owner); + + return new user($this->owner); + } + + /* + * Get an array of all members of this object + */ + public function getMembers() : array + { + $memb = array(); + $query = "SELECT member FROM members WHERE guid = '" . $this->db->esc($this->guid) . "'"; + $res = $this->db->query($query); + + foreach ($res as $m) + $memb[] = new user($m['member']); + + return $memb; + } +} + +?> -- cgit v1.2.3