r38613 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38612‎ | r38613 | r38614 >
Date:05:32, 5 August 2008
Author:brion
Status:old
Tags:
Comment:
Cleanup to r38608 ("Refactor badaccess-groupX and friends to use User::getGroupsWithPermission().")
* 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
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -1068,25 +1068,15 @@
10691069 $this->setArticleRelated( false );
10701070 $this->mBodytext = '';
10711071
1072 - $groups = array();
1073 - foreach( User::getGroupsWithPermission( $permission ) as $key ) {
1074 - $groupName = User::getGroupName( $key );
1075 - $groupPage = User::getGroupPage( $key );
1076 - if( $groupPage ) {
1077 - $skin = $wgUser->getSkin();
1078 - $groups[] = $skin->makeLinkObj( $groupPage, $groupName );
1079 - } else {
1080 - $groups[] = $groupName;
1081 - }
 1072+ $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
 1073+ User::getGroupsWithPermission( $permission ) );
 1074+ if( $groups ) {
 1075+ $this->addWikiMsg( 'badaccess-groups',
 1076+ implode( ', ', $groups ),
 1077+ count( $groups) );
 1078+ } else {
 1079+ $this->addWikiMsg( 'badaccess-group0' );
10821080 }
1083 - $n = count( $groups );
1084 - if ( $count > 0 ) {
1085 - $message = wfMsgHtml( 'badaccess-groups', array( $groups, $n ) );
1086 - }
1087 - else {
1088 - $message = wfMsgHtml( "badaccess-group0", $groups );
1089 - }
1090 - $this->addHtml( $message );
10911081 $this->returnToMain();
10921082 }
10931083
Index: trunk/phase3/includes/Title.php
@@ -1307,23 +1307,16 @@
13081308 $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
13091309 } elseif ( !$user->isAllowed( $action ) ) {
13101310 $return = null;
1311 - $groups = array();
1312 - foreach( User::getGroupsWithPermission( $action ) as $key ) {
1313 - $groupName = User::getGroupName( $key );
1314 - $groupPage = User::getGroupPage( $key );
1315 - if( $groupPage ) {
1316 - $groups[] = '[['.$groupPage->getPrefixedText().'|'.$groupName.']]';
1317 - } else {
1318 - $groups[] = $groupName;
1319 - }
 1311+ $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
 1312+ User::getGroupsWithPermission( $action ) );
 1313+ if ( $groups ) {
 1314+ $return = array( 'badaccess-groups',
 1315+ array(
 1316+ implode( ', ', $groups ),
 1317+ count( $groups ) ) );
13201318 }
1321 - $n = count( $groups );
1322 - if ( $n > 0 ) {
1323 - $groups = implode( ', ', $groups );
1324 - $return = array( 'badaccess-groups', array( $groups, $n ) );
1325 - }
13261319 else {
1327 - $return = array( "badaccess-group0", $groups );
 1320+ $return = array( "badaccess-group0" );
13281321 }
13291322 $errors[] = $return;
13301323 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r38608Refactor badaccess-groupX and friends to use User::getGroupsWithPermission()....demon02:37, 5 August 2008

Status & tagging log