Don't taunt permissionless users with a username search box on Special:Userrights.
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 26 Dec 2007 23:28:20 +0000 (23:28 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 26 Dec 2007 23:28:20 +0000 (23:28 +0000)
Give them a nice little permissions error and a login link for anons.

includes/SpecialUserrights.php
languages/messages/MessagesEn.php

index 2b35f1b..d10ece3 100644 (file)
@@ -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 ) {
index 2ead33f..50fe3de 100644 (file)
@@ -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:',