r22816 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22815‎ | r22816 | r22817 >
Date:17:31, 7 June 2007
Author:amidaniel
Status:old
Tags:
Comment:
(bug 7997) Added ability to Special:Blockip to block users from using Special:Emailuser.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/includes/SpecialEmailuser.php (modified) (history)
  • /trunk/phase3/includes/SpecialIpblocklist.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-ipb_emailban.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_emailban.sql
@@ -0,0 +1,4 @@
 2+-- Add row for email blocks --
 3+
 4+ALTER TABLE /*$wgDBprefix*/ipblocks
 5+ ADD ipb_block_email tinyint(1) NOT NULL default '0';
Property changes on: trunk/phase3/maintenance/archives/patch-ipb_emailban.sql
___________________________________________________________________
Added: svn:eol-style
16 + native
Index: trunk/phase3/maintenance/updaters.inc
@@ -76,6 +76,7 @@
7777 array( 'archive', 'ar_len', 'patch-ar_len.sql' ),
7878 array( 'revision', 'rev_parent_id', 'patch-rev_parent_id.sql' ),
7979 array( 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ),
 80+ array( 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ),
8081 );
8182
8283 function rename_table( $from, $to, $patch ) {
Index: trunk/phase3/maintenance/tables.sql
@@ -622,6 +622,9 @@
623623
624624 -- Flag for entries hidden from users and Sysops
625625 ipb_deleted bool NOT NULL default 0,
 626+
 627+ -- Block prevents user from accessing Special:Emailuser
 628+ ipb_block_email bool NOT NULL default 0,
626629
627630 PRIMARY KEY ipb_id (ipb_id),
628631
Index: trunk/phase3/includes/User.php
@@ -2149,6 +2149,17 @@
21502150 return $this->mBlock && $this->mBlock->mCreateAccount;
21512151 }
21522152
 2153+ /**
 2154+ * Determine if the user is blocked from using Special:Emailuser.
 2155+ *
 2156+ * @public
 2157+ * @return boolean
 2158+ */
 2159+ function isBlockedFromEmailuser() {
 2160+ $this->getBlockedStatus();
 2161+ return $this->mBlock && $this->mBlock->mBlockEmail;
 2162+ }
 2163+
21532164 function isAllowedToCreateAccount() {
21542165 return $this->isAllowed( 'createaccount' ) && !$this->isBlockedFromCreateAccount();
21552166 }
Index: trunk/phase3/includes/SpecialBlockip.php
@@ -43,6 +43,7 @@
4444 */
4545 class IPBlockForm {
4646 var $BlockAddress, $BlockExpiry, $BlockReason;
 47+# var $BlockEmail;
4748
4849 function IPBlockForm( $par ) {
4950 global $wgRequest, $wgUser;
@@ -60,6 +61,7 @@
6162 $this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', $byDefault );
6263 $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault );
6364 $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault );
 65+ $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
6466 # Re-check user's rights to hide names, very serious, defaults to 0
6567 $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
6668 }
@@ -238,12 +240,27 @@
239241 </tr>
240242 ");
241243 }
 244+
 245+ global $wgSysopEmailBans;
 246+
 247+ if ( $wgSysopEmailBans ) {
 248+ $wgOut->addHTML("
 249+ <tr>
 250+ <td>&nbsp;</td>
 251+ <td>
 252+ " . wfCheckLabel( wfMsgHtml( 'ipbemailban' ),
 253+ 'wpEmailBan', 'wpEmailBan', $this->BlockEmail,
 254+ array( 'tabindex' => '10' )) . "
 255+ </td>
 256+ </tr>
 257+ ");
 258+ }
242259 $wgOut->addHTML("
243260 <tr>
244261 <td style='padding-top: 1em'>&nbsp;</td>
245262 <td style='padding-top: 1em'>
246263 " . Xml::submitButton( wfMsg( 'ipbsubmit' ),
247 - array( 'name' => 'wpBlock', 'tabindex' => '10' ) ) . "
 264+ array( 'name' => 'wpBlock', 'tabindex' => '11' ) ) . "
248265 </td>
249266 </tr>
250267 </table>" .
@@ -356,10 +373,10 @@
357374
358375 # Create block
359376 # Note: for a user block, ipb_address is only for display purposes
360 -
361377 $block = new Block( $this->BlockAddress, $userId, $wgUser->getID(),
362378 $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
363 - $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName);
 379+ $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
 380+ $this->BlockEmail);
