Function out query building, to allow easier overriding
[lhc/web/wiklou.git] / includes / specials / SpecialListgrouprights.php
index 411e315..e351729 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 /**
+ * Implements Special:Listgrouprights
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,6 +16,9 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
  */
 
 /**
@@ -56,22 +60,31 @@ class SpecialListGroupRights extends SpecialPage {
                                '</tr>'
                );
 
-               foreach( $wgGroupPermissions as $group => $permissions ) {
-                       $groupname = ( $group == '*' ) ? 'all' : $group; // Replace * with a more descriptive groupname
+               $allGroups = array_unique( array_merge( 
+                       array_keys( $wgGroupPermissions ),
+                       array_keys( $wgRevokePermissions ),
+                       array_keys( $wgAddGroups ),
+                       array_keys( $wgRemoveGroups ),
+                       array_keys( $wgGroupsAddToSelf ),
+                       array_keys( $wgGroupsRemoveFromSelf )
+               ) );
+               asort( $allGroups );
+                               
+               foreach ( $allGroups as $group ) {
+                       $permissions = isset( $wgGroupPermissions[$group] ) 
+                               ? $wgGroupPermissions[$group] 
+                               : array();
+                       $groupname = ( $group == '*' ) // Replace * with a more descriptive groupname
+                               ? 'all' 
+                               : $group; 
 
-                       $msg = wfMsg( 'group-' . $groupname );
-                       if ( wfEmptyMsg( 'group-' . $groupname, $msg ) || $msg == '' ) {
-                               $groupnameLocalized = $groupname;
-                       } else {
-                               $groupnameLocalized = $msg;
-                       }
+                       $msg = wfMessage( 'group-' . $groupname );
+                       $groupnameLocalized = !$msg->isBlank() ? $msg->text() : $groupname;
 
-                       $msg = wfMsgForContent( 'grouppage-' . $groupname );
-                       if ( wfEmptyMsg( 'grouppage-' . $groupname, $msg ) || $msg == '' ) {
-                               $grouppageLocalized = MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
-                       } else {
-                               $grouppageLocalized = $msg;
-                       }
+                       $msg = wfMessage( 'grouppage-' . $groupname )->inContentLanguage();
+                       $grouppageLocalized = !$msg->isBlank() ?
+                               $msg->text() :
+                               MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
 
                        if( $group == '*' ) {
                                // Do not make a link for the generic * group