From: Tim Starling Date: Wed, 1 Nov 2006 07:13:31 +0000 (+0000) Subject: Added block option "enable autoblocks". Patch by Werdna from bug 1294. X-Git-Tag: 1.31.0-rc.0~55332 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=329b012d2b4de65f81d39335c66653983c444f14;p=lhc%2Fweb%2Fwiklou.git Added block option "enable autoblocks". Patch by Werdna from bug 1294. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d79faf9aba..cbce2f8447 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/Block.php b/includes/Block.php index b11df22c9f..679ff1efe0 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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, diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 567fd82425..7568b2eaca 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -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 ) ) . " + +   + + " . wfCheckLabel( wfMsg( 'ipbenableautoblock' ), + 'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock, + array( 'tabindex' => 6 ) ) . " + +   - + @@ -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))) { diff --git a/includes/User.php b/includes/User.php index 6bda68e0dc..06d5107ad6 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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 ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 9ecdf287ae..1fd069a951 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', diff --git a/maintenance/mysql5/tables.sql b/maintenance/mysql5/tables.sql index c28c80ba49..9d9c76a7ed 100644 --- a/maintenance/mysql5/tables.sql +++ b/maintenance/mysql5/tables.sql @@ -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 '', diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 20e45d9c70..9f9cb698ed 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -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 '', diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 94e5c3664b..dbddc47019 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -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;