(bug 23408) give admins a warning before letting them block themselves. Also tweak...
authorHappy-melon <happy-melon@users.mediawiki.org>
Wed, 30 Mar 2011 18:00:11 +0000 (18:00 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Wed, 30 Mar 2011 18:00:11 +0000 (18:00 +0000)
includes/specials/SpecialBlock.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 92658e0..48ec00c 100644 (file)
@@ -221,7 +221,7 @@ class SpecialBlock extends SpecialPage {
                                $fields['DisableUTEdit']['default'] = $block->prevents( 'editownusertalk' );
                        }
                        $fields['Reason']['default'] = $block->mReason;
-                       $fields['AlreadyBlocked']['default'] = true;
+                       $fields['AlreadyBlocked']['default'] = htmlspecialchars( $block->getTarget() );
 
                        if( $block->mExpiry == 'infinity' ) {
                                $fields['Expiry']['default'] = 'indefinite';
@@ -486,11 +486,23 @@ class SpecialBlock extends SpecialPage {
                        $user = $target;
                        $target = $user->getName();
                        $userId = $user->getId();
+
+                       # Give admins a heads-up before they go and block themselves.  Much messier
+                       # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
+                       # permission anyway, although the code does allow for it
+                       if( $target == $wgUser->getName()
+                               && $data['AlreadyBlocked'] != htmlspecialchars( $wgUser->getName() )  )
+                       {
+                               return array( 'ipb-blockingself' );
+                       }
+
                } elseif( $type == Block::TYPE_RANGE ){
                        $userId = 0;
+
                } elseif( $type == Block::TYPE_IP ){
                        $target = $target->getName();
                        $userId = 0;
+
                } else {
                        # This should have been caught in the form field validation
                        return array( 'badipaddress' );
@@ -556,7 +568,7 @@ class SpecialBlock extends SpecialPage {
                $status = $block->insert();
                if( !$status ) {
                        # Show form unless the user is already aware of this...
-                       if( !$data['AlreadyBlocked'] ) {
+                       if( $data['AlreadyBlocked'] != htmlspecialchars( $block->getTarget() ) ) {
                                return array( array( 'ipb_already_blocked', $block->getTarget() ) );
                        # Otherwise, try to update the block...
                        } else {
index b671331..46164d6 100644 (file)
@@ -3060,6 +3060,7 @@ Fill in a specific reason below (for example, citing particular pages that were
 'blockipsuccesssub'               => 'Block succeeded',
 'blockipsuccesstext'              => '[[Special:Contributions/$1|$1]] has been blocked.<br />
 See [[Special:IPBlockList|IP block list]] to review blocks.',
+'ipb-blockingself'                => 'You are about to block yourself!  Are you sure you want to do that?',
 'ipb-edit-dropdown'               => 'Edit block reasons',
 'ipb-unblock-addr'                => 'Unblock $1',
 'ipb-unblock'                     => 'Unblock a username or IP address',
index 6b025ee..e942c45 100644 (file)
@@ -2073,6 +2073,7 @@ $wgMessageStructure = array(
                'badipaddress',
                'blockipsuccesssub',
                'blockipsuccesstext',
+               'ipb-blockingself',
                'ipb-edit-dropdown',
                'ipb-unblock-addr',
                'ipb-unblock',