Added $wgInvisibleGroups, to hide groups from Special:Listusers
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 25 Jan 2006 12:01:26 +0000 (12:01 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 25 Jan 2006 12:01:26 +0000 (12:01 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/SpecialListusers.php
includes/User.php

index 49fbf04..a64597f 100644 (file)
@@ -331,6 +331,7 @@ Special Pages:
 * (bug 3192): properly check 'limit' parameter on Special:Contributions
 * (bug 3187) watchlist text refer to unexistent "Stop watching" action
 * Add block link and a link to the block log to Special:Contributions
+* Added $wgInvisibleGroups, to hide groups from Special:Listusers
 
 Misc.:
 * PHP 4.1 compatibility fix: don't use new_link parameter to mysql_connect
index b971c6b..165e25a 100644 (file)
@@ -846,6 +846,10 @@ $wgGroupPermissions['bureaucrat']['userrights'] = true;
  */
 # $wgGroupPermissions['developer']['siteadmin'] = true;
 
+/**
+ * List of groups which won't appear in Special:Listusers
+ */
+$wgInvisibleGroups = array();
 
 /**
  * Set of available actions that can be restricted via Special:Protect
index 9183ea5..1105ddf 100644 (file)
@@ -88,8 +88,8 @@ class ListUsersPage extends QueryPage {
                                '<input type="hidden" name="title" value="'.$special.'" />' .
                                wfMsgHtml( 'groups-editgroup-name' ) . '<select name="group">';
 
-               // get all group names and IDs
-               $groups = User::getAllGroups();
+               // get group names
+               $groups = User::getVisibleGroups();
 
                // we want a default empty group
                $out.= '<option value=""></option>';
@@ -174,7 +174,6 @@ class ListUsersPage extends QueryPage {
        }
 
        function formatResult( $skin, $result ) {
-
                $userPage = Title::makeTitle( $result->namespace, $result->title );
                $name = $skin->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
 
@@ -186,7 +185,9 @@ class ListUsersPage extends QueryPage {
                                'ListUsersPage::formatResult' );
                        $groups = array();
                        while( $row = $dbr->fetchObject( $result ) ) {
-                               $groups[] = User::getGroupName( $row->ug_group );
+                               if ( User::isVisibleGroup( $row->ug_group ) ) {
+                                       $groups[] = User::getGroupName( $row->ug_group );
+                               }
                        }
                        $dbr->freeResult( $result );
 
index 260f8e8..02f7ec3 100644 (file)
@@ -1853,6 +1853,25 @@ class User {
                        array( '*', 'user', 'autoconfirmed' ) );
        }
 
+       /**
+        * Return the set of groups which are not marked "invisible"
+        * @return array
+        * @static
+        */
+       function getVisibleGroups() {
+               global $wgGroupPermissions, $wgInvisibleGroups;
+               return array_diff( User::getAllGroups(), $wgInvisibleGroups );
+       }
+
+       /**
+        * Determine if a given group name is a valid, visible group
+        * @param string name
+        * @return bool
+        */
+       function isVisibleGroup( $group ) {
+               global $wgGroupPermissions, $wgInvisibleGroups;
+               return isset( $wgGroupPermissions[$group] ) && !in_array( $group, $wgInvisibleGroups );
+       }
 }
 
 ?>