summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialListgrouprights.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialListgrouprights.php')
-rw-r--r--includes/specials/SpecialListgrouprights.php78
1 files changed, 27 insertions, 51 deletions
diff --git a/includes/specials/SpecialListgrouprights.php b/includes/specials/SpecialListgrouprights.php
index 5bae28f0..828a93b9 100644
--- a/includes/specials/SpecialListgrouprights.php
+++ b/includes/specials/SpecialListgrouprights.php
@@ -86,13 +86,14 @@ class SpecialListGroupRights extends SpecialPage {
$grouppageLocalized = !$msg->isBlank() ?
$msg->text() :
MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
+ $grouppageLocalizedTitle = Title::newFromText( $grouppageLocalized );
- if ( $group == '*' ) {
- // Do not make a link for the generic * group
+ if ( $group == '*' || !$grouppageLocalizedTitle ) {
+ // Do not make a link for the generic * group or group with invalid group page
$grouppage = htmlspecialchars( $groupnameLocalized );
} else {
$grouppage = Linker::link(
- Title::newFromText( $grouppageLocalized ),
+ $grouppageLocalizedTitle,
htmlspecialchars( $groupnameLocalized )
);
}
@@ -235,20 +236,18 @@ class SpecialListGroupRights extends SpecialPage {
foreach ( $permissions as $permission => $granted ) {
//show as granted only if it isn't revoked to prevent duplicate display of permissions
if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
- $description = $this->msg( 'listgrouprights-right-display',
+ $r[] = $this->msg( 'listgrouprights-right-display',
User::getRightDescription( $permission ),
'<span class="mw-listgrouprights-right-name">' . $permission . '</span>'
)->parse();
- $r[] = $description;
}
}
foreach ( $revoke as $permission => $revoked ) {
if ( $revoked ) {
- $description = $this->msg( 'listgrouprights-right-revoked',
+ $r[] = $this->msg( 'listgrouprights-right-revoked',
User::getRightDescription( $permission ),
'<span class="mw-listgrouprights-right-name">' . $permission . '</span>'
)->parse();
- $r[] = $description;
}
}
@@ -257,51 +256,28 @@ class SpecialListGroupRights extends SpecialPage {
$lang = $this->getLanguage();
$allGroups = User::getAllGroups();
- if ( $add === true ) {
- $r[] = $this->msg( 'listgrouprights-addgroup-all' )->escaped();
- } elseif ( is_array( $add ) ) {
- $add = array_intersect( array_values( array_unique( $add ) ), $allGroups );
- if ( count( $add ) ) {
- $r[] = $this->msg( 'listgrouprights-addgroup',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ),
- count( $add )
- )->parse();
- }
- }
-
- if ( $remove === true ) {
- $r[] = $this->msg( 'listgrouprights-removegroup-all' )->escaped();
- } elseif ( is_array( $remove ) ) {
- $remove = array_intersect( array_values( array_unique( $remove ) ), $allGroups );
- if ( count( $remove ) ) {
- $r[] = $this->msg( 'listgrouprights-removegroup',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ),
- count( $remove )
- )->parse();
- }
- }
-
- if ( $addSelf === true ) {
- $r[] = $this->msg( 'listgrouprights-addgroup-self-all' )->escaped();
- } elseif ( is_array( $addSelf ) ) {
- $addSelf = array_intersect( array_values( array_unique( $addSelf ) ), $allGroups );
- if ( count( $addSelf ) ) {
- $r[] = $this->msg( 'listgrouprights-addgroup-self',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ),
- count( $addSelf )
- )->parse();
- }
- }
+ $changeGroups = array(
+ 'addgroup' => $add,
+ 'removegroup' => $remove,
+ 'addgroup-self' => $addSelf,
+ 'removegroup-self' => $removeSelf
+ );
- if ( $removeSelf === true ) {
- $r[] = $this->msg( 'listgrouprights-removegroup-self-all' )->parse();
- } elseif ( is_array( $removeSelf ) ) {
- $removeSelf = array_intersect( array_values( array_unique( $removeSelf ) ), $allGroups );
- if ( count( $removeSelf ) ) {
- $r[] = $this->msg( 'listgrouprights-removegroup-self',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ),
- count( $removeSelf )
- )->parse();
+ foreach ( $changeGroups as $messageKey => $changeGroup ) {
+ if ( $changeGroup === true ) {
+ // For grep: listgrouprights-addgroup-all, listgrouprights-removegroup-all,
+ // listgrouprights-addgroup-self-all, listgrouprights-removegroup-self-all
+ $r[] = $this->msg( 'listgrouprights-' . $messageKey . '-all' )->escaped();
+ } elseif ( is_array( $changeGroup ) ) {
+ $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
+ if ( count( $changeGroup ) ) {
+ // For grep: listgrouprights-addgroup, listgrouprights-removegroup,
+ // listgrouprights-addgroup-self, listgrouprights-removegroup-self
+ $r[] = $this->msg( 'listgrouprights-' . $messageKey,
+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $changeGroup ) ),
+ count( $changeGroup )
+ )->parse();
+ }
}
}