From 30ed8acfd9c079b3e87bbd9f3224893417693b70 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 26 Dec 2007 23:28:20 +0000 Subject: [PATCH] Don't taunt permissionless users with a username search box on Special:Userrights. Give them a nice little permissions error and a login link for anons. --- includes/SpecialUserrights.php | 13 +++++++++++++ languages/messages/MessagesEn.php | 2 ++ 2 files changed, 15 insertions(+) diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php index 2b35f1b169..d10ece3c86 100644 --- a/includes/SpecialUserrights.php +++ b/includes/SpecialUserrights.php @@ -42,6 +42,19 @@ class UserrightsForm extends HTMLForm { * Depending on the submit button used, call a form or a save function. */ function execute() { + // If the visitor doesn't have permissions to assign or remove + // any groups, it's a bit silly to give them the user search prompt. + $available = $this->changeableGroups(); + if( empty( $available['add'] ) && empty( $available['remove'] ) ) { + // fixme... there may be intermediate groups we can mention. + global $wgOut, $wgUser; + $wgOut->showPermissionsErrorPage( array( + $wgUser->isAnon() + ? 'userrights-nologin' + : 'userrights-notallowed' ) ); + return; + } + // show the general form $this->switchForm(); if( $this->mPosted ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 2ead33f90a..50fe3de1d6 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1340,6 +1340,8 @@ Unselected groups will not be changed. You can deselect a group with CTRL + Left 'userrights-available-remove' => 'You can remove users from $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.', # Groups 'group' => 'Group:', -- 2.20.1