From: Matt Johnston Date: Thu, 25 Sep 2008 11:45:26 +0000 (+0000) Subject: (bug 8440) Allow preventing blocked users from editing their talk pages X-Git-Tag: 1.31.0-rc.0~45102 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=08e561abb9cd7be8fac479993c997c6ea1c82c87;p=lhc%2Fweb%2Fwiklou.git (bug 8440) Allow preventing blocked users from editing their talk pages * Adds database field to ipblocks table, ipb_allow_usertalk, storing whether or not the user can edit their own talk page. Defaults to 0 to coincide with the default value of $wgBlockAllowsUTEdit. * Recommended to update all current blocks to have a allow_usertalk value of whatever the current setting is * Retasks $wgBlockAllowsUTEdit to be the default value of the field in the blocking screen - unless a sysop changes the checkbox, will use whatever that variable is set to. --- diff --git a/CREDITS b/CREDITS index f2a4741768..e0b7e66f5b 100644 --- a/CREDITS +++ b/CREDITS @@ -20,6 +20,7 @@ following names for their contribution to the product. * Hojjat * Jon Harald Søby * Leon Weber +* Matt Johnston * Meno25 * MinuteElectron * Mohamed Magdy diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6cf3700844..7adbe31ce0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -138,6 +138,7 @@ The following extensions are migrated into MediaWiki 1.14: image. * (bug 12650) It is now possible to set different expiration times for different restriction types on the protection form. +* (bug 8440) Allow preventing blocked users from editing their talk pages === Bug fixes in 1.14 === diff --git a/includes/Block.php b/includes/Block.php index 0fe9365b09..7efdab902e 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -16,7 +16,7 @@ class Block { /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry, $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName, - $mBlockEmail, $mByName, $mAngryAutoblock; + $mBlockEmail, $mByName, $mAngryAutoblock, $mAllowUsertalk; /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster; const EB_KEEP_EXPIRED = 1; @@ -25,7 +25,7 @@ class Block { function __construct( $address = '', $user = 0, $by = 0, $reason = '', $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0, - $hideName = 0, $blockEmail = 0 ) + $hideName = 0, $blockEmail = 0, $allowUsertalk = 0 ) { $this->mId = 0; # Expand valid IPv6 addresses @@ -42,6 +42,7 @@ class Block { $this->mEnableAutoblock = $enableAutoblock; $this->mHideName = $hideName; $this->mBlockEmail = $blockEmail; + $this->mAllowUsertalk = $allowUsertalk; $this->mForUpdate = false; $this->mFromMaster = false; $this->mByName = false; @@ -95,7 +96,7 @@ class Block { $this->mAddress = $this->mReason = $this->mTimestamp = ''; $this->mId = $this->mAnonOnly = $this->mCreateAccount = $this->mEnableAutoblock = $this->mAuto = $this->mUser = - $this->mBy = $this->mHideName = $this->mBlockEmail = 0; + $this->mBy = $this->mHideName = $this->mBlockEmail = $this->mAllowUsertalk = 0; $this->mByName = false; } @@ -303,6 +304,7 @@ class Block { $this->mCreateAccount = $row->ipb_create_account; $this->mEnableAutoblock = $row->ipb_enable_autoblock; $this->mBlockEmail = $row->ipb_block_email; + $this->mAllowUsertalk = $row->ipb_allow_usertalk; $this->mHideName = $row->ipb_deleted; $this->mId = $row->ipb_id; $this->mExpiry = self::decodeExpiry( $row->ipb_expiry ); @@ -437,7 +439,8 @@ class Block { 'ipb_range_start' => $this->mRangeStart, 'ipb_range_end' => $this->mRangeEnd, 'ipb_deleted' => $this->mHideName, - 'ipb_block_email' => $this->mBlockEmail + 'ipb_block_email' => $this->mBlockEmail, + 'ipb_allow_usertalk' => $this->mAllowUsertalk ), 'Block::insert', array( 'IGNORE' ) ); $affected = $dbw->affectedRows(); @@ -473,7 +476,8 @@ class Block { 'ipb_range_start' => $this->mRangeStart, 'ipb_range_end' => $this->mRangeEnd, 'ipb_deleted' => $this->mHideName, - 'ipb_block_email' => $this->mBlockEmail ), + 'ipb_block_email' => $this->mBlockEmail, + 'ipb_allow_usertalk' => $this->mAllowUsertalk ), array( 'ipb_id' => $this->mId ), 'Block::update' ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index a084f7396d..c1582bdbe8 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1069,7 +1069,7 @@ $wgHitcounterUpdateFreq = 1; $wgSysopUserBans = true; # Allow sysops to ban logged-in users $wgSysopRangeBans = true; # Allow sysops to ban IP ranges $wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire -$wgBlockAllowsUTEdit = false; # Blocks allow users to edit their own user talk page +$wgBlockAllowsUTEdit = false; # Default setting for option on block form to allow self talkpage editing whilst blocked $wgSysopEmailBans = true; # Allow sysops to ban users from accessing Emailuser # Pages anonymous user may see as an array, e.g.: diff --git a/includes/User.php b/includes/User.php index d8d6e36db2..6879d473fe 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1034,6 +1034,7 @@ class User { $this->mBlockedby = 0; $this->mHideName = 0; + $this->mAllowUsertalk = 0; $ip = wfGetIP(); if ($this->isAllowed( 'ipblock-exempt' ) ) { @@ -1049,6 +1050,7 @@ class User { $this->mBlockedby = $this->mBlock->mBy; $this->mBlockreason = $this->mBlock->mReason; $this->mHideName = $this->mBlock->mHideName; + $this->mAllowUsertalk = $this->mBlock->mAllowUsertalk; if ( $this->isLoggedIn() ) { $this->spreadBlock(); } @@ -1264,7 +1266,7 @@ class User { wfDebug( __METHOD__.": asking isBlocked()\n" ); $blocked = $this->isBlocked( $bFromSlave ); # If a user's name is suppressed, they cannot make edits anywhere - if ( !$this->mHideName && $wgBlockAllowsUTEdit && $title->getText() === $this->getName() && + if ( !$this->mHideName && $this->mAllowUsertalk && $title->getText() === $this->getName() && $title->getNamespace() == NS_USER_TALK ) { $blocked = false; wfDebug( __METHOD__.": self-talk page, ignoring any blocks\n" ); diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 705c6d39ed..44593f4afd 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -47,7 +47,7 @@ class IPBlockForm { # var $BlockEmail; function IPBlockForm( $par ) { - global $wgRequest, $wgUser; + global $wgRequest, $wgUser, $wgBlockAllowsUTEdit; $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) ); $this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' ); @@ -66,6 +66,11 @@ class IPBlockForm { $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false ); # Re-check user's rights to hide names, very serious, defaults to 0 $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0; + if($wgRequest->wasPosted()){ + $this->BlockAllowUsertalk = $wgRequest->getBool( 'wpAllowUsertalk', false ); + }else{ + $this->BlockAllowUsertalk = $wgBlockAllowsUTEdit; + } } function showForm( $err ) { @@ -238,6 +243,14 @@ class IPBlockForm { 'wpWatchUser', 'wpWatchUser', $this->BlockWatchUser, array( 'tabindex' => '11' ) ) . " + + +   + " . + Xml::checkLabel( wfMsg( 'ipballowusertalk' ), + 'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk, + array( 'tabindex' => '12' ) ) . " + " ); @@ -246,7 +259,7 @@ class IPBlockForm {   " . Xml::submitButton( wfMsg( 'ipbsubmit' ), - array( 'name' => 'wpBlock', 'tabindex' => '12', 'accesskey' => 's' ) ) . " + array( 'name' => 'wpBlock', 'tabindex' => '13', 'accesskey' => 's' ) ) . " " . Xml::closeElement( 'table' ) . @@ -361,7 +374,7 @@ class IPBlockForm { $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(), $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly, $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName, - $this->BlockEmail ); + $this->BlockEmail, $this->BlockAllowUsertalk ); if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) { @@ -452,6 +465,8 @@ class IPBlockForm { $flags[] = 'noautoblock'; if ( $this->BlockEmail ) $flags[] = 'noemail'; + if ( !$this->BlockAllowUsertalk ) + $flags[] = 'nousertalk'; return implode( ',', $flags ); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index aaad704871..4b6b072dff 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2501,6 +2501,7 @@ Fill in a specific reason below (for example, citing particular pages that were 'ipbotherreason' => 'Other/additional reason:', '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 their own talk page while blocked", 'badipaddress' => 'Invalid IP address', 'blockipsuccesssub' => 'Block succeeded', 'blockipsuccesstext' => '[[Special:Contributions/$1|$1]] has been blocked.
@@ -2545,6 +2546,7 @@ See the [[Special:IPBlockList|IP block list]] for the list of currently operatio 'block-log-flags-nocreate' => 'account creation disabled', 'block-log-flags-noautoblock' => 'autoblock disabled', 'block-log-flags-noemail' => 'e-mail blocked', +'block-log-flags-nousertalk' => 'cannot edit own talk page', 'block-log-flags-angry-autoblock' => 'enhanced autoblock enabled', 'range_block_disabled' => 'The sysop ability to create range blocks is disabled.', 'ipb_expiry_invalid' => 'Expiry time invalid.', diff --git a/maintenance/archives/patch-ipb_allow_usertalk.sql b/maintenance/archives/patch-ipb_allow_usertalk.sql new file mode 100644 index 0000000000..b46a2cea52 --- /dev/null +++ b/maintenance/archives/patch-ipb_allow_usertalk.sql @@ -0,0 +1,3 @@ +-- Adding ipb_allow_usertalk for blocks +ALTER TABLE /*$wgDBprefix*/ipblocks + ADD ipb_allow_usertalk bool NOT NULL default 0; diff --git a/maintenance/tables.sql b/maintenance/tables.sql index d3512c5077..d977612aa0 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -678,6 +678,9 @@ CREATE TABLE /*$wgDBprefix*/ipblocks ( -- Block prevents user from accessing Special:Emailuser ipb_block_email bool NOT NULL default 0, + -- Block allows user to edit their own talk page + ipb_allow_usertalk bool NOT NULL default 0, + PRIMARY KEY ipb_id (ipb_id), -- Unique index to support "user already blocked" messages diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index cd12da26a8..e43394179b 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -146,7 +146,8 @@ $wgMysqlUpdates = array( // 1.14 array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ), - array( 'do_active_users_init' ) + array( 'do_active_users_init' ), + array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ) );