From: Chad Horohoe Date: Sat, 2 Aug 2008 12:42:51 +0000 (+0000) Subject: Create User::getGroupsInRoles(). Given an array of roles (edit, read, delete), return... X-Git-Tag: 1.31.0-rc.0~46195 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=556afd34ebf0a5949ac1ac832955df13a9618685;p=lhc%2Fweb%2Fwiklou.git Create User::getGroupsInRoles(). Given an array of roles (edit, read, delete), return the groups allowed to do each. --- diff --git a/includes/User.php b/includes/User.php index 5c12981970..09326cc1f5 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2767,6 +2767,23 @@ class User { } return $rights; } + + /** + * @param $roles Array: list of roles + * @return array list of groups with the given permission + */ + static function getGroupsInRoles( $roles ) { + global $wgGroupPermissions; + $allowedGroups = array(); + foreach ( $roles as $role ) { + foreach ( $wgGroupPermissions as $group => $rights ) { + if ( $rights[$role] === true ) { + $allowedGroups[$role][] = $group; + } + } + } + return $allowedGroups; + } /** * @param $group String: key name