From 6a216b38315c6dd233f0b2f5f2a3cf4acd1dcb53 Mon Sep 17 00:00:00 2001 From: Thalia Date: Fri, 14 Jun 2019 09:22:57 +0100 Subject: [PATCH] Add a custom block message for composite blocks Give a custom reason and include the user's IP address and the expiry of the longest block. Bug: T225748 Change-Id: Ie147cca625365c1a01e2ed18819e5d6e3946865e --- includes/block/BlockManager.php | 2 ++ includes/block/CompositeBlock.php | 16 +++++++++++++++- languages/i18n/en.json | 2 ++ languages/i18n/qqq.json | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/includes/block/BlockManager.php b/includes/block/BlockManager.php index 60ae2f8677..b11e76f330 100644 --- a/includes/block/BlockManager.php +++ b/includes/block/BlockManager.php @@ -208,6 +208,8 @@ class BlockManager { } else { $block = new CompositeBlock( [ 'address' => $ip, + 'byText' => 'MediaWiki default', + 'reason' => wfMessage( 'blockedtext-composite-reason' )->plain(), 'originalBlocks' => $blocks, ] ); } diff --git a/includes/block/CompositeBlock.php b/includes/block/CompositeBlock.php index fda15058b2..8efd7de956 100644 --- a/includes/block/CompositeBlock.php +++ b/includes/block/CompositeBlock.php @@ -106,13 +106,27 @@ class CompositeBlock extends AbstractBlock { return $this->originalBlocks; } + /** + * @inheritDoc + */ + public function getExpiry() { + $maxExpiry = null; + foreach ( $this->originalBlocks as $block ) { + $expiry = $block->getExpiry(); + if ( $maxExpiry === null || $expiry === '' || $expiry > $maxExpiry ) { + $maxExpiry = $expiry; + } + } + return $maxExpiry; + } + /** * @inheritDoc */ public function getPermissionsError( IContextSource $context ) { $params = $this->getBlockErrorParams( $context ); - $msg = $this->isSitewide() ? 'blockedtext' : 'blockedtext-partial'; + $msg = 'blockedtext-composite'; array_unshift( $params, $msg ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 851a6b2c50..4c32ec6633 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -678,6 +678,8 @@ "autoblockedtext": "Your IP address has been automatically blocked because it was used by another user, who was blocked by $1.\nThe reason given is:\n\n:$2\n\n* Start of block: $8\n* Expiration of block: $6\n* Intended blockee: $7\n\nYou may contact $1 or one of the other [[{{MediaWiki:Grouppage-sysop}}|administrators]] to discuss the block.\n\nNote that you may not use the \"{{int:emailuser}}\" feature unless you have a valid email address registered in your [[Special:Preferences|user preferences]] and you have not been blocked from using it.\n\nYour current IP address is $3, and the block ID is #$5.\nPlease include all above details in any queries you make.", "systemblockedtext": "Your username or IP address has been automatically blocked by MediaWiki.\nThe reason given is:\n\n:$2\n\n* Start of block: $8\n* Expiration of block: $6\n* Intended blockee: $7\n\nYour current IP address is $3.\nPlease include all above details in any queries you make.", "blockednoreason": "no reason given", + "blockedtext-composite": "Your username or IP address has been blocked.\n\nThe reason given is:\n\n:$2.\n\n* Start of block: $8\n* Expiration of longest block: $6\n\nYour current IP address is $3.\nPlease include all above details in any queries you make.", + "blockedtext-composite-reason": "There are multiple blocks against your account and/or IP address", "whitelistedittext": "Please $1 to edit pages.", "confirmedittext": "You must confirm your email address before editing pages.\nPlease set and validate your email address through your [[Special:Preferences|user preferences]].", "nosuchsectiontitle": "Cannot find section", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index e0da190bb7..836359fe25 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -885,6 +885,8 @@ "blockedtext": "Text displayed to blocked users.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - the blocking sysop (with a link to his/her userpage)\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the blocking sysop's username (plain text, without the link)\n* $5 - the unique numeric identifier of the applied autoblock\n* $6 - the expiry of the block\n* $7 - the intended target of the block (what the blocking user specified in the blocking form)\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Autoblockedtext|notext=1}}\n* {{msg-mw|Systemblockedtext|notext=1}}", "autoblockedtext": "Text displayed to automatically blocked users.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - the blocking sysop (with a link to his/her userpage)\n* $2 - the reason for the block (in case of autoblocks: {{msg-mw|autoblocker}})\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the blocking sysop's username (plain text, without the link). Use it for GENDER.\n* $5 - the unique numeric identifier of the applied autoblock\n* $6 - the expiry of the block\n* $7 - the intended target of the block (what the blocking user specified in the blocking form)\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Blockedtext|notext=1}}\n* {{msg-mw|Systemblockedtext|notext=1}}", "systemblockedtext": "Text displayed to requests blocked by MediaWiki configuration.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - (Unused) A dummy user attributed as the blocker, possibly as a link to a user page.\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the dummy blocking user's username (plain text, without the link).\n* $5 - A short string indicating the type of system block.\n* $6 - the expiry of the block\n* $7 - the intended target of the block\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Blockedtext|notext=1}}\n* {{msg-mw|Autoblockedtext|notext=1}}", + "blockedtext-composite": "Text displayed to requests blocked by more than one block.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - (Unused) A dummy user attributed as the blocker, possibly as a link to a user page.\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the dummy blocking user's username (plain text, without the link).\n* $5 - (Unused) placeholder for the block ID.\n* $6 - the expiry of the block with the longest duration\n* $7 - (Unused) the intended target of the block\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Systemblockedtext|notext=1}}", + "blockedtext-composite-reason": "Reason given to blocked users who are affected by more than one block.\n\nSee also:\n* {{msg-mw|blockedtext-composite}}", "blockednoreason": "Substituted with $2 in the following message if the reason is not given:\n* {{msg-mw|cantcreateaccount-text}}.\n{{Identical|No reason given}}", "whitelistedittext": "Used as error message. Parameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description\n* $2 - an URL to the same\n\nSee also:\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Uploadnologintext}}\n* {{msg-mw|Loginreqpagetext}}", "confirmedittext": "Used as error message.", -- 2.20.1