r41248 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41247‎ | r41248 | r41249 >
Date:11:45, 25 September 2008
Author:mattj
Status:old
Tags:
Comment:
(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.
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-ipb_allow_usertalk.sql (added) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-ipb_allow_usertalk.sql
@@ -0,0 +1,3 @@
 2+-- Adding ipb_allow_usertalk for blocks
 3+ALTER TABLE /*$wgDBprefix*/ipblocks
 4+ ADD ipb_allow_usertalk bool NOT NULL default 0;
Index: trunk/phase3/maintenance/updaters.inc
@@ -146,7 +146,8 @@
147147
148148 // 1.14
149149 array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
150 - array( 'do_active_users_init' )
 150+ array( 'do_active_users_init' ),
 151+ array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' )
151152 );
152153
153154
Index: trunk/phase3/maintenance/tables.sql
@@ -678,6 +678,9 @@
679679 -- Block prevents user from accessing Special:Emailuser
680680 ipb_block_email bool NOT NULL default 0,
681681
 682+ -- Block allows user to edit their own talk page
 683+ ipb_allow_usertalk bool NOT NULL default 0,
 684+
682685 PRIMARY KEY ipb_id (ipb_id),
683686
684687 -- Unique index to support "user already blocked" messages
Index: trunk/phase3/CREDITS
@@ -20,6 +20,7 @@
2121 * Hojjat
2222 * Jon Harald Søby
2323 * Leon Weber
 24+* Matt Johnston
2425 * Meno25
2526 * MinuteElectron
2627 * Mohamed Magdy
Index: trunk/phase3/includes/User.php
@@ -1034,6 +1034,7 @@
10351035
10361036 $this->mBlockedby = 0;
10371037 $this->mHideName = 0;
 1038+ $this->mAllowUsertalk = 0;
10381039 $ip = wfGetIP();
10391040
10401041 if ($this->isAllowed( 'ipblock-exempt' ) ) {
@@ -1049,6 +1050,7 @@
10501051 $this->mBlockedby = $this->mBlock->mBy;
10511052 $this->mBlockreason = $this->mBlock->mReason;
10521053 $this->mHideName = $this->mBlock->mHideName;
 1054+ $this->mAllowUsertalk = $this->mBlock->mAllowUsertalk;
10531055 if ( $this->isLoggedIn() ) {
10541056 $this->spreadBlock();
10551057 }
@@ -1264,7 +1266,7 @@
12651267 wfDebug( __METHOD__.": asking isBlocked()\n" );
12661268 $blocked = $this->isBlocked( $bFromSlave );
12671269 # If a user's name is suppressed, they cannot make edits anywhere
1268 - if ( !$this->mHideName && $wgBlockAllowsUTEdit && $title->getText() === $this->getName() &&
 1270+ if ( !$this->mHideName && $this->mAllowUsertalk && $title->getText() === $this->getName() &&
12691271 $title->getNamespace() == NS_USER_TALK ) {
12701272 $blocked = false;
12711273 wfDebug( __METHOD__.": self-talk page, ignoring any blocks\n" );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1069,7 +1069,7 @@
10701070 $wgSysopUserBans = true; # Allow sysops to ban logged-in users
10711071 $wgSysopRangeBans = true; # Allow sysops to ban IP ranges
10721072 $wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire
1073 -$wgBlockAllowsUTEdit = false; # Blocks allow users to edit their own user talk page
 1073+$wgBlockAllowsUTEdit = false; # Default setting for option on block form to allow self talkpage editing whilst blocked
10741074 $wgSysopEmailBans = true; # Allow sysops to ban users from accessing Emailuser
10751075
10761076 # Pages anonymous user may see as an array, e.g.:
Index: trunk/phase3/includes/specials/SpecialBlockip.php
@@ -47,7 +47,7 @@
4848 # var $BlockEmail;
4949
5050 function IPBlockForm( $par ) {
51 - global $wgRequest, $wgUser;
 51+ global $wgRequest, $wgUser, $wgBlockAllowsUTEdit;
5252
5353 $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) );
5454 $this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' );
@@ -66,6 +66,11 @@
6767 $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
6868 # Re-check user's rights to hide names, very serious, defaults to 0
6969 $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
 70+ if($wgRequest->wasPosted()){
 71+ $this->BlockAllowUsertalk = $wgRequest->getBool( 'wpAllowUsertalk', false );
 72+ }else{
 73+ $this->BlockAllowUsertalk = $wgBlockAllowsUTEdit;
 74+ }
7075 }
7176
7277 function showForm( $err ) {
@@ -238,6 +243,14 @@
239244 'wpWatchUser', 'wpWatchUser', $this->BlockWatchUser,
240245 array( 'tabindex' => '11' ) ) . "
241246 </td>
 247+ </tr>
 248+ <tr id='wpAllowUsertalkRow'>
 249+ <td>&nbsp;</td>
 250+ <td class='mw-input'>" .
 251+ Xml::checkLabel( wfMsg( 'ipballowusertalk' ),
 252+ 'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk,
 253+ array( 'tabindex' => '12' ) ) . "
 254+ </td>
242255 </tr>"
243256 );
244257
@@ -246,7 +259,7 @@
247260 <td style='padding-top: 1em'>&nbsp;</td>
248261 <td class='mw-submit' style='padding-top: 1em'>" .
249262 Xml::submitButton( wfMsg( 'ipbsubmit' ),
250 - array( 'name' => 'wpBlock', 'tabindex' => '12', 'accesskey' => 's' ) ) . "
 263+ array( 'name' => 'wpBlock', 'tabindex' => '13', 'accesskey' => 's' ) ) . "
