SpecialActiveUsers: Allow excluding groups too
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 18 Nov 2016 14:39:00 +0000 (15:39 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 21 Nov 2016 19:21:37 +0000 (19:21 +0000)
Also restore support for old 'hidebots' and 'hidesysops' options.

Bug: T116354
Change-Id: I68887509c3dbf74598a1af82623b9f0f5a1ab43d

includes/specials/SpecialActiveusers.php
includes/specials/pagers/ActiveUsersPager.php
languages/i18n/en.json
languages/i18n/qqq.json

index 531c330..7e29be0 100644 (file)
@@ -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() )
index ea906b7..645a115 100644 (file)
@@ -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 ]
index 719f304..28ccbf3 100644 (file)
        "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",
index 07b55f9..e1b6c9b 100644 (file)
        "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]].",