From 5e8f3fb2adb74a9eb5c841848cfaae6502c9e91a Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 26 Mar 2017 19:18:19 -0400 Subject: Add group class --- app/class/group.class.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/class/group.class.php (limited to 'app/class') diff --git a/app/class/group.class.php b/app/class/group.class.php new file mode 100644 index 0000000..1e98aff --- /dev/null +++ b/app/class/group.class.php @@ -0,0 +1,66 @@ +fields['groups'] = array( + "guid", + ); + + parent::__construct($guid); + $this->expectType("group"); + } + + /* + * Get an array of all groups, sorted by name + */ + public static function getAll_ordByName() : array + { + $query = "SELECT guid FROM objects WHERE objtype = 'group' ORDER BY name"; + $res = database::query($query); + + $groups = array(); + + foreach ($res as $g) + $groups[] = new group($g['guid']); + + return $groups; + } + + /* + * Initialize a new group object with the given name and owner + */ + public static function initNew(string $name, user $owner) : group + { + $group = new group(); + $group->setOwner($owner); + $group->name = $name; + $group->objtype = "group"; + return $group; + } +} + +?> -- cgit v1.2.3