protected $opts;
/**
- * @var array
- */
- protected $hideGroups = [];
-
- /**
- * @var array
+ * @var string[]
*/
- protected $hideRights = [];
+ protected $groups;
/**
* @var array
}
}
- 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';
}
}
$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,
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 ]
}
return [
- 'tables' => [ 'querycachetwo', 'user', 'recentchanges' ],
+ 'tables' => $tables,
'fields' => [ 'user_name', 'user_id', 'recentedits' => 'COUNT(*)', 'qcc_title' ],
'options' => $options,
'conds' => $conds
$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 );
}