364381
365382 if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
366383
@@ -420,6 +437,8 @@
421438 $flags[] = 'nocreate';
422439 if( !$this->BlockEnableAutoblock )
423440 $flags[] = 'noautoblock';
 441+ if ( $this->BlockEmail )
 442+ $flags[] = 'noemail';
424443 return implode( ',', $flags );
425444 }
426445
Index: trunk/phase3/includes/SpecialEmailuser.php
@@ -45,6 +45,13 @@
4646 return;
4747 }
4848
 49+ if ( $wgUser->isBlockedFromEmailUser() ) {
 50+ // User has been blocked from sending e-mail. Show the std blocked form.
 51+ wfDebug( "User is blocked from sending e-mail.\n" );
 52+ $wgOut->blockedPage();
 53+ return;
 54+ }
 55+
4956 $f = new EmailUserForm( $nu );
5057
5158 if ( "success" == $action ) {
Index: trunk/phase3/includes/SpecialIpblocklist.php
@@ -265,7 +265,7 @@
266266 if( is_null( $msg ) ) {
267267 $msg = array();
268268 $keys = array( 'infiniteblock', 'expiringblock', 'contribslink', 'unblocklink',
269 - 'anononlyblock', 'createaccountblock', 'noautoblockblock' );
 269+ 'anononlyblock', 'createaccountblock', 'noautoblockblock', 'emailblock' );
270270 foreach( $keys as $key ) {
271271 $msg[$key] = wfMsgHtml( $key );
272272 }
@@ -306,6 +306,10 @@
307307 $properties[] = $msg['noautoblockblock'];
308308 }
309309
 310+ if ( $block->mBlockEmail && $block->mUser ) {
 311+ $properties[] = $msg['emailblock'];
 312+ }
 313+
310314 $properties = implode( ', ', $properties );
311315
312316 $line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $blocker, $target, $properties ) );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -971,9 +971,10 @@
972972
973973 # Basic user rights and block settings
974974 $wgSysopUserBans = true; # Allow sysops to ban logged-in users
975 -$wgSysopRangeBans = true; # Allow sysops to ban IP ranges
976 -$wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire
 975+$wgSysopRangeBans = true; # Allow sysops to ban IP ranges
 976+$wgAutoblockExpiry = 86400; # Number of seconds before autoblock entries expire
977977 $wgBlockAllowsUTEdit = false; # Blocks allow users to edit their own user talk page
 978+$wgSysopEmailBans = true; # Allow sysops to ban users from accessing Emailuser
978979
979980 # Pages anonymous user may see as an array, e.g.:
980981 # array ( "Main Page", "Special:Userlogin", "Wikipedia:Help");
Index: trunk/phase3/includes/Block.php
@@ -15,7 +15,8 @@
1616 class Block
1717 {
1818 /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
19 - $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName;
 19+ $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName,
 20+ $mBlockEmail;
2021 /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName;
2122
2223 const EB_KEEP_EXPIRED = 1;
@@ -24,7 +25,7 @@
2526
2627 function __construct( $address = '', $user = 0, $by = 0, $reason = '',
2728 $timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0,
28 - $hideName = 0 )
 29+ $hideName = 0, $blockEmail = 0 )
2930 {
3031 $this->mId = 0;
3132 # Expand valid IPv6 addresses
@@ -40,7 +41,7 @@
4142 $this->mExpiry = self::decodeExpiry( $expiry );
4243 $this->mEnableAutoblock = $enableAutoblock;
4344 $this->mHideName = $hideName;
44 -
 45+ $this->mBlockEmail = $blockEmail;
4546 $this->mForUpdate = false;
4647 $this->mFromMaster = false;
4748 $this->mByName = false;
@@ -76,7 +77,7 @@
7778 $this->mAddress = $this->mReason = $this->mTimestamp = '';
7879 $this->mId = $this->mAnonOnly = $this->mCreateAccount =
7980 $this->mEnableAutoblock = $this->mAuto = $this->mUser =
80 - $this->mBy = $this->mHideName = 0;
 81+ $this->mBy = $this->mHideName = $this->mBlockEmail = 0;
8182 $this->mByName = false;
8283 }
8384
@@ -262,6 +263,7 @@
263264 $this->mAnonOnly = $row->ipb_anon_only;
264265 $this->mCreateAccount = $row->ipb_create_account;
265266 $this->mEnableAutoblock = $row->ipb_enable_autoblock;
 267+ $this->mBlockEmail = $row->ipb_block_email;
