Add option to block a user from editing their own talk page

Bug: T170014
Change-Id: I74b7fd2e036111583e8b69c355e7fb0c51fe67fc
This commit is contained in:
Huji Lee 2017-08-22 14:23:01 -04:00 committed by Huji
parent 24a2518f02
commit a83b10c5ed
4 changed files with 50 additions and 4 deletions

View file

@ -171,6 +171,7 @@
"abusefilter-edit-action-blockautopromote": "Revoke the user's autoconfirmed status",
"abusefilter-edit-action-degroup": "Remove the user from all privileged groups",
"abusefilter-edit-action-block": "Block the user and/or IP address from editing",
"abusefilter-edit-action-blocktalk": "Block the user and/or IP address from editing their own talk page",
"abusefilter-edit-action-throttle": "Trigger actions only if the user trips a rate limit",
"abusefilter-edit-action-rangeblock": "Block the respective IP range from which the user originates",
"abusefilter-edit-action-tag": "Tag the edit for further review",
@ -318,6 +319,7 @@
"abusefilter-edit-builder-vars-file-width": "Width of the file in pixels",
"abusefilter-edit-builder-vars-file-height": "Height of the file in pixels",
"abusefilter-edit-builder-vars-file-bits-per-channel": "Bits per color channel of the file",
"abusefilter-edit-block-options": "Block options:",
"abusefilter-filter-log": "Recent filter changes",
"abusefilter-history": "Change history for Abuse Filter #$1",
"abusefilter-history-foruser": "Changes by $1",

View file

@ -203,6 +203,7 @@
"abusefilter-edit-action-blockautopromote": "{{doc-abusefilter-action}}",
"abusefilter-edit-action-degroup": "{{doc-abusefilter-action}}",
"abusefilter-edit-action-block": "{{doc-abusefilter-action}}",
"abusefilter-edit-action-blocktalk": "{{doc-abusefilter-action}}",
"abusefilter-edit-action-throttle": "{{doc-abusefilter-action}}",
"abusefilter-edit-action-rangeblock": "{{doc-abusefilter-action}}",
"abusefilter-edit-action-tag": "{{doc-abusefilter-action}}",
@ -350,6 +351,7 @@
"abusefilter-edit-builder-vars-file-width": "This variable contains the width of the file in pixels",
"abusefilter-edit-builder-vars-file-height": "This variable contains the height of the file in pixels",
"abusefilter-edit-builder-vars-file-bits-per-channel": "This variable contains the number of bits per color channel of the file",
"abusefilter-edit-block-options": "Label for the checkbox for block options",
"abusefilter-filter-log": "Used as page title.",
"abusefilter-history": "Used as page title.\n\n\"Change history\" is the \"history of changes\"\n\nParameters:\n* $1 - filter ID\n\nIf the filter ID is not specified, {{msg-mw|Abusefilter-filter-log}} will be used.",
"abusefilter-history-foruser": "Parameters:\n* $1 - a link to the changing user's page\n* $2 - (Optional) the plain text username",

View file

@ -1441,7 +1441,8 @@ class AbuseFilter {
],
$wgUser->getName(),
$expiry,
true
true,
is_array( $parameters ) && in_array( 'blocktalk', $parameters )
);
$message = [
@ -1591,8 +1592,15 @@ class AbuseFilter {
* @param string $target
* @param string $expiry
* @param bool $isAutoBlock
* @param bool $preventEditOwnUserTalk
*/
protected static function doAbuseFilterBlock( array $rule, $target, $expiry, $isAutoBlock ) {
protected static function doAbuseFilterBlock(
array $rule,
$target,
$expiry,
$isAutoBlock,
$preventEditOwnUserTalk = false
) {
$filterUser = self::getFilterUser();
$reason = wfMessage(
'abusefilter-blockreason',
@ -1606,7 +1614,7 @@ class AbuseFilter {
$block->isHardblock( false );
$block->isAutoblocking( $isAutoBlock );
$block->prevents( 'createaccount', true );
$block->prevents( 'editownusertalk', false );
$block->prevents( 'editownusertalk', $preventEditOwnUserTalk );
$block->mExpiry = SpecialBlock::parseExpiryInput( $expiry );
$success = $block->insert();

View file

@ -821,11 +821,42 @@ class AbuseFilterViewEdit extends AbuseFilterView {
Xml::buildForm( $tagFields )
);
return $output;
case 'block':
global $wgBlockAllowsUTEdit;
$output = '';
$checkbox = Xml::checkLabel(
$this->msg( 'abusefilter-edit-action-block' )->text(),
'wpFilterActionBlock',
"mw-abusefilter-action-checkbox-block",
$set,
[ 'class' => 'mw-abusefilter-action-checkbox' ] + $cbReadOnlyAttrib );
$output .= Xml::tags( 'p', null, $checkbox );
if ( $wgBlockAllowsUTEdit === true ) {
$checkbox =
Xml::label(
$this->msg( 'abusefilter-edit-block-options' ),
'mw-abusefilter-block-parameters'
) .
Xml::checkLabel(
$this->msg( 'abusefilter-edit-action-blocktalk' )->text(),
'wpFilterBlockTalk',
'mw-abusefilter-action-checkbox-blocktalk',
$parameters[0] == 'blocktalk',
[ 'class' => 'mw-abusefilter-action-checkbox' ] + $cbReadOnlyAttrib
);
$output .=
Xml::tags(
'div',
[ 'id' => 'mw-abusefilter-block-parameters' ],
$checkbox
);
}
return $output;
default:
// Give grep a chance to find the usages:
// abusefilter-edit-action-warn, abusefilter-edit-action-disallow
// abusefilter-edit-action-blockautopromote
// abusefilter-edit-action-degroup, abusefilter-edit-action-block
// abusefilter-edit-action-degroup
// abusefilter-edit-action-throttle, abusefilter-edit-action-rangeblock
// abusefilter-edit-action-tag
$message = 'abusefilter-edit-action-' . $action;
@ -1059,6 +1090,9 @@ class AbuseFilterViewEdit extends AbuseFilterView {
}
$parameters[0] = $specMsg;
} elseif ( $action == 'block' ) {
$parameters = $request->getCheck( 'wpFilterBlockTalk' ) ?
[ 'blocktalk' ] : [ '' ];
} elseif ( $action == 'tag' ) {
$parameters = explode( "\n", $request->getText( 'wpFilterTags' ) );
}