(bug 10080) (bug 15820) - Allow modification of blocks without unblocking, and show...
authorAlex Z <mrzman@users.mediawiki.org>
Thu, 30 Oct 2008 21:45:16 +0000 (21:45 +0000)
committerAlex Z <mrzman@users.mediawiki.org>
Thu, 30 Oct 2008 21:45:16 +0000 (21:45 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/LogPage.php
includes/specials/SpecialBlockip.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 0582a7b..c329308 100644 (file)
@@ -179,6 +179,9 @@ The following extensions are migrated into MediaWiki 1.14:
 * Make search matches bold only, not red as well
 * Added 'UserRights::showEditUserGroupsForm' hook to allow extensions to alter
   the groups that the user can be added to or removed from in Special:UserRights
+* (bug 10080) Blocks can be modified without unblocking first
+* (bug 15820) Special:BlockIP shows a notice if the user being blocked is already
+  directly blocked
 
 === Bug fixes in 1.14 ===
 
index 7e75847..7fa87da 100644 (file)
@@ -2762,6 +2762,7 @@ $wgLogHeaders = array(
 $wgLogActions = array(
        'block/block'       => 'blocklogentry',
        'block/unblock'     => 'unblocklogentry',
+       'block/reblock'     => 'reblock-logentry',
        'protect/protect'   => 'protectedarticle',
        'protect/modify'    => 'modifiedarticleprotection',
        'protect/unprotect' => 'unprotectedarticle',
index 00f2422..228c3fd 100644 (file)
@@ -196,7 +196,7 @@ class LogPage {
                                } else {
                                        $details = '';
                                        array_unshift( $params, $titleLink );
-                                       if ( $key == 'block/block' || $key == 'suppress/block' ) {
+                                       if ( $key == 'block/block' || $key == 'suppress/block' || $key == 'block/reblock' ) {
                                                if ( $skin ) {
                                                        $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' . 
                                                                $wgLang->translateBlockExpiry( $params[1] ) . '</span>';
index e449b6e..e159f0b 100644 (file)
@@ -67,6 +67,7 @@ class IPBlockForm {
                # Re-check user's rights to hide names, very serious, defaults to 0
                $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
                $this->BlockAllowUsertalk = ( $wgRequest->getBool( 'wpAllowUsertalk', $byDefault ) && $wgBlockAllowsUTEdit );
+               $this->BlockReblock = $wgRequest->getBool( 'wpChangeBlock', false );
        }
 
        function showForm( $err ) {
@@ -86,10 +87,19 @@ class IPBlockForm {
                $mIpbreason = Xml::label( wfMsg( 'ipbotherreason' ), 'mw-bi-reason' );
 
                $titleObj = SpecialPage::getTitleFor( 'Blockip' );
-
-               if ( "" != $err ) {
+               
+               $alreadyBlocked = false;
+               if ( $err && $err[0] != 'ipb_already_blocked' ) {
+                       $key = array_shift($err);
+                       $msg = wfMsgReal($key, $err);
                        $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
-                       $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $err ) );
+                       $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $msg ) );
+               } elseif ( $this->BlockAddress ) {
+                       $currentBlock = Block::newFromDB( $this->BlockAddress );
+                       if ( !is_null($currentBlock) && !$currentBlock->mAuto && !($currentBlock->mRangeStart && $currentBlock->mAddress != $this->BlockAddress) ) {
+                               $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress );
+                               $alreadyBlocked = true;
+                       }
                }
 
                $scBlockExpiryOptions = wfMsgForContent( 'ipboptions' );
@@ -253,6 +263,18 @@ class IPBlockForm {
                                </tr>"
                        );
                }
+               if ( $alreadyBlocked ) {
+                       $wgOut->addHTML("
+                               <tr id='wpChangeBlockRow'>
+                                       <td>&nbsp;</td>
+                                       <td class='mw-input'>" .
+                                               Xml::checkLabel( wfMsg( 'ipb-change-block' ),
+                                                       'wpChangeBlock', 'wpChangeBlock', $this->BlockReblock,
+                                                       array( 'tabindex' => '13' ) ) . "
+                                       </td>
+                               </tr>"
+                       );
+               }
 
                $wgOut->addHTML("
                        <tr>
@@ -379,9 +401,18 @@ class IPBlockForm {
                if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
 
                        if ( !$block->insert() ) {
-                               return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
+                               if ( !$this->BlockReblock ) {
+                                       return array( 'ipb_already_blocked' );
+                               } else {
+                                       # This returns direct blocks before autoblocks/rangeblocks, since we should be sure the user is blocked by now it should work for our purposes
+                                       $currentBlock = Block::newFromDB( $this->BlockAddress );
+                                       $currentBlock->delete();
+                                       $block->insert();
+                                       $log_action = 'reblock';
+                               }
+                       } else {
+                               $log_action = 'block';
                        }
-
                        wfRunHooks('BlockIpComplete', array($block, $wgUser));
 
                        if ( $this->BlockWatchUser ) { 
@@ -396,7 +427,7 @@ class IPBlockForm {
                        # Make log entry, if the name is hidden, put it in the oversight log
                        $log_type = ($this->BlockHideName) ? 'suppress' : 'block';
                        $log = new LogPage( $log_type );
-                       $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ),
+                       $log->addEntry( $log_action, Title::makeTitle( NS_USER, $this->BlockAddress ),
                          $reasonstr, $logParams );
 
                        # Report to the user
@@ -420,8 +451,7 @@ class IPBlockForm {
                                urlencode( $this->BlockAddress ) ) );
                        return;
                }
-               $key = array_shift($retval);
-               $this->showForm(wfMsgReal($key, $retval));
+               $this->showForm( $retval );
        }
 
        function showSuccess() {
index ffbab16..ebb9351 100644 (file)
@@ -2552,6 +2552,7 @@ Fill in a specific reason below (for example, citing particular pages that were
 'ipbhidename'                     => 'Hide username from the block log, active block list and user list',
 'ipbwatchuser'                    => "Watch this user's user and talk pages",
 'ipballowusertalk'                => 'Allow this user to edit own talk page while blocked',
+'ipb-change-block'                => 'Re-block the user with these settings',
 'badipaddress'                    => 'Invalid IP address',
 'blockipsuccesssub'               => 'Block succeeded',
 'blockipsuccesstext'              => '[[Special:Contributions/$1|$1]] has been blocked.<br />
@@ -2593,6 +2594,7 @@ The reason given for $1\'s block is: "$2"',
 'blocklogpage'                    => 'Block log',
 'blocklog-fulllog'                => 'Full block log',
 'blocklogentry'                   => 'blocked [[$1]] with an expiry time of $2 $3',
+'reblock-logentry'                => 'changed block settings for [[$1]] with an expiry time of $2 $3',
 'blocklogtext'                    => 'This is a log of user blocking and unblocking actions.
 Automatically blocked IP addresses are not listed.
 See the [[Special:IPBlockList|IP block list]] for the list of currently operational bans and blocks.',
@@ -2607,6 +2609,8 @@ See the [[Special:IPBlockList|IP block list]] for the list of currently operatio
 'ipb_expiry_invalid'              => 'Expiry time invalid.',
 'ipb_expiry_temp'                 => 'Hidden username blocks must be permanent.',
 'ipb_already_blocked'             => '"$1" is already blocked',
+'ipb-needreblock'                 => '== Already blocked ==
+$1 is already blocked. Do you want to change the settings?',
 'ipb_cant_unblock'                => 'Error: Block ID $1 not found.
 It may have been unblocked already.',
 'ipb_blocked_as_range'            => 'Error: The IP $1 is not blocked directly and cannot be unblocked.
index 40aed99..00012e1 100644 (file)
@@ -1745,6 +1745,7 @@ $wgMessageStructure = array(
                'ipbhidename',
                'ipbwatchuser',
                'ipballowusertalk',
+               'ipb-change-block',
                'badipaddress',
                'blockipsuccesssub',
                'blockipsuccesstext',
@@ -1784,6 +1785,7 @@ $wgMessageStructure = array(
                'blocklogpage',
                'blocklog-fulllog',
                'blocklogentry',
+               'reblock-logentry',
                'blocklogtext',
                'unblocklogentry',
                'block-log-flags-anononly',
@@ -1796,6 +1798,7 @@ $wgMessageStructure = array(
                'ipb_expiry_invalid',
                'ipb_expiry_temp',
                'ipb_already_blocked',
+               'ipb-needreblock',
                'ipb_cant_unblock',
                'ipb_blocked_as_range',
                'ip_range_invalid',