Sethakill has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/288197

Change subject: Change checkboxes to dropdown.
......................................................................

Change checkboxes to dropdown.

Moved form to new function and
fixed text about cached version.

Bug: T116354
Change-Id: I29ae63472536f99f7f9546f30d86e7bd324d3094
---
M includes/specials/SpecialActiveusers.php
M includes/specials/pagers/ActiveUsersPager.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 56 insertions(+), 72 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/97/288197/1

diff --git a/includes/specials/SpecialActiveusers.php 
b/includes/specials/SpecialActiveusers.php
index c697ca7..bc0e52a 100644
--- a/includes/specials/SpecialActiveusers.php
+++ b/includes/specials/SpecialActiveusers.php
@@ -30,6 +30,9 @@
  */
 class SpecialActiveUsers extends SpecialPage {
 
+       /** @var string */
+       protected $mCacheText;
+
        /**
         * Constructor
         */
@@ -51,8 +54,7 @@
                $opts = new FormOptions();
 
                $opts->add( 'username', '' );
-               $opts->add( 'hidebots', false, FormOptions::BOOL );
-               $opts->add( 'hidesysops', false, FormOptions::BOOL );
+               $opts->add( 'group', '' );
 
                $opts->fetchValuesFromRequest( $this->getRequest() );
 
@@ -77,45 +79,17 @@
                                $secondsOld = time() - wfTimestamp( TS_UNIX, 
$rcMin );
                        }
                        if ( $secondsOld > 0 ) {
-                               $cacheTxt = '<br>' . $this->msg( 
'cachedspecial-viewing-cached-ttl' )
-                                       ->durationParams( $secondsOld );
+                               $cacheText = $this->msg( 
'cachedspecial-viewing-cached-ttl' )
+                                       ->durationParams( $secondsOld 
)->parseAsBlock();
                        }
                }
+
+               $this->mCacheText = $cacheText;
 
                $pager = new ActiveUsersPager( $this->getContext(), $opts );
                $usersBody = $pager->getBody();
 
-               $days = $this->getConfig()->get( 'ActiveUserDays' );
-
-               $formDescriptor = [
-                       'username' => [
-                               'type' => 'user',
-                               'name' => 'username',
-                               'label-message' => 'activeusers-from',
-                       ],
-
-                       'hidebots' => [
-                               'type' => 'check',
-                               'name' => 'hidebots',
-                               'label-message' => 'activeusers-hidebots',
-                               'default' => false,
-                       ],
-
-                       'hidesysops' => [
-                               'type' => 'check',
-                               'name' => 'hidesysops',
-                               'label-message' => 'activeusers-hidesysops',
-                               'default' => false,
-                       ],
-               ];
-
-               $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 
$this->getContext() )
-                       ->setIntro( $this->msg( 'activeusers-intro' 
)->numParams( $days ) . $cacheText )
-                       ->setWrapperLegendMsg( 'activeusers' )
-                       ->setSubmitTextMsg( 'activeusers-submit' )
-                       ->setMethod( 'get' )
-                       ->prepareForm()
-                       ->displayForm( false );
+               $this->buildForm();
 
                if ( $usersBody ) {
                        $out->addHTML(
@@ -128,6 +102,44 @@
                }
        }
 
+       function buildForm() {
+               $days = $this->getConfig()->get( 'ActiveUserDays' );
+               $groups = User::getAllGroups();
+               $options = [
+                       'all' => '',
+               ];
+
+               foreach ( $groups as $group ) {
+                       $msg = User::getGroupName( $group );
+                       $options[$msg] = $group;
+               }
+
+               $formDescriptor = [
+                       'username' => [
+                               'type' => 'user',
+                               'name' => 'username',
+                               'label-message' => 'activeusers-from',
+                       ],
+
+                       'group' => [
+                               'type' => 'select',
+                               'name' => 'group',
+                               'label-message' => 'group',
+                               'options' => $options,
+                       ],
+               ];
+
+               $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 
$this->getContext() )
+                       ->setIntro( $this->msg( 'activeusers-intro' 
)->numParams( $days ) . $this->mCacheText )
+                       ->setWrapperLegendMsg( 'activeusers' )
+                       ->setSubmitTextMsg( 'activeusers-submit' )
+                       // prevent setting subpage and 'username' parameter at 
the same time
+                       ->setAction( $this->getPageTitle()->getLocalURL() )
+                       ->setMethod( 'get' )
+                       ->prepareForm()
+                       ->displayForm( false );
+       }
+
        protected function getGroupName() {
                return 'users';
        }
