Page MenuHomePhabricator

patch-email_block.diff

Authored By
bzimport
Nov 21 2014, 9:28 PM
Size
9 KB
Referenced Files
None
Subscribers
None

patch-email_block.diff

Index: includes/Block.php
===================================================================
--- includes/Block.php (revision 22278)
+++ includes/Block.php (working copy)
@@ -15,7 +15,8 @@
class Block
{
/* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
- $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName;
+ $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName,
+ $mBlockEmail;
/* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName;
const EB_KEEP_EXPIRED = 1;
@@ -24,7 +25,7 @@
function __construct( $address = '', $user = 0, $by = 0, $reason = '',
$timestamp = '' , $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0,
- $hideName = 0 )
+ $hideName = 0, $blockEmail = 0 )
{
$this->mId = 0;
# Expand valid IPv6 addresses
@@ -40,7 +41,7 @@
$this->mExpiry = self::decodeExpiry( $expiry );
$this->mEnableAutoblock = $enableAutoblock;
$this->mHideName = $hideName;
-
+ $this->mBlockEmail = $blockEmail;
$this->mForUpdate = false;
$this->mFromMaster = false;
$this->mByName = false;
@@ -76,7 +77,7 @@
$this->mAddress = $this->mReason = $this->mTimestamp = '';
$this->mId = $this->mAnonOnly = $this->mCreateAccount =
$this->mEnableAutoblock = $this->mAuto = $this->mUser =
- $this->mBy = $this->mHideName = 0;
+ $this->mBy = $this->mHideName = $this->mBlockEmail = 0;
$this->mByName = false;
}
@@ -262,6 +263,7 @@
$this->mAnonOnly = $row->ipb_anon_only;
$this->mCreateAccount = $row->ipb_create_account;
$this->mEnableAutoblock = $row->ipb_enable_autoblock;
+ $this->mBlockEmail = $row->ipb_block_email;
$this->mHideName = $row->ipb_deleted;
$this->mId = $row->ipb_id;
$this->mExpiry = self::decodeExpiry( $row->ipb_expiry );
@@ -371,6 +373,7 @@
# Unset ipb_enable_autoblock for IP blocks, makes no sense
if ( !$this->mUser ) {
$this->mEnableAutoblock = 0;
+ $this->mBlockEmail = 0; //Same goes for email...
}
# Don't collide with expired blocks
@@ -392,7 +395,8 @@
'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ),
'ipb_range_start' => $this->mRangeStart,
'ipb_range_end' => $this->mRangeEnd,
- 'ipb_deleted' => $this->mHideName
+ 'ipb_deleted' => $this->mHideName,
+ 'ipb_block_email' => $this->mBlockEmail
), 'Block::insert', array( 'IGNORE' )
);
$affected = $dbw->affectedRows();
Index: includes/DefaultSettings.php
===================================================================
--- includes/DefaultSettings.php (revision 22799)
+++ includes/DefaultSettings.php (working copy)
@@ -974,6 +974,7 @@
$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
+$wgSysopEmailBans = false; # Allow sysops to ban users from accessing Emailuser
# Pages anonymous user may see as an array, e.g.:
# array ( "Main Page", "Special:Userlogin", "Wikipedia:Help");
Index: includes/SpecialBlockip.php
===================================================================
--- includes/SpecialBlockip.php (revision 22619)
+++ includes/SpecialBlockip.php (working copy)
@@ -43,6 +43,7 @@
*/
class IPBlockForm {
var $BlockAddress, $BlockExpiry, $BlockReason;
+# var $BlockEmail;
function IPBlockForm( $par ) {
global $wgRequest, $wgUser;
@@ -60,6 +61,7 @@
$this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', $byDefault );
$this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault );
$this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault );
+ $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', 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;
}
@@ -238,12 +240,27 @@
</tr>
");
}
+
+ global $wgSysopEmailBans;
+
+ if ( $wgSysopEmailBans ) {
+ $wgOut->addHTML("
+ <tr>
+ <td>&nbsp;</td>
+ <td>
+ " . wfCheckLabel( wfMsgHtml( 'ipbemailban' ),
+ 'wpEmailBan', 'wpEmailBan', $this->BlockEmail,
+ array( 'tabindex' => '10' )) . "
+ </td>
+ </tr>
+ ");
+ }
$wgOut->addHTML("
<tr>
<td style='padding-top: 1em'>&nbsp;</td>
<td style='padding-top: 1em'>
" . Xml::submitButton( wfMsg( 'ipbsubmit' ),
- array( 'name' => 'wpBlock', 'tabindex' => '10' ) ) . "
+ array( 'name' => 'wpBlock', 'tabindex' => '11' ) ) . "
</td>
</tr>
</table>" .
@@ -356,10 +373,10 @@
# Create block
# Note: for a user block, ipb_address is only for display purposes
-
$block = new Block( $this->BlockAddress, $userId, $wgUser->getID(),
$reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
- $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName);
+ $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
+ $this->BlockEmail);
if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
@@ -420,6 +437,8 @@
$flags[] = 'nocreate';
if( !$this->BlockEnableAutoblock )
$flags[] = 'noautoblock';
+ if ( $this->BlockEmail )
+ $flags[] = 'noemail';
return implode( ',', $flags );
}
Index: includes/SpecialEmailuser.php
===================================================================
--- includes/SpecialEmailuser.php (revision 22278)
+++ includes/SpecialEmailuser.php (working copy)
@@ -45,6 +45,14 @@
return;
}
+ $wgUser->getBlockedStatus();
+ if ( $wgUser->mBlock->mBlockEmail ) {
+ // User has been blocked from sending e-mail. Show the std blocked form.
+ wfDebug( "User is blocked from sending e-mail.\n" );
+ $wgOut->blockedPage();
+ return;
+ }
+
$f = new EmailUserForm( $nu );
if ( "success" == $action ) {
Index: includes/SpecialIpblocklist.php
===================================================================
--- includes/SpecialIpblocklist.php (revision 22278)
+++ includes/SpecialIpblocklist.php (working copy)
@@ -265,7 +265,7 @@
if( is_null( $msg ) ) {
$msg = array();
$keys = array( 'infiniteblock', 'expiringblock', 'contribslink', 'unblocklink',
- 'anononlyblock', 'createaccountblock', 'noautoblockblock' );
+ 'anononlyblock', 'createaccountblock', 'noautoblockblock', 'emailblock' );
foreach( $keys as $key ) {
$msg[$key] = wfMsgHtml( $key );
}
@@ -306,6 +306,10 @@
$properties[] = $msg['noautoblockblock'];
}
+ if ( $block->mBlockEmail && $block->mUser ) {
+ $properties[] = $msg['emailblock'];
+ }
+
$properties = implode( ', ', $properties );
$line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $blocker, $target, $properties ) );
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 22809)
+++ languages/messages/MessagesEn.php (working copy)
@@ -1967,6 +1967,7 @@
** Unacceptable username',
'ipbanononly' => 'Block anonymous users only',
'ipbcreateaccount' => 'Prevent account creation',
+'ipbemailban' => 'Prevent user from sending e-mail',
'ipbenableautoblock' => 'Automatically block the last IP address used by this user, and any subsequent IPs they try to edit from',
'ipbsubmit' => 'Block this user',
'ipbother' => 'Other time:',
@@ -1998,6 +1999,7 @@
'anononlyblock' => 'anon. only',
'noautoblockblock' => 'autoblock disabled',
'createaccountblock' => 'account creation blocked',
+'emailblock' => 'e-mail blocked',
'ipblocklist-empty' => 'The blocklist is empty.',
'ipblocklist-no-results' => 'The requested IP address or username is not blocked.',
'blocklink' => 'block',
@@ -2013,6 +2015,7 @@
'block-log-flags-anononly' => 'anonymous users only',
'block-log-flags-nocreate' => 'account creation disabled',
'block-log-flags-noautoblock' => 'autoblock disabled',
+'block-log-flags-noemail' => 'e-mail blocked',
'range_block_disabled' => 'The sysop ability to create range blocks is disabled.',
'ipb_expiry_invalid' => 'Expiry time invalid.',
'ipb_already_blocked' => '"$1" is already blocked',
Index: maintenance/archives/patch-ipb_emailban.sql
===================================================================
--- maintenance/archives/patch-ipb_emailban.sql (revision 0)
+++ maintenance/archives/patch-ipb_emailban.sql (revision 0)
@@ -0,0 +1,4 @@
+-- Add row for email blocks --
+
+ALTER TABLE /*$wgDBprefix*/ipblocks
+ ADD ipb_block_email tinyint(1) NOT NULL default '0';
Index: maintenance/updaters.inc
===================================================================
--- maintenance/updaters.inc (revision 22799)
+++ maintenance/updaters.inc (working copy)
@@ -76,6 +76,7 @@
array( 'archive', 'ar_len', 'patch-ar_len.sql' ),
array( 'revision', 'rev_parent_id', 'patch-rev_parent_id.sql' ),
array( 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ),
+ array( 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ),
);
function rename_table( $from, $to, $patch ) {

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2942
Default Alt Text
patch-email_block.diff (9 KB)

Event Timeline