From a23cbbba12cd981c7a5b8f1f4f31317d8db832b0 Mon Sep 17 00:00:00 2001 From: Platonides Date: Sun, 13 May 2012 15:51:28 +0200 Subject: [PATCH] (bug 36812) SpecialActiveUsers: Use right instead of group for bots. Test with: * $wgGroupPermissions['script'] = $wgGroupPermissions['bot']; * Add a user to it that made an edit recently * With this fix it will be hidden on SpecialActiveUsers?hidebots=1 without it will remain visible. Change-Id: Ie0b88d7982a3d111c6ba6c456cfc02229f1339df --- RELEASE-NOTES-1.20 | 2 ++ includes/specials/SpecialActiveusers.php | 34 +++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 709f2ea0e9..bc04a8d94a 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -130,6 +130,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * (bug 37708) mw.Uri.clone() should make a deep copy. * (bug 38024) ResourceLoader should not create empty stylesheets for modules that don't have stylesheets. +* (bug 36812) Special:ActiveUsers "Hide bots" should hide users from any group + having the "bot" user right, instead of just the default "bot" user group. === API changes in 1.20 === * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API. diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 06a4694219..156b5f2d5b 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -40,7 +40,12 @@ class ActiveUsersPager extends UsersPager { /** * @var Array */ - protected $groups; + protected $hideGroups = array(); + + /** + * @var Array + */ + protected $hideRights = array(); /** * @param $context IContextSource @@ -73,12 +78,11 @@ class ActiveUsersPager extends UsersPager { $this->opts->fetchValuesFromRequest( $this->getRequest() ); - $this->groups = array(); if ( $this->opts->getValue( 'hidebots' ) == 1 ) { - $this->groups['bot'] = true; + $this->hideRights[] = 'bot'; } if ( $this->opts->getValue( 'hidesysops' ) == 1 ) { - $this->groups['sysop'] = true; + $this->hideGroups[] = 'sysop'; } } @@ -127,12 +131,30 @@ class ActiveUsersPager extends UsersPager { $lang = $this->getLanguage(); $list = array(); - foreach( self::getGroups( $row->user_id ) as $group ) { - if ( isset( $this->groups[$group] ) ) { + $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 + foreach( $user->getGroups() as $group ) { + if ( in_array( $group, $this->hideGroups ) ) { return ''; } $list[] = self::buildGroupLink( $group, $userName ); } + $groups = $lang->commaList( $list ); $item = $lang->specialList( $ulinks, $groups ); -- 2.20.1