251264 </td>
252265 </tr>" .
253266 Xml::closeElement( 'table' ) .
@@ -361,7 +374,7 @@
362375 $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(),
363376 $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
364377 $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
365 - $this->BlockEmail );
 378+ $this->BlockEmail, $this->BlockAllowUsertalk );
366379
367380 if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
368381
@@ -452,6 +465,8 @@
453466 $flags[] = 'noautoblock';
454467 if ( $this->BlockEmail )
455468 $flags[] = 'noemail';
 469+ if ( !$this->BlockAllowUsertalk )
 470+ $flags[] = 'nousertalk';
456471 return implode( ',', $flags );
457472 }
458473
Index: trunk/phase3/includes/Block.php
@@ -16,7 +16,7 @@
1717 class Block {
1818 /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
1919 $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName,
20 - $mBlockEmail, $mByName, $mAngryAutoblock;
 20+ $mBlockEmail, $mByName, $mAngryAutoblock, $mAllowUsertalk;
2121 /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster;
2222
2323 const EB_KEEP_EXPIRED = 1;
@@ -25,7 +25,7 @@
2626
2727 function __construct( $address = '', $user = 0, $by = 0, $reason = '',
2828 $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0,
29 - $hideName = 0, $blockEmail = 0 )
 29+ $hideName = 0, $blockEmail = 0, $allowUsertalk = 0 )
3030 {
3131 $this->mId = 0;
3232 # Expand valid IPv6 addresses
@@ -42,6 +42,7 @@
4343 $this->mEnableAutoblock = $enableAutoblock;
4444 $this->mHideName = $hideName;
4545 $this->mBlockEmail = $blockEmail;
 46+ $this->mAllowUsertalk = $allowUsertalk;
4647 $this->mForUpdate = false;
4748 $this->mFromMaster = false;
4849 $this->mByName = false;
@@ -95,7 +96,7 @@
9697 $this->mAddress = $this->mReason = $this->mTimestamp = '';
9798 $this->mId = $this->mAnonOnly = $this->mCreateAccount =
9899 $this->mEnableAutoblock = $this->mAuto = $this->mUser =
99 - $this->mBy = $this->mHideName = $this->mBlockEmail = 0;
 100+ $this->mBy = $this->mHideName = $this->mBlockEmail = $this->mAllowUsertalk = 0;
100101 $this->mByName = false;
101102 }
102103
@@ -303,6 +304,7 @@
304305 $this->mCreateAccount = $row->ipb_create_account;
305306 $this->mEnableAutoblock = $row->ipb_enable_autoblock;
306307 $this->mBlockEmail = $row->ipb_block_email;
 308+ $this->mAllowUsertalk = $row->ipb_allow_usertalk;
