From 2d78b8d44eaa8109d6c1e8371fd3eca857bd2e80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 18 Nov 2016 15:39:00 +0100 Subject: [PATCH] SpecialActiveUsers: Allow excluding groups too Also restore support for old 'hidebots' and 'hidesysops' options. Bug: T116354 Change-Id: I68887509c3dbf74598a1af82623b9f0f5a1ab43d --- includes/specials/SpecialActiveusers.php | 24 ++++++++++++++++++- includes/specials/pagers/ActiveUsersPager.php | 15 ++++++++++++ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 531c330328..7e29be0a29 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -52,6 +52,10 @@ class SpecialActiveUsers extends SpecialPage { $opts->add( 'username', '' ); $opts->add( 'groups', [] ); + $opts->add( 'excludegroups', [] ); + // Backwards-compatibility with old URLs + $opts->add( 'hidebots', false, FormOptions::BOOL ); + $opts->add( 'hidesysops', false, FormOptions::BOOL ); $opts->fetchValuesFromRequest( $this->getRequest() ); @@ -86,13 +90,22 @@ class SpecialActiveUsers extends SpecialPage { $options[$msg] = $group; } + // Backwards-compatibility with old URLs + $req = $this->getRequest(); + $excludeDefault = []; + if ( $req->getCheck( 'hidebots' ) ) { + $excludeDefault[] = 'bot'; + } + if ( $req->getCheck( 'hidesysops' ) ) { + $excludeDefault[] = 'sysop'; + } + $formDescriptor = [ 'username' => [ 'type' => 'user', 'name' => 'username', 'label-message' => 'activeusers-from', ], - 'groups' => [ 'type' => 'multiselect', 'dropdown' => true, @@ -101,6 +114,15 @@ class SpecialActiveUsers extends SpecialPage { 'label-message' => 'activeusers-groups', 'options' => $options, ], + 'excludegroups' => [ + 'type' => 'multiselect', + 'dropdown' => true, + 'flatlist' => true, + 'name' => 'excludegroups', + 'label-message' => 'activeusers-excludegroups', + 'options' => $options, + 'default' => $excludeDefault, + ], ]; HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ) diff --git a/includes/specials/pagers/ActiveUsersPager.php b/includes/specials/pagers/ActiveUsersPager.php index ea906b7d50..645a115041 100644 --- a/includes/specials/pagers/ActiveUsersPager.php +++ b/includes/specials/pagers/ActiveUsersPager.php @@ -64,6 +64,14 @@ class ActiveUsersPager extends UsersPager { } $this->groups = $opts->getValue( 'groups' ); + $this->excludegroups = $opts->getValue( 'excludegroups' ); + // Backwards-compatibility with old URLs + if ( $opts->getValue( 'hidebots' ) ) { + $this->excludegroups[] = 'bot'; + } + if ( $opts->getValue( 'hidesysops' ) ) { + $this->excludegroups[] = 'sysop'; + } } function getIndexField() { @@ -94,6 +102,13 @@ class ActiveUsersPager extends UsersPager { $conds[] = 'ug_user = user_id'; $conds['ug_group'] = $this->groups; } + if ( $this->excludegroups !== [] ) { + foreach ( $this->excludegroups as $group ) { + $conds[] = 'NOT EXISTS (' . $dbr->selectSQLText( + 'user_groups', '1', [ 'ug_user = user_id', 'ug_group' => $group ] + ) . ')'; + } + } if ( !$this->getUser()->isAllowed( 'hideuser' ) ) { $conds[] = 'NOT EXISTS (' . $dbr->selectSQLText( 'ipblocks', '1', [ 'ipb_user=user_id', 'ipb_deleted' => 1 ] diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 719f304bf3..28ccbf3d81 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2001,6 +2001,7 @@ "activeusers-count": "$1 {{PLURAL:$1|action|actions}} in the last {{PLURAL:$3|day|$3 days}}", "activeusers-from": "Display users starting at:", "activeusers-groups": "Display users belonging to groups:", + "activeusers-excludegroups": "Exclude users belonging to groups:", "activeusers-noresult": "No users found.", "activeusers-submit": "Display active users", "listgrouprights": "User group rights", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 07b55f957a..e1b6c9b67f 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2185,6 +2185,7 @@ "activeusers-count": "Used in [[Special:ActiveUsers]] to show the active user's recent action count in brackets ([]).\n* $1 is the number of recent actions\n* $2 is the user's name for use with GENDER (optional)\n* $3 is the maximum number of days of the RecentChangesList", "activeusers-from": "Used as label for checkbox in the form on [[Special:ActiveUsers]].\n\nidentical with {{msg-mw|listusersfrom}}\n\nSee also:\n* {{msg-mw|activeusers|legend for the form}}", "activeusers-groups": "Used as label on [[Special:ActiveUsers]].", + "activeusers-excludegroups": "Used as an option on [[Special:ActiveUsers]].", "activeusers-noresult": "identical with {{msg-mw|listusers-noresult}}", "activeusers-submit": "Used as label for button in the form on [[Special:ActiveUsers]]", "listgrouprights": "The name of the special page [[Special:ListGroupRights]].", -- 2.20.1