From 1ff545e5621ba711cd20aec06f4f39d645c2600a Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 26 Mar 2017 18:54:43 -0400 Subject: Add function object::typeOf() Also updated the getOwner function to use this instead of duplicating logic. --- app/class/object.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/class/object.class.php b/app/class/object.class.php index f9fde02..ee3dc21 100644 --- a/app/class/object.class.php +++ b/app/class/object.class.php @@ -49,6 +49,15 @@ class object extends table parent::__construct($guid); } + /* + * Get the object type for the given GUID + */ + public static function typeOf(string $guid) : string + { + $obj = new object($guid); + return $obj->objtype; + } + /* * 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, @@ -59,9 +68,7 @@ class object extends table if (!isset($this->owner) || $this->owner == "") return NULL; - $obj = new object($this->owner); - - if ($obj->objtype == "group") + if (self::typeOf($this->owner) == "group") return new group($this->owner); return new user($this->owner); -- cgit v1.2.3