summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialUserrights.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialUserrights.php')
-rw-r--r--includes/specials/SpecialUserrights.php65
1 files changed, 41 insertions, 24 deletions
diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php
index cefdad07..758e3c05 100644
--- a/includes/specials/SpecialUserrights.php
+++ b/includes/specials/SpecialUserrights.php
@@ -106,7 +106,7 @@ class UserrightsPage extends SpecialPage {
}
}
- if ( User::getCanonicalName( $this->mTarget ) == $user->getName() ) {
+ if ( User::getCanonicalName( $this->mTarget ) === $user->getName() ) {
$this->isself = true;
}
@@ -135,6 +135,7 @@ class UserrightsPage extends SpecialPage {
$out = $this->getOutput();
$out->addModuleStyles( 'mediawiki.special' );
+ $this->addHelpLink( 'Help:Assigning permissions' );
// show the general form
if ( count( $available['add'] ) || count( $available['remove'] ) ) {
@@ -218,7 +219,7 @@ class UserrightsPage extends SpecialPage {
/**
* Save user groups changes in the database.
*
- * @param User $user
+ * @param User|UserRightsProxy $user
* @param array $add Array of groups to add
* @param array $remove Array of groups to remove
* @param string $reason Reason for group change
@@ -228,7 +229,7 @@ class UserrightsPage extends SpecialPage {
global $wgAuth;
// Validate input set...
- $isself = ( $user->getName() == $this->getUser()->getName() );
+ $isself = $user->getName() == $this->getUser()->getName();
$groups = $user->getGroups();
$changeable = $this->changeableGroups();
$addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : array() );
@@ -244,18 +245,22 @@ class UserrightsPage extends SpecialPage {
$oldGroups = $user->getGroups();
$newGroups = $oldGroups;
- // remove then add groups
+ // Remove then add groups
if ( $remove ) {
- $newGroups = array_diff( $newGroups, $remove );
- foreach ( $remove as $group ) {
- $user->removeGroup( $group );
+ foreach ( $remove as $index => $group ) {
+ if ( !$user->removeGroup( $group ) ) {
+ unset($remove[$index]);
+ }
}
+ $newGroups = array_diff( $newGroups, $remove );
}
if ( $add ) {
- $newGroups = array_merge( $newGroups, $add );
- foreach ( $add as $group ) {
- $user->addGroup( $group );
+ foreach ( $add as $index => $group ) {
+ if ( !$user->addGroup( $group ) ) {
+ unset($add[$index]);
+ }
}
+ $newGroups = array_merge( $newGroups, $add );
}
$newGroups = array_unique( $newGroups );
@@ -267,7 +272,7 @@ class UserrightsPage extends SpecialPage {
wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
- wfRunHooks( 'UserRights', array( &$user, $add, $remove ) );
+ Hooks::run( 'UserRights', array( &$user, $add, $remove ) );
if ( $newGroups != $oldGroups ) {
$this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
@@ -415,6 +420,8 @@ class UserrightsPage extends SpecialPage {
* Output a form to allow searching for a user
*/
function switchForm() {
+ $this->getOutput()->addModules( 'mediawiki.userSuggest' );
+
$this->getOutput()->addHTML(
Html::openElement(
'form',
@@ -433,7 +440,10 @@ class UserrightsPage extends SpecialPage {
'username',
30,
str_replace( '_', ' ', $this->mTarget ),
- array( 'autofocus' => true )
+ array(
+ 'autofocus' => '',
+ 'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
+ )
) . ' ' .
Xml::submitButton( $this->msg( 'editusergroup' )->text() ) .
Html::closeElement( 'fieldset' ) .
@@ -488,25 +498,32 @@ class UserrightsPage extends SpecialPage {
}
$language = $this->getLanguage();
- $displayedList = $this->msg( 'userrights-groupsmember-type',
- $language->listToText( $list ),
- $language->listToText( $membersList )
- )->plain();
- $displayedAutolist = $this->msg( 'userrights-groupsmember-type',
- $language->listToText( $autoList ),
- $language->listToText( $autoMembersList )
- )->plain();
+ $displayedList = $this->msg( 'userrights-groupsmember-type' )
+ ->rawParams(
+ $language->listToText( $list ),
+ $language->listToText( $membersList )
+ )->escaped();
+ $displayedAutolist = $this->msg( 'userrights-groupsmember-type' )
+ ->rawParams(
+ $language->listToText( $autoList ),
+ $language->listToText( $autoMembersList )
+ )->escaped();
$grouplist = '';
$count = count( $list );
if ( $count > 0 ) {
- $grouplist = $this->msg( 'userrights-groupsmember', $count, $user->getName() )->parse();
+ $grouplist = $this->msg( 'userrights-groupsmember' )
+ ->numParams( $count )
+ ->params( $user->getName() )
+ ->parse();
$grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
}
$count = count( $autoList );
if ( $count > 0 ) {
- $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto', $count, $user->getName() )
+ $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto' )
+ ->numParams( $count )
+ ->params( $user->getName() )
->parse();
$grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
}
@@ -664,9 +681,9 @@ class UserrightsPage extends SpecialPage {
$member = User::getGroupMember( $group, $user->getName() );
if ( $checkbox['irreversible'] ) {
- $text = $this->msg( 'userrights-irreversible-marker', $member )->escaped();
+ $text = $this->msg( 'userrights-irreversible-marker', $member )->text();
} else {
- $text = htmlspecialchars( $member );
+ $text = $member;
}
$checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
"wpGroup-" . $group, $checkbox['set'], $attr );