summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialActiveusers.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialActiveusers.php')
-rw-r--r--includes/specials/SpecialActiveusers.php54
1 files changed, 40 insertions, 14 deletions
diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php
index 617a8026..c5aa2389 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';
}
}
@@ -90,8 +94,8 @@ class ActiveUsersPager extends UsersPager {
$dbr = wfGetDB( DB_SLAVE );
$conds = array( 'rc_user > 0' ); // Users - no anons
$conds[] = 'ipb_deleted IS NULL'; // don't show hidden names
- $conds[] = "rc_log_type IS NULL OR rc_log_type != 'newusers'";
- $conds[] = "rc_timestamp >= '{$dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 )}'";
+ $conds[] = 'rc_log_type IS NULL OR rc_log_type != ' . $dbr->addQuotes( 'newusers' );
+ $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 ) );
if( $this->requestedUser != '' ) {
$conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser );
@@ -99,19 +103,23 @@ class ActiveUsersPager extends UsersPager {
$query = array(
'tables' => array( 'recentchanges', 'user', 'ipblocks' ),
- 'fields' => array( 'rc_user_text AS user_name', // inheritance
+ 'fields' => array( 'user_name' => 'rc_user_text', // inheritance
'rc_user_text', // for Pager
'user_id',
- 'COUNT(*) AS recentedits',
- 'MAX(ipb_user) AS blocked'
+ 'recentedits' => 'COUNT(*)',
+ 'blocked' => 'MAX(ipb_user)'
),
'options' => array(
- 'GROUP BY' => 'rc_user_text, user_id',
+ 'GROUP BY' => array( 'rc_user_text', 'user_id' ),
'USE INDEX' => array( 'recentchanges' => 'rc_user_text' )
),
'join_conds' => array(
'user' => array( 'INNER JOIN', 'rc_user_text=user_name' ),
- 'ipblocks' => array( 'LEFT JOIN', 'user_id=ipb_user AND ipb_auto=0 AND ipb_deleted=1' ),
+ 'ipblocks' => array( 'LEFT JOIN', array(
+ 'user_id=ipb_user',
+ 'ipb_auto' => 0,
+ 'ipb_deleted' => 1
+ )),
),
'conds' => $conds
);
@@ -127,12 +135,30 @@ class ActiveUsersPager extends UsersPager {
$lang = $this->getLanguage();
$list = array();
- foreach( self::getGroups( $row->user_id ) as $group ) {
- if ( isset( $this->groups[$group] ) ) {
- return;
+ $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 );