From c7ca1a555170e2cc6c550a53d4312c57b51efda1 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 18 Apr 2008 00:23:52 +0000 Subject: [PATCH] * Do not display empty columns on Special:UserRights if all groups are changeable or all unchangeable. * On Special:UserRights, when you can add a group you can't remove or remove one you can't add, a notice is printed to warn you. This is to avoid confusion like that exhibited at bug 13503; it's a fairly unusual situation in MediaWiki to be unable to reverse your own actions, so a notice seems to be appropriate. (I changed the userrights-groups-help message to point out the meaning of the extra markup; should it be renamed? It's a common and kind of annoying problem, we should think up some consistent way of versioning messages. Start adding numbers to the end?) --- RELEASE-NOTES | 4 +++ includes/SpecialUserrights.php | 41 ++++++++++++++++++++------- languages/messages/MessagesEn.php | 4 ++- maintenance/language/messageTypes.inc | 1 + maintenance/language/messages.inc | 1 + 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c692146ed6..25b1f68abc 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -81,6 +81,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN a slightly less huge margin and padding. * (bug 13527) Use sitemaps.org format 0.9 instead of a Google-specific format * Allow \C and \Q as TeX commands to match \R, \N, \Z +* On Special:UserRights, when you can add a group you can't remove or remove + one you can't add, a notice is printed to warn you === Bug fixes in 1.13 === @@ -197,6 +199,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Properly escape search terms with regex chars so they appear highlighted in search results * (bug 13768) pt_title field encoding fixed +* Do not display empty columns on Special:UserRights if all groups are + changeable or all unchangeable === API changes in 1.13 === diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php index 349009dc70..4061a89654 100644 --- a/includes/SpecialUserrights.php +++ b/includes/SpecialUserrights.php @@ -406,13 +406,21 @@ class UserrightsPage extends SpecialPage { foreach ($allgroups as $group) { $set = in_array( $group, $usergroups ); + # Should the checkbox be disabled? $disabled = !( ( $set && $this->canRemove( $group ) ) || ( !$set && $this->canAdd( $group ) ) ); + # Do we need to point out that this action is irreversible? + $irreversible = !$disabled && ( + ($set && !$this->canAdd( $group )) || + (!$set && !$this->canRemove( $group ) ) ); $attr = $disabled ? array( 'disabled' => 'disabled' ) : array(); - $checkbox = Xml::checkLabel( User::getGroupMember( $group ), "wpGroup-$group", - "wpGroup-$group", $set, $attr ); + $text = $irreversible + ? wfMsgHtml( 'userrights-irreversible-marker', User::getGroupMember( $group ) ) + : User::getGroupMember( $group ); + $checkbox = Xml::checkLabel( $text, "wpGroup-$group", + "wpGroup-$group", $set, $attr ); $checkbox = $disabled ? Xml::tags( 'span', array( 'class' => 'mw-userrights-disabled' ), $checkbox ) : $checkbox; if ($disabled) { @@ -424,19 +432,32 @@ class UserrightsPage extends SpecialPage { if ($column) { $ret .= Xml::openElement( 'table', array( 'border' => '0', 'class' => 'mw-userrights-groups' ) ) . - "" . - xml::element( 'th', null, wfMsg( 'userrights-changeable-col' ) ) . - xml::element( 'th', null, wfMsg( 'userrights-unchangeable-col' ) ) . - " + " +"; + if( $settable_col !== '' ) { + $ret .= xml::element( 'th', null, wfMsg( 'userrights-changeable-col' ) ); + } + if( $unsettable_col !== '' ) { + $ret .= xml::element( 'th', null, wfMsg( 'userrights-unchangeable-col' ) ); + } + $ret.= " - +"; + if( $settable_col !== '' ) { + $ret .= +" $settable_col - +"; + } + if( $unsettable_col !== '' ) { + $ret .= +" $unsettable_col - " . - Xml::closeElement( 'table' ); + "; + } + $ret .= Xml::closeElement( 'table' ); } return $ret; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 755c5771d9..5cefa6d87c 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1413,7 +1413,8 @@ please see math/README to configure.', 'userrights-groupsavailable' => 'Available groups:', 'userrights-groups-help' => 'You may alter the groups this user is in. A checked box means the user is in that group. -An unchecked box means the user is not in that group.', +An unchecked box means the user is not in that group. +A * indicates that you cannot remove the group once you have added it, or vice versa.', 'userrights-reason' => 'Reason for change:', 'userrights-available-none' => 'You may not alter group membership.', 'userrights-available-add' => 'You can add any user to {{PLURAL:$2|this group|these groups}}: $1.', @@ -1426,6 +1427,7 @@ An unchecked box means the user is not in that group.', 'userrights-notallowed' => 'Your account does not have permission to assign user rights.', 'userrights-changeable-col' => 'Groups you can change', 'userrights-unchangeable-col' => 'Groups you cannot change', +'userrights-irreversible-marker' => '$1*', # only translate this message to other languages if you have to change it # Groups 'group' => 'Group:', diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 90c82bdb89..673622377e 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -151,6 +151,7 @@ $wgOptionalMessages = array( 'ancientpages-summary', 'unwatchedpages-summary', 'userrights-summary', + 'userrights-irreversible-marker', 'brokenredirects-summary', 'deadendpages-summary', 'protectedpages-summary', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 429e510d47..e046219bbf 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -812,6 +812,7 @@ $wgMessageStructure = array( 'userrights-notallowed', 'userrights-changeable-col', 'userrights-unchangeable-col', + 'userrights-irreversible-marker', ), 'group' => array( 'group', -- 2.20.1