Niharika29 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/355805 )

Change subject: Show total number of autoblocks on top of Special:AutoblockList
......................................................................

Show total number of autoblocks on top of Special:AutoblockList

Bug: T163172
Change-Id: I51b1b7675c2f4ed68ccb725230ffecf3583cf65f
---
M includes/specials/SpecialAutoblockList.php
M includes/specials/pagers/BlockListPager.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 39 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/05/355805/1

diff --git a/includes/specials/SpecialAutoblockList.php 
b/includes/specials/SpecialAutoblockList.php
index dcb2444..72ab117 100644
--- a/includes/specials/SpecialAutoblockList.php
+++ b/includes/specials/SpecialAutoblockList.php
@@ -78,6 +78,7 @@
                        ->prepareForm()
                        ->displayForm( false );
 
+               $this->showTotal( $pager );
                $this->showList( $pager );
        }
 
@@ -98,6 +99,20 @@
        }
 
        /**
+        * Show total number of autoblocks on top of the table
+        *
+        * @param BlockListPager $pager The BlockListPager instance for this 
page
+        */
+       protected function showTotal( BlockListPager $pager ) {
+               $out = $this->getOutput();
+               $out->addHTML(
+                       Html::element( 'h5', [],
+                               $this->msg( 'autoblocklist-total-autoblocks', 
$pager->getTotalAutoblocks() )->parse() )
+                       . "\n"
+               );
+       }
+
+       /**
         * Show the list of blocked accounts matching the actual filter.
         * @param BlockListPager $pager The BlockListPager instance for this 
page
         */
diff --git a/includes/specials/pagers/BlockListPager.php 
b/includes/specials/pagers/BlockListPager.php
index 9a447ef..8ae07d8 100644
--- a/includes/specials/pagers/BlockListPager.php
+++ b/includes/specials/pagers/BlockListPager.php
@@ -246,6 +246,28 @@
                return $info;
        }
 
+       /**
+        * Get total number of autoblocks at any given time
+        *
+        * @return int Total number of unexpired active autoblocks
+        */
+       function getTotalAutoblocks() {
+               $dbr = $this->getDatabase();
+               $res = $dbr->select( 'ipblocks',
+                       [ 'COUNT(*) AS totalautoblocks' ],
+                       [
+                               'ipb_auto' => '1',
+                               'ipb_expiry >= ' . $dbr->addQuotes( 
$dbr->timestamp() ),
+                       ]
+               );
+               foreach ( $res as $row ) {
+                       if ( $row->totalautoblocks ) {
+                               return $row->totalautoblocks; // Total number 
of autoblocks
+                       }
+               }
+               return 0; // We found nothing
+       }
+
        protected function getTableClass() {
                return parent::getTableClass() . ' mw-blocklist';
        }
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index cc60432..a0efd05 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -2497,6 +2497,7 @@
        "autoblocklist-submit": "Search",
        "autoblocklist-legend": "List autoblocks",
        "autoblocklist-localblocks": "Local {{PLURAL:$1|autoblock|autoblocks}}",
+       "autoblocklist-total-autoblocks": "Total number of autoblocks: $1",
        "autoblocklist-empty": "The autoblock list is empty.",
        "autoblocklist-otherblocks": "Other {{PLURAL:$1|autoblock|autoblocks}}",
        "ipblocklist": "Blocked users",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 694ef74..7b7f27f 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2686,6 +2686,7 @@
        "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-total-autoblocks": "Shows the total number of active 
autoblocks on [[Special:AutoblockList]]. Parameters:\n* $1 - number of 
autoblocks",
        "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}}",

-- 
To view, visit https://gerrit.wikimedia.org/r/355805
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I51b1b7675c2f4ed68ccb725230ffecf3583cf65f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <nko...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to