diff --git a/includes/specials/pagers/ActiveUsersPager.php 
b/includes/specials/pagers/ActiveUsersPager.php
index 73ab0ad..4a9d427 100644
--- a/includes/specials/pagers/ActiveUsersPager.php
+++ b/includes/specials/pagers/ActiveUsersPager.php
@@ -36,14 +36,9 @@
        protected $opts;
 
        /**
-        * @var array
+        * @var string
         */
-       protected $hideGroups = [];
-
-       /**
-        * @var array
-        */
-       protected $hideRights = [];
+       protected $group;
 
        /**
         * @var array
@@ -68,12 +63,7 @@
                        }
                }
 
-               if ( $opts->getValue( 'hidebots' ) == 1 ) {
-                       $this->hideRights[] = 'bot';
-               }
-               if ( $opts->getValue( 'hidesysops' ) == 1 ) {
-                       $this->hideGroups[] = 'sysop';
-               }
+               $this->group = $opts->getValue( 'group' );
        }
 
        function getIndexField() {
@@ -98,6 +88,10 @@
                if ( $this->requestedUser != '' ) {
                        $conds[] = 'qcc_title >= ' . $dbr->addQuotes( 
$this->requestedUser );
                }
+               if ( $this->group != '' ) {
+                       $conds[] = 'ug_user = user_id';
+                       $conds[] = 'ug_group = ' . $dbr->addQuotes( 
$this->group );
+               }
                if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
                        $conds[] = 'NOT EXISTS (' . $dbr->selectSQLText(
                                        'ipblocks', '1', [ 'ipb_user=user_id', 
'ipb_deleted' => 1 ]
@@ -111,7 +105,7 @@
                }
 
                return [
-                       'tables' => [ 'querycachetwo', 'user', 'recentchanges' 
],
+                       'tables' => [ 'querycachetwo', 'user', 'user_groups', 
'recentchanges' ],
                        'fields' => [ 'user_name', 'user_id', 'recentedits' => 
'COUNT(*)', 'qcc_title' ],
                        'options' => $options,
                        'conds' => $conds
@@ -154,26 +148,8 @@
                $list = [];
                $user = User::newFromId( $row->user_id );
 
-               // User right filter
-               foreach ( $this->hideRights as $right ) {
-                       // Calling User::getRights() within the loop so that
-                       // if the hideRights() filter is empty, we don't have to
-                       // trigger the lazy-init of the big userrights array in 
the
-                       // User object
-                       if ( in_array( $right, $user->getRights() ) ) {
-                               return '';
-                       }
-               }
-
-               // User group filter
-               // Note: This is a different loop than for user rights,
-               // because we're reusing it to build the group links
-               // at the same time
                $groups_list = self::getGroups( intval( $row->user_id ), 
$this->userGroupCache );
                foreach ( $groups_list as $group ) {
-                       if ( in_array( $group, $this->hideGroups ) ) {
-                               return '';
-                       }
                        $list[] = self::buildGroupLink( $group, $userName );
                }
 
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index e7fa4c7..9864827 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1955,8 +1955,6 @@
        "activeusers-intro": "This is a list of users who had some kind of 
activity within the last $1 {{PLURAL:$1|day|days}}.",
        "activeusers-count": "$1 {{PLURAL:$1|action|actions}} in the last 
{{PLURAL:$3|day|$3 days}}",
        "activeusers-from": "Display users starting at:",
-       "activeusers-hidebots": "Hide bots",
-       "activeusers-hidesysops": "Hide administrators",
        "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 2faea55..731bef0 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2132,9 +2132,7 @@
        "activeusers-summary": "{{doc-specialpagesummary|activeusers}}",
        "activeusers-intro": "Used as introduction in [[Special:ActiveUsers]]. 
Parameters:\n* $1 - number of days (<code>$wgActiveUserDays</code>)",
        "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}}\n* 
{{msg-mw|activeusers-hidebots|label for checkbox}}\n* 
{{msg-mw|activeusers-hidesysops|label for checkbox}}",
-       "activeusers-hidebots": "Used as label for checkbox in the form on 
[[Special:ActiveUsers]].\n\nSee also:\n* {{msg-mw|activeusers|legend for the 
form}}\n* {{msg-mw|activeusers-from|label for input box}}\n* 
{{msg-mw|activeusers-hidesysops|label for checkbox}}",
-       "activeusers-hidesysops": "Used as label for checkbox in the form on 
[[Special:ActiveUsers]].\n\nSee also:\n* {{msg-mw|activeusers|legend for the 
form}}\n* {{msg-mw|activeusers-from|label for input box}}\n* 
{{msg-mw|activeusers-hidebots|label for checkbox}}",
+       "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-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]].",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I29ae63472536f99f7f9546f30d86e7bd324d3094
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sethakill <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to