From: Andrew Garrett Date: Mon, 31 Mar 2008 12:55:26 +0000 (+0000) Subject: Redesign of Special:Userrights. X-Git-Tag: 1.31.0-rc.0~48720 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=6723969994be26f985544350c03203fe47485540;p=lhc%2Fweb%2Fwiklou.git Redesign of Special:Userrights. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 215795a7ef..302ae7980f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -145,6 +145,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13540) Date format in confirmation e-mail now matches message language * (bug 13554) PHP Notice in old pre-processor when list item is empty. * (bug 13556) Don't show a blank form if no image is attached in Special:Upload +* Redesign of Special:Userrights === API changes in 1.13 === diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php index 0e2cf56f9e..8d23aead95 100644 --- a/includes/SpecialUserrights.php +++ b/includes/SpecialUserrights.php @@ -97,8 +97,7 @@ class UserrightsPage extends SpecialPage { if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $this->mTarget ) ) { $this->saveUserGroups( $this->mTarget, - $wgRequest->getArray( 'removable' ), - $wgRequest->getArray( 'available' ), + $wgRequest, $reason ); } @@ -121,7 +120,7 @@ class UserrightsPage extends SpecialPage { * @param string $reason Reason for group change * @return null */ - function saveUserGroups( $username, $removegroup, $addgroup, $reason = '') { + function saveUserGroups( $username, $request, $reason = '') { global $wgUser, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; $user = $this->fetchUser( $username ); @@ -129,6 +128,22 @@ class UserrightsPage extends SpecialPage { return; } + $allgroups = User::getAllGroups(); + $addgroup = array(); + $removegroup = array(); + + // This could possibly create a highly unlikely race condition if permissions are changed between + // when the form is loaded and when the form is saved. Ignoring it for the moment. + foreach ($allgroups as $group) { + // We'll tell it to remove all unchecked groups, and add all checked groups. + // Later on, this gets filtered for what can actually be removed + if ($request->getCheck( "wpGroup-$group" )) { + $addgroup[] = $group; + } else { + $removegroup[] = $group; + } + } + // Validate input set... $changeable = $this->changeableGroups(); if ($wgUser->getId() != 0 && $wgUser->getId() == $user->getId()) { @@ -340,23 +355,9 @@ class UserrightsPage extends SpecialPage { Xml::element( 'legend', array(), wfMsg( 'userrights-editusergroup' ) ) . wfMsgExt( 'editinguser', array( 'parse' ), wfEscapeWikiText( $user->getName() ) ) . $grouplist . - $this->explainRights() . + Xml::openElement( 'p') . $this->groupCheckboxes( $groups ) . Xml::closeElement( 'p' ) . Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-userrights-table-outer' ) ) . " - - " . - Xml::openElement( 'table', array( 'style' => 'width:400px;', 'id' => 'mw-userrights-table-inner' ) ) . - " - " . - $this->removeSelect( $removable ) . - " - " . - $this->addSelect( $addable ) . - " - " . - Xml::closeElement( 'table' ) . - " - " . $wgOut->parse( wfMsg( 'userrights-groupshelp' ) ) . " @@ -394,55 +395,6 @@ class UserrightsPage extends SpecialPage { return $cache[$group]; } - /** - * Prepare a list of groups the user is able to add and remove - * - * @return string - */ - private function explainRights() { - global $wgUser, $wgLang; - - $out = array(); - list( $add, $remove, $addself, $rmself ) = array_values( $this->changeableGroups() ); - - if( count( $add ) > 0 ) - $out[] = wfMsgExt( 'userrights-available-add', 'parseinline', - $wgLang->listToText( $add ), count( $add ) ); - if( count( $remove ) > 0 ) - $out[] = wfMsgExt( 'userrights-available-remove', 'parseinline', - $wgLang->listToText( $remove ), count( $add ) ); - if( count( $addself ) > 0 ) - $out[] = wfMsgExt( 'userrights-available-add-self', 'parseinline', - $wgLang->listToText( $addself ), count( $addself ) ); - if( count( $rmself ) > 0 ) - $out[] = wfMsgExt( 'userrights-available-remove-self', 'parseinline', - $wgLang->listToText( $rmself ), count( $rmself ) ); - - return count( $out ) > 0 - ? implode( '
', $out ) - : wfMsgExt( 'userrights-available-none', 'parseinline' ); - } - - /** - * Adds the element - */ - private function removeSelect( $groups ) { - return $this->doSelect( $groups, 'removable' ); - } - - /** - * Adds the element - */ - private function addSelect( $groups ) { - return $this->doSelect( $groups, 'available' ); - } - /** * Adds the element */ - private function doSelect( $groups, $name ) { - $ret = wfMsgHtml( "{$this->mName}-groups$name" ) . - Xml::openElement( 'select', array( - 'name' => "{$name}[]", - 'multiple' => 'multiple', - 'size' => '6', - 'style' => 'width: 100%;' - ) - ); - foreach ($groups as $group) { - $ret .= Xml::element( 'option', array( 'value' => $group ), User::getGroupName( $group ) ); + private function groupCheckboxes( $usergroups ) { + $allgroups = User::getAllGroups(); + $ret = ''; + + if (count($allgroups)>8) { + $column = 1; + $settable_col = ''; + $unsettable_col = ''; + } else { + $column = 0; } - $ret .= Xml::closeElement( 'select' ); + + foreach ($allgroups as $group) { + $set = in_array( $group, $usergroups ); + $disabled = !( + ( $set && $this->canRemove( $group ) ) || + ( !$set && $this->canAdd( $group ) ) ); + + $attr = $disabled ? array( 'disabled' => 'disabled' ) : array(); + $checkbox = wfCheckLabel( User::getGroupMember( $group ), "wpGroup-$group", + "wpGroup-$group", $set, $attr ); + + if ($column) { + if ($disabled) { + $unsettable_col .= "$checkbox
\n"; + } else { + $settable_col .= "$checkbox
\n"; + } + } else { + $ret .= " $checkbox "; + } + } + + if ($column) { + $ret .= ''; + $ret .= ''; + $ret .= ""; + $ret .= "
'.wfMsgHtml('userrights-changeable-col').''.wfMsgHtml('userrights-unchangeable-col').'
$settable_col$unsettable_col
"; + } + return $ret; } @@ -474,7 +453,7 @@ class UserrightsPage extends SpecialPage { // $this->changeableGroups()['remove'] doesn't work, of course. Thanks, // PHP. $groups = $this->changeableGroups(); - return in_array( $group, $groups['remove'] ); + return in_array( $group, $groups['remove'] ) || ($this->isself && in_array( $group, $groups['remove-self'] )); } /** @@ -483,7 +462,7 @@ class UserrightsPage extends SpecialPage { */ private function canAdd( $group ) { $groups = $this->changeableGroups(); - return in_array( $group, $groups['add'] ); + return in_array( $group, $groups['add'] ) || ($this->isself && in_array( $group, $groups['add-self'] )); } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ce5c4b2500..df53d9004e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1382,19 +1382,19 @@ please see math/README to configure.', 'userrights-groupsmember' => 'Member of:', 'userrights-groupsremovable' => 'Removable groups:', 'userrights-groupsavailable' => 'Available groups:', -'userrights-groupshelp' => 'Select groups you want the user to be removed from or added to. -Unselected groups will not be changed. -You can deselect a group with CTRL + Left Click', +'userrights-groupshelp' => '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.', 'userrights-reason' => 'Reason for change:', 'userrights-available-none' => 'You may not alter group membership.', -'userrights-available-add' => 'You can add users to {{PLURAL:$2|this group|these groups}}: $1.', -'userrights-available-remove' => 'You can remove users from {{PLURAL:$2|this group|these groups}}: $1.', +'userrights-available-add' => 'You can add any user to {{PLURAL:$2|this group|these groups}}: $1.', +'userrights-available-remove' => 'You can remove any user from {{PLURAL:$2|this group|these groups}}: $1.', 'userrights-available-add-self' => 'You can add yourself to {{PLURAL:$2|this group|these groups}}: $1.', 'userrights-available-remove-self' => 'You can remove yourself from {{PLURAL:$2|this group|these groups}}: $1.', 'userrights-no-interwiki' => 'You do not have permission to edit user rights on other wikis.', 'userrights-nodatabase' => 'Database $1 does not exist or is not local.', 'userrights-nologin' => 'You must [[Special:Userlogin|log in]] with an administrator account to assign user rights.', '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', # Groups 'group' => 'Group:', diff --git a/skins/common/shared.css b/skins/common/shared.css index fd96b983f3..d8cf94f311 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -97,3 +97,7 @@ p.mw-ipb-conveniencelinks, p.mw-filedelete-editreasons, p.mw-delete-editreasons .mw-search-result-data { color: green; } + +table.mw-userrights-groups * td,table.mw-userrights-groups * th { + padding-right: 1.5em; +} \ No newline at end of file