Don't show the "permissions error" page after a user self-removes rights
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Mon, 3 Jun 2013 06:40:54 +0000 (08:40 +0200)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 10 Jun 2013 21:24:43 +0000 (21:24 +0000)
- Instead show a message saying that it will no longer be able to access this page
- Added a "success=1" parameter to URL the user is redirected to after making changes
  on that page to catch those cases

bug: 48609
Change-Id: I4f42713ccec647b1d6ff11c2714d645973750579

includes/specials/SpecialUserrights.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index f23bc2d..8b24372 100644 (file)
@@ -110,6 +110,17 @@ class UserrightsPage extends SpecialPage {
                }
 
                if ( !$this->userCanChangeRights( $user, true ) ) {
+                       if ( $this->isself && $request->getCheck( 'success' ) ) {
+                               // bug 48609: if the user just removed its own rights, this would
+                               // leads it in a "permissions error" page. In that case, show a
+                               // message that it can't anymore use this page instead of an error
+                               $this->setHeaders();
+                               $out = $this->getOutput();
+                               $out->wrapWikiMsg( "<div class=\"successbox\">\n$1\n</div>", 'userrights-removed-self' );
+                               $out->returnToMain();
+                               return;
+                       }
+
                        // @todo FIXME: There may be intermediate groups we can mention.
                        $msg = $user->isAnon() ? 'userrights-nologin' : 'userrights-notallowed';
                        throw new PermissionsError( null, array( array( $msg ) ) );
@@ -163,7 +174,7 @@ class UserrightsPage extends SpecialPage {
        }
 
        function getSuccessURL() {
-               return $this->getTitle( $this->mTarget )->getFullURL();
+               return $this->getTitle( $this->mTarget )->getFullURL( array( 'success' => 1 ) );
        }
 
        /**
index 6e0ecb5..1125af9 100644 (file)
@@ -2020,6 +2020,7 @@ Your email address is not revealed when other users contact you.',
 'userrights-unchangeable-col'    => 'Groups you cannot change',
 'userrights-irreversible-marker' => '$1*', # only translate this message to other languages if you have to change it
 'userrights-conflict'            => 'User rights conflict! Please apply your changes again.',
+'userrights-removed-self'        => 'You successfully removed your own rights. As such, you are no longer able to access this page.',
 
 # Groups
 'group'               => 'Group:',
index 498a489..c6ff569 100644 (file)
@@ -2745,6 +2745,7 @@ Parameters:
 * $1 - optional, for PLURAL use, the number of items in the column following the message. Avoid PLURAL, if your language allows that.',
 'userrights-irreversible-marker' => '{{optional}}',
 'userrights-conflict' => "Shown on [[Special:UserRights]] if the target's rights have been changed since the form was loaded.",
+'userrights-removed-self' => "Shown on [[Special:UserRights]] in a green box after the user removed its own rights to access that page.",
 
 # Groups
 'group' => '{{Identical|Group}}',
index bc7a7d4..f4a53db 100644 (file)
@@ -1146,6 +1146,7 @@ $wgMessageStructure = array(
                'userrights-unchangeable-col',
                'userrights-irreversible-marker',
                'userrights-conflict',
+               'userrights-removed-self',
        ),
        'group' => array(
                'group',