First version of AutoblockList special page
authormainframe98 <k.s.werf@hotmail.com>
Mon, 6 Mar 2017 20:09:36 +0000 (21:09 +0100)
committerKaldari <rkaldari@wikimedia.org>
Tue, 11 Apr 2017 17:40:42 +0000 (10:40 -0700)
This patch introduces a new special page named AutoblockList.
Its design is reused from Special:BlockList.

Bug: T146414
Change-Id: I811d23c98be749d8df36700b07a295355691af77

autoload.php
docs/hooks.txt
includes/specialpage/SpecialPageFactory.php
includes/specials/SpecialAutoblockList.php [new file with mode: 0644]
languages/i18n/en.json
languages/i18n/qqq.json
languages/messages/MessagesEn.php

index a16451d..f274c7a 100644 (file)
@@ -1307,6 +1307,7 @@ $wgAutoloadLocalClasses = [
        'SpecialAllPages' => __DIR__ . '/includes/specials/SpecialAllPages.php',
        'SpecialApiHelp' => __DIR__ . '/includes/specials/SpecialApiHelp.php',
        'SpecialApiSandbox' => __DIR__ . '/includes/specials/SpecialApiSandbox.php',
+       'SpecialAutoblockList' => __DIR__ . '/includes/specials/SpecialAutoblockList.php',
        'SpecialBlankpage' => __DIR__ . '/includes/specials/SpecialBlankpage.php',
        'SpecialBlock' => __DIR__ . '/includes/specials/SpecialBlock.php',
        'SpecialBlockList' => __DIR__ . '/includes/specials/SpecialBlockList.php',
index 846a073..d56ca35 100644 (file)
@@ -2279,6 +2279,10 @@ $page: the Page that was rendered.
 $title: the Title of the rendered page.
 $parserOutput: ParserOutput resulting from rendering the page.
 
+'OtherAutoblockLogLink': Get links to the autoblock log from extensions which
+autoblocks users and/or IP addresses too.
+&$otherBlockLink: An array with links to other autoblock logs
+
 'OtherBlockLogLink': Get links to the block log from extensions which blocks
 users and/or IP addresses too.
 &$otherBlockLink: An array with links to other block logs
index 33e1cc3..0c9c718 100644 (file)
@@ -96,6 +96,7 @@ class SpecialPageFactory {
                'Block' => 'SpecialBlock',
                'Unblock' => 'SpecialUnblock',
                'BlockList' => 'SpecialBlockList',
+               'AutoblockList' => 'SpecialAutoblockList',
                'ChangePassword' => 'SpecialChangePassword',
                'BotPasswords' => 'SpecialBotPasswords',
                'PasswordReset' => 'SpecialPasswordReset',
@@ -504,7 +505,7 @@ class SpecialPageFactory {
         * @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 (file)
index 0000000..dcb2444
--- /dev/null
@@ -0,0 +1,152 @@
+<?php
+/**
+ * Implements Special:AutoblockList
+ *
+ * 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 autoblocks
+ *
+ * @since 1.29
+ * @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' ) );
+               $this->addHelpLink( 'Autoblock' );
+               $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 = [
+                       '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-localblocks',
+                                       $pager->getNumRows() )->parse() )
+                               . "\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';
+       }
+}
index b7078dd..32ec7bf 100644 (file)
        "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-localblocks": "Local {{PLURAL:$1|autoblock|autoblocks}}",
+       "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",
index a3e2a8c..2748f02 100644 (file)
        "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-localblocks": "[[File:Special AutoBlockList new.png|thumb|Example]]\nUsed on [[Special:AutoblockList]] as header when global autoblocks 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}}",
index b9280ea..e6aa109 100644 (file)
@@ -400,6 +400,7 @@ $specialPageAliases = [
        'ApiHelp'                   => [ 'ApiHelp' ],
        'ApiSandbox'                => [ 'ApiSandbox' ],
        'Ancientpages'              => [ 'AncientPages' ],
+       'AutoblockList'             => [ 'AutoblockList', 'ListAutoblocks' ],
        'Badtitle'                  => [ 'Badtitle' ],
        'Blankpage'                 => [ 'BlankPage' ],
        'Block'                     => [ 'Block', 'BlockIP', 'BlockUser' ],