From 360fc1ffe364b7ef39fc55f584464ccbcedaa05e Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 3 Jun 2013 08:40:54 +0200 Subject: [PATCH] Don't show the "permissions error" page after a user self-removes rights - 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 | 13 ++++++++++++- languages/messages/MessagesEn.php | 1 + languages/messages/MessagesQqq.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index f23bc2dfbd..8b24372aa8 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -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( "
\n$1\n
", '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 ) ); } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 6e0ecb5706..1125af981e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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:', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 498a4890f0..c6ff569427 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -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}}', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index bc7a7d41c8..f4a53db444 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1146,6 +1146,7 @@ $wgMessageStructure = array( 'userrights-unchangeable-col', 'userrights-irreversible-marker', 'userrights-conflict', + 'userrights-removed-self', ), 'group' => array( 'group', -- 2.20.1