Mainframe98 has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/341376 )
Change subject: First version of AutoBlockList special page
......................................................................
First version of AutoBlockList special page
This patch introduces a new special page named AutoBlockList.
Its design is reused from Special:BlockList.
Bug: T146414
Change-Id: I811d23c98be749d8df36700b07a295355691af77
---
M autoload.php
M includes/specialpage/SpecialPageFactory.php
A includes/specials/SpecialAutoBlockList.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M languages/messages/MessagesEn.php
6 files changed, 164 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/76/341376/1
diff --git a/autoload.php b/autoload.php
index 8c63d4f..8df5a23 100644
--- a/autoload.php
+++ b/autoload.php
@@ -1308,6 +1308,7 @@
'SpecialApiHelp' => __DIR__ . '/includes/specials/SpecialApiHelp.php',
'SpecialApiSandbox' => __DIR__ .
'/includes/specials/SpecialApiSandbox.php',
'SpecialBlankpage' => __DIR__ .
'/includes/specials/SpecialBlankpage.php',
+ 'SpecialAutoBlockList' => __DIR__ .
'/includes/specials/SpecialAutoBlockList.php',
'SpecialBlock' => __DIR__ . '/includes/specials/SpecialBlock.php',
'SpecialBlockList' => __DIR__ .
'/includes/specials/SpecialBlockList.php',
'SpecialBookSources' => __DIR__ .
'/includes/specials/SpecialBooksources.php',
diff --git a/includes/specialpage/SpecialPageFactory.php
b/includes/specialpage/SpecialPageFactory.php
index 33e1cc3..99e4d2f 100644
--- a/includes/specialpage/SpecialPageFactory.php
+++ b/includes/specialpage/SpecialPageFactory.php
@@ -96,6 +96,7 @@
'Block' => 'SpecialBlock',
'Unblock' => 'SpecialUnblock',
'BlockList' => 'SpecialBlockList',
+ 'AutoBlockList' => 'SpecialAutoBlockList',
'ChangePassword' => 'SpecialChangePassword',
'BotPasswords' => 'SpecialBotPasswords',
'PasswordReset' => 'SpecialPasswordReset',
@@ -504,7 +505,7 @@
* @param bool $including Bool output is being captured for use in
{{special:whatever}}
* @param LinkRenderer|null $linkRenderer (since 1.28)
*
- * @return bool
+ * @return bool|Title
*/
public static function executePath( Title &$title, IContextSource
&$context, $including = false,
LinkRenderer $linkRenderer = null
diff --git a/includes/specials/SpecialAutoBlockList.php
b/includes/specials/SpecialAutoBlockList.php
new file mode 100644
index 0000000..37ffe3e
--- /dev/null
+++ b/includes/specials/SpecialAutoBlockList.php
@@ -0,0 +1,148 @@
+<?php
+/**
+ * Implements Special:BlockList
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
+ */
+
+/**
+ * A special page that lists existing blocks
+ *
+ * @ingroup SpecialPage
+ */
+class SpecialAutoBlockList extends SpecialPage {
+
+ function __construct() {
+ parent::__construct( 'AutoBlockList' );
+ }
+
+ /**
+ * Main execution point
+ *
+ * @param string $par Title fragment
+ */
+ public function execute( $par ) {
+ $this->setHeaders();
+ $this->outputHeader();
+ $out = $this->getOutput();
+ $lang = $this->getLanguage();
+ $out->setPageTitle( $this->msg( 'autoblocklist' ) );
+ $out->addModuleStyles( [ 'mediawiki.special' ] );
+
+ # setup BlockListPager here to get the actual default Limit
+ $pager = $this->getBlockListPager();
+
+ # Just show the block list
+ $fields = [
+ 'Limit' => [
+ 'type' => 'limitselect',
+ 'label-message' => 'table_pager_limit_label',
+ 'options' => [
+ $lang->formatNum( 20 ) => 20,
+ $lang->formatNum( 50 ) => 50,
+ $lang->formatNum( 100 ) => 100,
+ $lang->formatNum( 250 ) => 250,
+ $lang->formatNum( 500 ) => 500,
+ ],
+ 'name' => 'limit',
+ 'default' => $pager->getLimit(),
+ ]
+ ];
+
+ $context = new DerivativeContext( $this->getContext() );
+ $context->setTitle( $this->getPageTitle() ); // Remove subpage
+ $form = HTMLForm::factory( 'ooui', $fields, $context );
+ $form
+ ->setMethod( 'get' )
+ ->setFormIdentifier( 'blocklist' )
+ ->setWrapperLegendMsg( 'autoblocklist-legend' )
+ ->setSubmitTextMsg( 'autoblocklist-submit' )
+ ->setSubmitProgressive()
+ ->prepareForm()
+ ->displayForm( false );
+
+ $this->showList( $pager );
+ }
+
+ /**
+ * Setup a new BlockListPager instance.
+ * @return BlockListPager
+ */
+ protected function getBlockListPager() {
+ $conds = [
+ // If this give compatibility issues, you can also
check for > 0.
+ 'ipb_parent_block_id IS NOT NULL'
+ ];
+ # Is the user allowed to see hidden blocks?
+ if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+ $conds['ipb_deleted'] = 0;
+ }
+
+ return new BlockListPager( $this, $conds );
+ }
+
+ /**
+ * Show the list of blocked accounts matching the actual filter.
+ * @param BlockListPager $pager The BlockListPager instance for this
page
+ */
+ protected function showList( BlockListPager $pager ) {
+ $out = $this->getOutput();
+
+ # Check for other blocks, i.e. global/tor blocks
+ $otherAutoBlockLink = [];
+ Hooks::run( 'OtherAutoBlockLogLink', [ &$otherAutoBlockLink ] );
+
+ # Show additional header for the local block only when other
blocks exists.
+ # Not necessary in a standard installation without such
extensions enabled
+ if ( count( $otherAutoBlockLink ) ) {
+ $out->addHTML(
+ Html::element( 'h2', [], $this->msg(
'autoblocklist-localblock' )->text() ) . "\n"
+ );
+ }
+
+ if ( $pager->getNumRows() ) {
+ $out->addParserOutputContent( $pager->getFullOutput() );
+ } else {
+ $out->addWikiMsg( 'autoblocklist-empty' );
+ }
+
+ if ( count( $otherAutoBlockLink ) ) {
+ $out->addHTML(
+ Html::rawElement(
+ 'h2',
+ [],
+ $this->msg(
'autoblocklist-otherblocks', count( $otherAutoBlockLink ) )->parse()
+ ) . "\n"
+ );
+ $list = '';
+ foreach ( $otherAutoBlockLink as $link ) {
+ $list .= Html::rawElement( 'li', [], $link ) .
"\n";
+ }
+ $out->addHTML( Html::rawElement(
+ 'ul',
+ [ 'class' =>
'mw-autoblocklist-otherblocks' ],
+ $list
+ ) . "\n" );
+ }
+ }
+
+ protected function getGroupName() {
+ return 'users';
+ }
+}
\ No newline at end of file
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 098adb6..ed37db1 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -2462,6 +2462,12 @@
"unblocked-id": "Block $1 has been removed.",
"unblocked-ip": "[[Special:Contributions/$1|$1]] has been unblocked.",
"blocklist": "Blocked users",
+ "autoblocklist": "Autoblocks",
+ "autoblocklist-submit": "Search",
+ "autoblocklist-legend": "List autoblocks",
+ "autoblocklist-localblock": "Local autoblock",
+ "autoblocklist-empty": "The autoblock list is empty.",
+ "autoblocklist-otherblocks": "Other {{PLURAL:$1|autoblock|autoblocks}}",
"ipblocklist": "Blocked users",
"ipblocklist-legend": "Find a blocked user",
"blocklist-userblocks": "Hide account blocks",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 026157e..fb746d7 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2649,6 +2649,12 @@
"unblocked-id": "Used in [[Special:Unblock]]. Parameters:\n* $1 -
autoblock ID\nSee also:\n* {{msg-mw|Unblocked}}\n* {{msg-mw|Unblocked-range}}",
"unblocked-ip": "{{doc-important|Do not translate the title
\"Special:Contributions\".}}\nParameters:\n* $1 - the IP address that was
unblocked\nSee also:\n* {{msg-mw|Unblocked-range}}\n*
{{msg-mw|Unblocked-id}}\n*{{msg-mw|Unblocked}}",
"blocklist": "{{doc-special|BlockList}}",
+ "autoblocklist": "Title of [[Special:Autoblocklist]].",
+ "autoblocklist-submit": "Used as Submit button text in the form on
[[Special:BlockList]].\n\nSee also:\n* {{msg-mw|Ipblocklist-legend}}\n*
{{msg-mw|Autoblocklist-submit}}\n{{Identical|Search}}",
+ "autoblocklist-legend":"Used as legend of the form in
[[Special:AutoBlockList]].\n\nSee also:\n* {{msg-mw|Autoblocklist-legend}}\n*
{{msg-mw|Autoblocklist-submit}}",
+ "autoblocklist-localblock": "[[File:Special AutoBlockList
new.png|thumb|Example]]\nUsed on [[Special:AutoBlockList]] as header when
global blocks exists too.",
+ "autoblocklist-empty": "Used in [[Special:AutoBlockList]].",
+ "autoblocklist-otherblocks": "[[File:Special AutoBlockList
new.png|thumb|Example]]\nUsed on [[Special:AutoBlockList]] as header for other
blocks, i.e. from GlobalBlocking or TorBlocks.\n\nParameters:\n* $1 - number of
blocks",
"ipblocklist": "Title of [[Special:Ipblocklist]].",
"ipblocklist-legend": "Used as legend of the form in
[[Special:BlockList]].\n\nSee also:\n* {{msg-mw|Ipblocklist-legend}}\n*
{{msg-mw|Ipblocklist-submit}}",
"blocklist-userblocks": "Used as the label for the multi-select
checkbox in the form on [[Special:BlockList]].\n{{Related|Blocklist-blocks}}",
diff --git a/languages/messages/MessagesEn.php
b/languages/messages/MessagesEn.php
index b9280ea..541c09a 100644
--- a/languages/messages/MessagesEn.php
+++ b/languages/messages/MessagesEn.php
@@ -431,6 +431,7 @@
'Invalidateemail' => [ 'InvalidateEmail' ],
'JavaScriptTest' => [ 'JavaScriptTest' ],
'BlockList' => [ 'BlockList', 'ListBlocks',
'IPBlockList' ],
+ 'AutoBlockList' => [ 'AutoBlockList', 'ListAutoBlocks' ],
'LinkSearch' => [ 'LinkSearch' ],
'LinkAccounts' => [ 'LinkAccounts' ],
'Listadmins' => [ 'ListAdmins' ],
--
To view, visit https://gerrit.wikimedia.org/r/341376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I811d23c98be749d8df36700b07a295355691af77
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mainframe98 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits