Add UserGroup::getGroupByID()
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 25 Oct 2012 18:31:18 +0000 (20:31 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 1 Nov 2012 17:16:14 +0000 (18:16 +0100)
wcfsetup/install/files/lib/data/user/group/UserGroup.class.php

index ae9400480ae0247b524e20bfc7879189d6108cc4..522a5ef8ff799cca21136ffd90267f526aab379e 100644 (file)
@@ -94,7 +94,7 @@ class UserGroup extends DatabaseObject {
         * Returns groups by given type. Returns all groups if no types given.
         * 
         * @param       array<integer>          $types
-        * @return      array<UserGroup>
+        * @return      array<wcf\data\user\group\UserGroup>
         */
        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.