From 3f58919204a6d21111b6ff00ccec1e2a9dfac040 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 8 Jun 2016 23:36:35 -0400 Subject: Add function Object::getOwner() Added object function to get the owner of an object. This base-class function returns a User object, however a user might not always be the kind of owner (eg: a group can own a pad). In these situations, Object sub-classes should override this function and return the appropriate type of object. --- app/class/object.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app') diff --git a/app/class/object.class.php b/app/class/object.class.php index a64bdfb..8a4b956 100644 --- a/app/class/object.class.php +++ b/app/class/object.class.php @@ -15,6 +15,7 @@ */ require_once "class/framework.class.php"; +require_once "class/user.class.php"; /* * Base class for Scrott database objects @@ -253,6 +254,17 @@ abstract class Object extends Framework return hash("sha256", openssl_random_pseudo_bytes(64)); } + /* + * Get a user object for this object's owner + */ + function getOwner() + { + if (isset($this->owner)) + return new User($this->owner); + + return null; + } + /* * Get an array of all members of this object */ -- cgit v1.2.3