From: Tim Düsterhus Date: Thu, 25 Oct 2012 18:31:18 +0000 (+0200) Subject: Add UserGroup::getGroupByID() X-Git-Tag: 2.0.0_Beta_1~821^2~12^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cbe2318824a331a7eb1706f9420884c41a7d68ee;p=GitHub%2FWoltLab%2FWCF.git Add UserGroup::getGroupByID() --- 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.