jenkins-bot has submitted this change and it was merged.
Change subject: Add Special:MultiLock link on Special:CheckUser if configured
......................................................................
Add Special:MultiLock link on Special:CheckUser if configured
Introduce $wgCheckUserCAMultiLock which, if enabled, adds a link to
Special:MultiLock on the block form for users in the configured global groups.
By default, this is disabled.
Example config:
$wgCheckUserCAMultiLock = array(
'centralDB' => 'metawiki',
'groups' => array( 'steward' )
);
Bug: T128605
Change-Id: I925ee0849109e08bed1c0380e16063900c148753
---
M CheckUser.php
M extension.json
M i18n/en.json
M i18n/qqq.json
A modules/ext.checkuser.caMultiLock.js
M specials/SpecialCheckUser.php
6 files changed, 93 insertions(+), 2 deletions(-)
Approvals:
CSteipp: Looks good to me, but someone else must approve
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CheckUser.php b/CheckUser.php
index 0ac2e6b..1b8fb9b 100644
--- a/CheckUser.php
+++ b/CheckUser.php
@@ -72,6 +72,20 @@
CUPUBLICKEY;
+/*
+ * This can be used to add a link to Special:MultiLock by CentralAuth
+ * to the Special:CheckUser's mass block form. This requires CentralAuth
+ * extension to be installed on the wiki.
+ * To enable this, set this to an array with a central wiki's database name
+ * and an array with the name(s) of the global group(s) to add the link for.
+ * Example:
+ * $wgCheckUserCAMultiLock = array(
+ * 'centralDB' => 'metawiki',
+ * 'groups' => array( 'steward' )
+ * );
+ */
+$wgCheckUserCAMultiLock = false;
+
# Recent changes data hook
$wgHooks['RecentChange_save'][] = 'CheckUserHooks::updateCheckUserData';
$wgHooks['EmailUser'][] = 'CheckUserHooks::updateCUEmailData';
@@ -97,6 +111,13 @@
'localBasePath' => dirname( __FILE__ ),
'remoteExtPath' => 'CheckUser',
);
+$wgResourceModules['ext.checkUser.caMultiLock'] = array(
+ 'scripts' => 'modules/ext.checkuser.caMultiLock.js',
+ 'dependencies' => array( 'mediawiki.util' ),
+ 'messages' => array( 'checkuser-centralauth-multilock' ),
+ 'localBasePath' => dirname( __FILE__ ),
+ 'remoteExtPath' => 'CheckUser',
+);
// Set up the new special page
$wgSpecialPages['CheckUser'] = 'CheckUser';
diff --git a/extension.json b/extension.json
index 550af42..610e590 100644
--- a/extension.json
+++ b/extension.json
@@ -21,7 +21,8 @@
"CheckUserLog": "/home/wikipedia/logs/checkuser.log",
"CUPublicKey": "",
"CUDMaxAge": 7776000,
- "CheckUserForceSummary": false
+ "CheckUserForceSummary": false,
+ "CheckUserCAMultiLock": false
},
"APIListModules": {
"checkuser": "ApiQueryCheckUser",
@@ -76,6 +77,15 @@
"dependencies": [
"mediawiki.util"
]
+ },
+ "ext.checkUser.caMultiLock": {
+ "scripts": "modules/ext.checkuser.caMultiLock.js",
+ "dependencies": [
+ "mediawiki.util"
+ ],
+ "messages": [
+ "checkuser-centralauth-multilock"
+ ]
}
},
"ResourceFileModulePaths": {
diff --git a/i18n/en.json b/i18n/en.json
index 435f7c6..783dfa8 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -57,6 +57,7 @@
"checkuser-block-failure": "'''No users blocked.'''",
"checkuser-block-limit": "Too many users selected.",
"checkuser-block-noreason": "You must give a reason for the blocks.",
+ "checkuser-centralauth-multilock": "Multi lock selected accounts",
"checkuser-noreason": "You must give a reason for this query.",
"checkuser-accounts": "$1 new {{PLURAL:$1|account|accounts}}",
"checkuser-too-many": "Too many results (according to query estimate),
please narrow down the CIDR.\nHere are the IP addresses used (5000 max, sorted
by address):",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b122e50..6a45cec 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -76,6 +76,7 @@
"checkuser-block-failure": "Used as failure message in
[[Special:CheckUser]].\n\nSee also:\n* {{msg-mw|Checkuser-block-success}}\n*
{{msg-mw|Checkuser-block-limit}}\n* {{msg-mw|Checkuser-block-noreason}}",
"checkuser-block-limit": "Used as failure message in
[[Special:CheckUser]].\n\nSee also:\n* {{msg-mw|Checkuser-block-success}}\n*
{{msg-mw|Checkuser-block-failure}}\n* {{msg-mw|Checkuser-block-noreason}}",
"checkuser-block-noreason": "Used as failure message in
[[Special:CheckUser]].\n\nSee also:\n* {{msg-mw|Checkuser-block-success}}\n*
{{msg-mw|Checkuser-block-failure}}\n* {{msg-mw|Checkuser-block-limit}}",
+ "checkuser-centralauth-multilock": "Label of link to Special:MultiLock
shown on Special:CheckUser's block form.",
"checkuser-noreason": "Used as error message in [[Special:CheckUser]].",
"checkuser-accounts": "Used in Special:CheckUser. Parameters:\n* $1 -
number of accounts",
"checkuser-too-many": "Used in [[Special:CheckUser]].\n\nThis message
is followed by a list of IPs that have edits.\n\nIf the number of IPs is 5000
or more, the following message is shown:\n* {{msg-mw|checkuser-limited}}",
diff --git a/modules/ext.checkuser.caMultiLock.js
b/modules/ext.checkuser.caMultiLock.js
new file mode 100644
index 0000000..f2b52cc
--- /dev/null
+++ b/modules/ext.checkuser.caMultiLock.js
@@ -0,0 +1,35 @@
+/**
+ * Adds a link to Special:MultiLock on a central wiki if
$wgCheckUserCAMultiLock
+ * is configured on the Special:CheckUser's block form
+ */
+( function ( mw, $ ) {
+ var centralURL = mw.config.get( 'wgCUCAMultiLockCentral' ),
+ $userCheckboxes = $( '#checkuserresults li :checkbox' );
+
+ // Initialize the link
+ $( '#checkuserblock fieldset' ).append(
+ $( '<a>', {
+ id: 'cacu-multilock-link',
+ text: mw.msg( 'checkuser-centralauth-multilock' ),
+ href: centralURL,
+ } )
+ );
+
+ // Change the URL of the link when a checkbox's state is changed
+ $userCheckboxes.on( 'change', function() {
+ var names = [];
+ $.each( $userCheckboxes.serializeArray(), function( i, obj ) {
+ if ( obj.name && obj.name === 'users[]' ) {
+ // Only registered accounts (not IPs) can be
locked
+ if ( !mw.util.isIPAddress( obj.value ) ) {
+ names.push( obj.value );
+ }
+ }
+ } );
+
+ var mlHref = encodeURI( centralURL + '?wpTarget=' + names.join(
'\n' ) );
+ // Update the href of the link with the latest change
+ $( '#cacu-multilock-link' ).prop( 'href', mlHref );
+ } );
+
+}( mediaWiki, jQuery ) );
diff --git a/specials/SpecialCheckUser.php b/specials/SpecialCheckUser.php
index ea7c300..6980bcc 100644
--- a/specials/SpecialCheckUser.php
+++ b/specials/SpecialCheckUser.php
@@ -1141,7 +1141,30 @@
* @return string
*/
protected function getBlockForm( $tag, $talkTag ) {
- global $wgBlockAllowsUTEdit;
+ global $wgBlockAllowsUTEdit, $wgCheckUserCAMultiLock;
+ if ( $wgCheckUserCAMultiLock !== false ) {
+ if ( !class_exists( 'CentralAuthUser' ) ) {
+ // $wgCheckUserCAMultiLock shouldn't be enabled
if CA is not loaded
+ throw new Exception( '$wgCheckUserCAMultiLock
requires CentralAuth extension.' );
+ }
+
+ $caUserGroups = CentralAuthUser::getInstance(
$this->getUser() )->getGlobalGroups();
+ // Only load the script for users in the configured
global group(s)
+ if ( count( array_intersect(
$wgCheckUserCAMultiLock['groups'], $caUserGroups ) ) ) {
+ $out = $this->getOutput();
+ $out->addModules( 'ext.checkUser.caMultiLock' );
+ $centralMLUrl = WikiMap::getForeignURL(
+ $wgCheckUserCAMultiLock['centralDB'],
+ // Use canonical name instead of local
name so that it works
+ // even if the local language is
different from central wiki
+ Title::makeTitle( NS_SPECIAL,
'MultiLock' )->getPrefixedText()
+ );
+ if ( $centralMLUrl === false ) {
+ throw new Exception( "Could not
retrieve URL for {$wgCheckUserCAMultiLock['centralDB']}" );
+ }
+ $out->addJsConfigVars(
'wgCUCAMultiLockCentral', $centralMLUrl );
+ }
+ }
$s = "<fieldset>\n";
$s .= '<legend>' . $this->msg( 'checkuser-massblock'
)->escaped() . "</legend>\n";
--
To view, visit https://gerrit.wikimedia.org/r/283840
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I925ee0849109e08bed1c0380e16063900c148753
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/CheckUser
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Glaisher <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits