From: Brion Vibber Date: Tue, 5 Aug 2008 05:32:30 +0000 (+0000) Subject: Cleanup to r38608 ("Refactor badaccess-groupX and friends to use User::getGroupsWithP... X-Git-Tag: 1.31.0-rc.0~46128 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=d676ceaa91593459cbac08644bc84a05eda34cdd;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 1a55c81d7e..33bfaba4d8 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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(); } diff --git a/includes/Title.php b/includes/Title.php index f885740e07..c60be4a43d 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; }