307309 $this->mHideName = $row->ipb_deleted;
308310 $this->mId = $row->ipb_id;
309311 $this->mExpiry = self::decodeExpiry( $row->ipb_expiry );
@@ -437,7 +439,8 @@
438440 'ipb_range_start' => $this->mRangeStart,
439441 'ipb_range_end' => $this->mRangeEnd,
440442 'ipb_deleted' => $this->mHideName,
441 - 'ipb_block_email' => $this->mBlockEmail
 443+ 'ipb_block_email' => $this->mBlockEmail,
 444+ 'ipb_allow_usertalk' => $this->mAllowUsertalk
442445 ), 'Block::insert', array( 'IGNORE' )
443446 );
444447 $affected = $dbw->affectedRows();
@@ -473,7 +476,8 @@
474477 'ipb_range_start' => $this->mRangeStart,
475478 'ipb_range_end' => $this->mRangeEnd,
476479 'ipb_deleted' => $this->mHideName,
477 - 'ipb_block_email' => $this->mBlockEmail ),
 480+ 'ipb_block_email' => $this->mBlockEmail,
 481+ 'ipb_allow_usertalk' => $this->mAllowUsertalk ),
478482 array( 'ipb_id' => $this->mId ),
479483 'Block::update' );
480484
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2501,6 +2501,7 @@
25022502 'ipbotherreason' => 'Other/additional reason:',
25032503 'ipbhidename' => 'Hide username from the block log, active block list and user list',
25042504 'ipbwatchuser' => "Watch this user's user and talk pages",
 2505+'ipballowusertalk' => "Allow this user to edit their own talk page while blocked",
25052506 'badipaddress' => 'Invalid IP address',
25062507 'blockipsuccesssub' => 'Block succeeded',
25072508 'blockipsuccesstext' => '[[Special:Contributions/$1|$1]] has been blocked.<br />
@@ -2545,6 +2546,7 @@
25462547 'block-log-flags-nocreate' => 'account creation disabled',
25472548 'block-log-flags-noautoblock' => 'autoblock disabled',
25482549 'block-log-flags-noemail' => 'e-mail blocked',
 2550+'block-log-flags-nousertalk' => 'cannot edit own talk page',
25492551 'block-log-flags-angry-autoblock' => 'enhanced autoblock enabled',
25502552 'range_block_disabled' => 'The sysop ability to create range blocks is disabled.',
25512553 'ipb_expiry_invalid' => 'Expiry time invalid.',
Index: trunk/phase3/RELEASE-NOTES
@@ -138,6 +138,7 @@
139139 image.
140140 * (bug 12650) It is now possible to set different expiration times for different
141141 restriction types on the protection form.
 142+* (bug 8440) Allow preventing blocked users from editing their talk pages
142143
143144 === Bug fixes in 1.14 ===
144145

Follow-up revisions

RevisionCommit summaryAuthorDate
r41249Add messages from r41248siebrand11:59, 25 September 2008
r41275Fix r41248 per Chad's suggestions on Wikitech. $wgBlockAllowsUTEdit now enabl...mattj00:28, 26 September 2008
r41403Fix r41248 (bug 8440) - Default should be 1 to allow for previous behaviour t...mattj23:16, 29 September 2008
r41533(bug 8440) Fix ipblocklist to show new allow usertalk flag.mattj08:41, 2 October 2008
r41536(bug 8440) Add API support for new blocking flag, also fix defaults so anywhe...mattj09:34, 2 October 2008