summaryrefslogtreecommitdiffstats
path: root/app/class
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-03-26 18:54:43 -0400
committerMalf Furious <m@lfurio.us>2017-03-26 18:54:43 -0400
commit1ff545e5621ba711cd20aec06f4f39d645c2600a (patch)
treeb72964b1cf41a42bca400444c559567af355d0f3 /app/class
parent5b8fafdc1608d017f63548a9af7c1043ccc61968 (diff)
downloadscrott-1ff545e5621ba711cd20aec06f4f39d645c2600a.tar.gz
scrott-1ff545e5621ba711cd20aec06f4f39d645c2600a.zip
Add function object::typeOf()
Also updated the getOwner function to use this instead of duplicating logic.
Diffstat (limited to 'app/class')
-rw-r--r--app/class/object.class.php13
1 files 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
@@ -50,6 +50,15 @@ class object extends table
}
/*
+ * 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,
* NULL will be returned.
@@ -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);