From cbe2318824a331a7eb1706f9420884c41a7d68ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 25 Oct 2012 20:31:18 +0200 Subject: [PATCH] Add UserGroup::getGroupByID() --- .../lib/data/user/group/UserGroup.class.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php index ae9400480a..522a5ef8ff 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php @@ -94,7 +94,7 @@ class UserGroup extends DatabaseObject { * Returns groups by given type. Returns all groups if no types given. * * @param array $types - * @return array + * @return array */ public static function getGroupsByType(array $types = array()) { self::getCache(); @@ -117,7 +117,7 @@ class UserGroup extends DatabaseObject { * Returns unique group by given type. Only works for the default user groups. * * @param integer $type - * @return UserGroup + * @return wcf\data\user\group\UserGroup */ public static function getGroupByType($type) { if ($type != self::EVERYONE && $type != self::GUESTS && $type != self::USERS) { @@ -128,6 +128,23 @@ class UserGroup extends DatabaseObject { return array_shift($groups); } + /** + * Returns a group from _cache_ by given groupID. + * null is returned when the given groupID is invalid. + * + * @param integer $groupID + * @return wcf\data\user\group\UserGroup + */ + public static function getGroupByID($groupID) { + self::getCache(); + + if (isset(self::$cache['groups'][$groupID])) { + return self::$cache['groups'][$groupID]; + } + + return null; + } + /** * Returns true, if the given user is member of the group. If no user is * given, the active user is used. -- 2.20.1