X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=inline;f=includes%2Fspecials%2Fpagers%2FActiveUsersPager.php;h=645a1150413efb237ebbac3289a4b046de0dc8a3;hb=892b17237bb44630fa6f508c5bf85374a62def13;hp=73ab0ad729dae0e336c02430b4bdcf3cda2e7de6;hpb=6fcabeeb0b400b0d2987b6c934e6c1b591e7b486;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/pagers/ActiveUsersPager.php b/includes/specials/pagers/ActiveUsersPager.php index 73ab0ad729..645a115041 100644 --- a/includes/specials/pagers/ActiveUsersPager.php +++ b/includes/specials/pagers/ActiveUsersPager.php @@ -36,14 +36,9 @@ class ActiveUsersPager extends UsersPager { protected $opts; /** - * @var array - */ - protected $hideGroups = []; - - /** - * @var array + * @var string[] */ - protected $hideRights = []; + protected $groups; /** * @var array @@ -68,11 +63,14 @@ class ActiveUsersPager extends UsersPager { } } - if ( $opts->getValue( 'hidebots' ) == 1 ) { - $this->hideRights[] = 'bot'; + $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' ) == 1 ) { - $this->hideGroups[] = 'sysop'; + if ( $opts->getValue( 'hidesysops' ) ) { + $this->excludegroups[] = 'sysop'; } } @@ -85,6 +83,7 @@ class ActiveUsersPager extends UsersPager { $activeUserSeconds = $this->getConfig()->get( 'ActiveUserDays' ) * 86400; $timestamp = $dbr->timestamp( wfTimestamp( TS_UNIX ) - $activeUserSeconds ); + $tables = [ 'querycachetwo', 'user', 'recentchanges' ]; $conds = [ 'qcc_type' => 'activeusers', 'qcc_namespace' => NS_USER, @@ -98,6 +97,18 @@ class ActiveUsersPager extends UsersPager { if ( $this->requestedUser != '' ) { $conds[] = 'qcc_title >= ' . $dbr->addQuotes( $this->requestedUser ); } + if ( $this->groups !== [] ) { + $tables[] = 'user_groups'; + $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 ] @@ -111,7 +122,7 @@ class ActiveUsersPager extends UsersPager { } return [ - 'tables' => [ 'querycachetwo', 'user', 'recentchanges' ], + 'tables' => $tables, 'fields' => [ 'user_name', 'user_id', 'recentedits' => 'COUNT(*)', 'qcc_title' ], 'options' => $options, 'conds' => $conds @@ -154,26 +165,8 @@ class ActiveUsersPager extends UsersPager { $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 ); }