Added block option "enable autoblocks". Patch by Werdna from bug 1294.
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 1 Nov 2006 07:13:31 +0000 (07:13 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 1 Nov 2006 07:13:31 +0000 (07:13 +0000)
RELEASE-NOTES
includes/Block.php
includes/SpecialBlockip.php
includes/User.php
languages/messages/MessagesEn.php
maintenance/mysql5/tables.sql
maintenance/tables.sql
maintenance/updaters.inc

index d79faf9..cbce2f8 100644 (file)
@@ -117,6 +117,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Moved variant language links on Cologne Blue and Nostalgia to before the
   login/logout link
 * Fix for parser tests with MySQL 5 in strict mode
+* Added block option "enable autoblocks"
 
 
 == Languages updated ==
index b11df22..679ff1e 100644 (file)
@@ -17,7 +17,7 @@
 class Block
 {
        /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
-                           $mRangeStart, $mRangeEnd, $mAnonOnly;
+                           $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock;
        /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName;
        
        const EB_KEEP_EXPIRED = 1;
@@ -25,7 +25,7 @@ class Block
        const EB_RANGE_ONLY = 4;
 
        function Block( $address = '', $user = 0, $by = 0, $reason = '',
-               $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0 )
+               $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0 )
        {
                $this->mId = 0;
                $this->mAddress = $address;
@@ -37,6 +37,7 @@ class Block
                $this->mAnonOnly = $anonOnly;
                $this->mCreateAccount = $createAccount;
                $this->mExpiry = self::decodeExpiry( $expiry );
+               $this->mEnableAutoblock = $enableAutoblock;
 
                $this->mForUpdate = false;
                $this->mFromMaster = false;
@@ -72,7 +73,8 @@ class Block
        {
                $this->mAddress = $this->mReason = $this->mTimestamp = '';
                $this->mId = $this->mAnonOnly = $this->mCreateAccount = 
-                       $this->mAuto = $this->mUser = $this->mBy = 0;
+                       $this->mEnableAutoblock = $this->mAuto = $this->mUser = 
+                       $this->mBy = 0;
                $this->mByName = false;
        }
 
@@ -259,6 +261,7 @@ class Block
                $this->mAuto = $row->ipb_auto;
                $this->mAnonOnly = $row->ipb_anon_only;
                $this->mCreateAccount = $row->ipb_create_account;
+               $this->mEnableAutoblock = $row->ipb_enable_autoblock;
                $this->mId = $row->ipb_id;
                $this->mExpiry = self::decodeExpiry( $row->ipb_expiry );
                if ( isset( $row->user_name ) ) {
@@ -379,6 +382,7 @@ class Block
                                'ipb_auto' => $this->mAuto,
                                'ipb_anon_only' => $this->mAnonOnly,
                                'ipb_create_account' => $this->mCreateAccount,
+                               'ipb_enable_autoblock' => $this->mEnableAutoblock,
                                'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ),
                                'ipb_range_start' => $this->mRangeStart,
                                'ipb_range_end' => $this->mRangeEnd,
index 567fd82..7568b2e 100644 (file)
@@ -55,6 +55,13 @@ class IPBlockForm {
                } else {
                        $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', true );
                }
+
+               if ( $wgRequest->wasPosted() ) {
+                       $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', false );
+               } else {
+                       $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', true );
+               }
+
        }
 
        function showForm( $err ) {
@@ -155,10 +162,18 @@ class IPBlockForm {
                                        array( 'tabindex' => 5 ) ) . "
                        </td>
                </tr>
+                <tr>
+                        <td>&nbsp;</td>
+                        <td align=\"left\">
+                                " . wfCheckLabel( wfMsg( 'ipbenableautoblock' ),
+                                        'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock,
+                                        array( 'tabindex' => 6 ) ) . "
+                        </td>
+                </tr>
                <tr>
                        <td style='padding-top: 1em'>&nbsp;</td>
                        <td style='padding-top: 1em' align=\"left\">
-                               <input tabindex='5' type='submit' name=\"wpBlock\" value=\"{$mIpbsubmit}\" />
+                               <input tabindex='7' type='submit' name=\"wpBlock\" value=\"{$mIpbsubmit}\" />
                        </td>
                </tr>
        </table>
@@ -242,7 +257,7 @@ class IPBlockForm {
 
                $block = new Block( $this->BlockAddress, $userId, $wgUser->getID(),
                        $this->BlockReason, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly, 
-                       $this->BlockCreateAccount );
+                       $this->BlockCreateAccount, $this->BlockEnableAutoblock );
 
                if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
 
index 6bda68e..06d5107 100644 (file)
@@ -1924,6 +1924,10 @@ class User {
                        return;
                }
 
+               if ( !$userblock->mEnableAutoblock ) {
+                       return;
+               }
+
                # Check if this IP address is already blocked
                $ipblock = Block::newFromDB( wfGetIP() );
                if ( $ipblock ) {
index 9ecdf28..1fd069a 100644 (file)
@@ -1754,6 +1754,7 @@ pages that were vandalized).",
 'ipbreason'            => 'Reason',
 'ipbanononly'   => 'Block anonymous users only',
 'ipbcreateaccount' => 'Prevent account creation',
+'ipbenableautoblock' => 'Automatically block IP addresses used by this user',
 'ipbsubmit'            => 'Block this user',
 'ipbother'             => 'Other time',
 'ipboptions'           => '2 hours:2 hours,1 day:1 day,3 days:3 days,1 week:1 week,2 weeks:2 weeks,1 month:1 month,3 months:3 months,6 months:6 months,1 year:1 year,infinite:infinite',
index c28c80b..9d9c76a 100644 (file)
@@ -594,6 +594,9 @@ CREATE TABLE /*$wgDBprefix*/ipblocks (
 
   -- Block prevents account creation from matching IP addresses
   ipb_create_account bool NOT NULL default 1,
+
+  -- Block triggers autoblocks
+  ipb_enable_autoblock bool NOT NULL default '1',
     
   -- Time at which the block will expire.
   ipb_expiry char(14) binary NOT NULL default '',
index 20e45d9..9f9cb69 100644 (file)
@@ -582,6 +582,9 @@ CREATE TABLE /*$wgDBprefix*/ipblocks (
 
   -- Block prevents account creation from matching IP addresses
   ipb_create_account bool NOT NULL default 1,
+
+  -- Block triggers autoblocks
+  ipb_enable_autoblock bool NOT NULL default '1',
   
   -- Time at which the block will expire.
   ipb_expiry char(14) binary NOT NULL default '',
index 94e5c36..dbddc47 100644 (file)
@@ -38,6 +38,7 @@ $wgNewFields = array(
 #           table            field             patch file (in maintenance/archives)
        array( 'ipblocks',      'ipb_id',           'patch-ipblocks.sql' ),
        array( 'ipblocks',      'ipb_expiry',       'patch-ipb_expiry.sql' ),
+       array( 'ipblocks',      'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ),
        array( 'recentchanges', 'rc_type',          'patch-rc_type.sql' ),
        array( 'recentchanges', 'rc_ip',            'patch-rc_ip.sql' ),
        array( 'recentchanges', 'rc_id',            'patch-rc_id.sql' ),
@@ -894,6 +895,7 @@ ALTER TABLE recentchanges ALTER rc_cur_id DROP NOT NULL;
 -- New columns:
 ALTER TABLE ipblocks ADD ipb_anon_only CHAR NOT NULL DEFAULT '0';
 ALTER TABLE ipblocks ADD ipb_create_account CHAR NOT NULL DEFAULT '1';
+ALTER TABLE ipblocks ADD ipb_enable_autoblock CHAR NOT NULL default '1';
 
 -- Index order rearrangements:
 DROP INDEX pagelink_unique;