266268 $this->mHideName = $row->ipb_deleted;
267269 $this->mId = $row->ipb_id;
268270 $this->mExpiry = self::decodeExpiry( $row->ipb_expiry );
@@ -371,6 +373,7 @@
372374 # Unset ipb_enable_autoblock for IP blocks, makes no sense
373375 if ( !$this->mUser ) {
374376 $this->mEnableAutoblock = 0;
 377+ $this->mBlockEmail = 0; //Same goes for email...
375378 }
376379
377380 # Don't collide with expired blocks
@@ -392,7 +395,8 @@
393396 'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ),
394397 'ipb_range_start' => $this->mRangeStart,
395398 'ipb_range_end' => $this->mRangeEnd,
396 - 'ipb_deleted' => $this->mHideName
 399+ 'ipb_deleted' => $this->mHideName,
 400+ 'ipb_block_email' => $this->mBlockEmail
397401 ), 'Block::insert', array( 'IGNORE' )
398402 );
399403 $affected = $dbw->affectedRows();
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -939,7 +939,8 @@
940940
941941 You can contact $1 or another [[{{MediaWiki:grouppage-sysop}}|administrator]] to discuss the block.
942942 You cannot use the 'email this user' feature unless a valid email address is specified in your
943 -[[Special:Preferences|account preferences]]. Your current IP address is $3, and the block ID is #$5. Please include either or both of these in any queries.",
 943+[[Special:Preferences|account preferences]] and you have not been blocked from using it.
 944+Your current IP address is $3, and the block ID is #$5. Please include either or both of these in any queries.",
944945 'autoblockedtext' => 'Your IP address has been automatically blocked because it was used by another user, who was blocked by $1.
945946 The reason given is this:
946947
@@ -950,7 +951,8 @@
951952 You may contact $1 or one of the other
952953 [[{{MediaWiki:grouppage-sysop}}|administrators]] to discuss the block.
953954
954 -Note that you may not use the "e-mail this user" feature unless you have a valid e-mail address registered in your [[Special:Preferences|user preferences]].
 955+Note that you may not use the "e-mail this user" feature unless you have a valid e-mail address
 956+registered in your [[Special:Preferences|user preferences]] and you have not been blocked from using it.
955957
956958 Your block ID is $5. Please include this ID in any queries you make.',
957959 'blockedoriginalsource' => "The source of '''$1''' is shown below:",
@@ -1967,6 +1969,7 @@
19681970 ** Unacceptable username',
19691971 'ipbanononly' => 'Block anonymous users only',
19701972 'ipbcreateaccount' => 'Prevent account creation',
 1973+'ipbemailban' => 'Prevent user from sending e-mail',
19711974 'ipbenableautoblock' => 'Automatically block the last IP address used by this user, and any subsequent IPs they try to edit from',
19721975 'ipbsubmit' => 'Block this user',
19731976 'ipbother' => 'Other time:',
@@ -1998,6 +2001,7 @@
19992002 'anononlyblock' => 'anon. only',
20002003 'noautoblockblock' => 'autoblock disabled',
20012004 'createaccountblock' => 'account creation blocked',
 2005+'emailblock' => 'e-mail blocked',
20022006 'ipblocklist-empty' => 'The blocklist is empty.',
20032007 'ipblocklist-no-results' => 'The requested IP address or username is not blocked.',
20042008 'blocklink' => 'block',
@@ -2013,6 +2017,7 @@
20142018 'block-log-flags-anononly' => 'anonymous users only',
20152019 'block-log-flags-nocreate' => 'account creation disabled',
20162020 'block-log-flags-noautoblock' => 'autoblock disabled',
 2021+'block-log-flags-noemail' => 'e-mail blocked',
20172022 'range_block_disabled' => 'The sysop ability to create range blocks is disabled.',
20182023 'ipb_expiry_invalid' => 'Expiry time invalid.',
20192024 'ipb_already_blocked' => '"$1" is already blocked',
Index: trunk/phase3/RELEASE-NOTES
@@ -64,6 +64,9 @@
6565 * Show result of Special:Booksources in wiki content language always, it's
6666 normally better maintained than the generic list from the standard message
6767 files
 68+* (bug 7997) Added ability of sysops to block users from sending e-mail via
 69+ Special:Emailuser. This can be disabled by setting $wgSysopEmailBans to
 70+ false.
6871
6972 == Bugfixes since 1.10 ==
7073

Follow-up revisions

RevisionCommit summaryAuthorDate
r22826* (bug 8989) Blacklist 'mhtml' and 'mht' files from upload...robchurch20:49, 7 June 2007
r22857Merged revisions 22811-22855 via svnmerge from...david00:48, 9 June 2007

Status & tagging log