Create User::getGroupsInRoles(). Given an array of roles (edit, read, delete), return...
authorChad Horohoe <demon@users.mediawiki.org>
Sat, 2 Aug 2008 12:42:51 +0000 (12:42 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Sat, 2 Aug 2008 12:42:51 +0000 (12:42 +0000)
includes/User.php

index 5c12981..09326cc 100644 (file)
@@ -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