(bug 8440) Allow preventing blocked users from editing their talk pages
authorMatt Johnston <mattj@users.mediawiki.org>
Thu, 25 Sep 2008 11:45:26 +0000 (11:45 +0000)
committerMatt Johnston <mattj@users.mediawiki.org>
Thu, 25 Sep 2008 11:45:26 +0000 (11:45 +0000)
* 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.

CREDITS
RELEASE-NOTES
includes/Block.php
includes/DefaultSettings.php
includes/User.php
includes/specials/SpecialBlockip.php
languages/messages/MessagesEn.php
maintenance/archives/patch-ipb_allow_usertalk.sql [new file with mode: 0644]
maintenance/tables.sql
maintenance/updaters.inc

diff --git a/CREDITS b/CREDITS
index f2a4741..e0b7e66 100644 (file)
--- 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
index 6cf3700..7adbe31 100644 (file)
@@ -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 ===
 
index 0fe9365..7efdab9 100644 (file)
@@ -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' );
 
index a084f73..c1582bd 100644 (file)
@@ -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.:
index d8d6e36..6879d47 100644 (file)
@@ -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" );
index 705c6d3..44593f4 100644 (file)
@@ -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' ) ) . "
                                </td>
+                       </tr>
+                       <tr id='wpAllowUsertalkRow'>
+                               <td>&nbsp;</td>
+                               <td class='mw-input'>" .
+                                       Xml::checkLabel( wfMsg( 'ipballowusertalk' ),
+                                               'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk,
+                                               array( 'tabindex' => '12' ) ) . "
+                               </td>
                        </tr>"
                );
 
@@ -246,7 +259,7 @@ class IPBlockForm {
                                <td style='padding-top: 1em'>&nbsp;</td>
                                <td  class='mw-submit' style='padding-top: 1em'>" .
                                        Xml::submitButton( wfMsg( 'ipbsubmit' ),
-                                               array( 'name' => 'wpBlock', 'tabindex' => '12', 'accesskey' => 's' ) ) . "
+                                               array( 'name' => 'wpBlock', 'tabindex' => '13', 'accesskey' => 's' ) ) . "
                                </td>
                        </tr>" .
                        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 );
        }
 
index aaad704..4b6b072 100644 (file)
@@ -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.<br />
@@ -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 (file)
index 0000000..b46a2ce
--- /dev/null
@@ -0,0 +1,3 @@
+-- Adding ipb_allow_usertalk for blocks\r
+ALTER TABLE /*$wgDBprefix*/ipblocks\r
+  ADD ipb_allow_usertalk bool NOT NULL default 0;\r
index d3512c5..d977612 100644 (file)
@@ -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
index cd12da2..e433941 100644 (file)
@@ -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' )
 );