Cleanup to r38608 ("Refactor badaccess-groupX and friends to use User::getGroupsWithP...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 5 Aug 2008 05:32:30 +0000 (05:32 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 5 Aug 2008 05:32:30 +0000 (05:32 +0000)
* Remove some code duplication
* Fix some errors and plural failures in OutputPage::permissionRequired()
* Make the badaccess messages consistently wikitext now; in last rev they were output in different ways in each usage

includes/OutputPage.php
includes/Title.php

index 1a55c81..33bfaba 100644 (file)
@@ -1068,25 +1068,15 @@ class OutputPage {
                $this->setArticleRelated( false );
                $this->mBodytext = '';
 
-               $groups = array();
-               foreach( User::getGroupsWithPermission( $permission ) as $key ) {
-                       $groupName = User::getGroupName( $key );
-                       $groupPage = User::getGroupPage( $key );
-                       if( $groupPage ) {
-                               $skin = $wgUser->getSkin();
-                               $groups[] = $skin->makeLinkObj( $groupPage, $groupName );
-                       } else {
-                               $groups[] = $groupName;
-                       }
-               }
-               $n = count( $groups );
-               if ( $count > 0 ) {
-                       $message = wfMsgHtml( 'badaccess-groups', array( $groups, $n ) );
-               }
-               else {
-                       $message = wfMsgHtml( "badaccess-group0", $groups );
+               $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
+                       User::getGroupsWithPermission( $permission ) );
+               if( $groups ) {
+                       $this->addWikiMsg( 'badaccess-groups',
+                               implode( ', ', $groups ),
+                               count( $groups) );
+               } else {
+                       $this->addWikiMsg( 'badaccess-group0' );
                }
-               $this->addHtml( $message );
                $this->returnToMain();
        }
 
index f885740..c60be4a 100644 (file)
@@ -1307,23 +1307,16 @@ class Title {
                        $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
                } elseif ( !$user->isAllowed( $action ) ) {
                        $return = null;
-                       $groups = array();
-                       foreach( User::getGroupsWithPermission( $action ) as $key ) {
-                               $groupName = User::getGroupName( $key );
-                               $groupPage = User::getGroupPage( $key );
-                               if( $groupPage ) {
-                                       $groups[] = '[['.$groupPage->getPrefixedText().'|'.$groupName.']]';
-                               } else {
-                                       $groups[] = $groupName;
-                               }
-                       }
-                       $n = count( $groups );
-                       if ( $n > 0 ) {
-                               $groups = implode( ', ', $groups );
-                               $return = array( 'badaccess-groups', array( $groups, $n ) );
+                       $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
+                               User::getGroupsWithPermission( $action ) );
+                       if ( $groups ) {
+                               $return = array( 'badaccess-groups',
+                                       array(
+                                               implode( ', ', $groups ),
+                                               count( $groups ) ) );
                        }
                        else {
-                               $return = array( "badaccess-group0", $groups );
+                               $return = array( "badaccess-group0" );
                        }
                        $errors[] = $return;
                }