From: Marcel Werk Date: Mon, 10 Dec 2012 02:44:54 +0000 (+0100) Subject: Added support for invalid group type filter X-Git-Tag: 2.0.0_Beta_1~721 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=34370320df89bd3a7ed449852397305ffac817c8;p=GitHub%2FWoltLab%2FWCF.git Added support for invalid group type filter --- 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 74f26b8d8f..34a4bf4d58 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php @@ -94,20 +94,17 @@ class UserGroup extends DatabaseObject { * Returns groups by given type. Returns all groups if no types given. * * @param array $types + * @param array $invalidGroupTypes * @return array */ - public static function getGroupsByType(array $types = array()) { + public static function getGroupsByType(array $types = array(), array $invalidGroupTypes = array()) { self::getCache(); - // get all groups - if (empty($types)) return self::$cache['groups']; - - // get groups by type - $groupIDs = self::getGroupIDsByType($types); $groups = array(); - - foreach ($groupIDs as $groupID) { - $groups[$groupID] = self::$cache['groups'][$groupID]; + foreach (self::$cache['groups'] as $group) { + if ((empty($types) || in_array($group->groupType, $types)) && !in_array($group->groupType, $invalidGroupTypes)) { + $groups[$group->groupID] = $group; + } } return $groups; @@ -186,17 +183,10 @@ class UserGroup extends DatabaseObject { * * @param array $groupTypes * @param array $invalidGroupTypes - * @return array + * @return array */ public static function getAccessibleGroups(array $groupTypes = array(), array $invalidGroupTypes = array()) { - $groups = self::getGroupsByType($groupTypes); - - if (!empty($invalidGroupTypes)) { - $invalidGroups = self::getGroupsByType($invalidGroupTypes); - foreach ($invalidGroups as $groupID => $group) { - unset($groups[$groupID]); - } - } + $groups = self::getGroupsByType($groupTypes, $invalidGroupTypes); foreach ($groups as $key => $value) { if (!self::isAccessibleGroup(array($key))) {