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.php87
1 files changed, 58 insertions, 29 deletions
diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php
index c5aa2389..705dab55 100644
--- a/includes/specials/SpecialActiveusers.php
+++ b/includes/specials/SpecialActiveusers.php
@@ -50,7 +50,7 @@ class ActiveUsersPager extends UsersPager {
/**
* @param $context IContextSource
* @param $group null Unused
- * @param $par string Parameter passed to the page
+ * @param string $par Parameter passed to the page
*/
function __construct( IContextSource $context = null, $group = null, $par = null ) {
global $wgActiveUserDays;
@@ -62,7 +62,7 @@ class ActiveUsersPager extends UsersPager {
$this->requestedUser = '';
if ( $un != '' ) {
$username = Title::makeTitleSafe( NS_USER, $un );
- if( !is_null( $username ) ) {
+ if ( !is_null( $username ) ) {
$this->requestedUser = $username->getText();
}
}
@@ -91,39 +91,60 @@ class ActiveUsersPager extends UsersPager {
}
function getQueryInfo() {
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = $this->getDatabase();
+
$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 != ' . $dbr->addQuotes( 'newusers' );
- $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 ) );
+ $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes(
+ $dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge * 24 * 3600 ) );
- if( $this->requestedUser != '' ) {
+ if ( $this->requestedUser != '' ) {
$conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser );
}
- $query = array(
- 'tables' => array( 'recentchanges', 'user', 'ipblocks' ),
- 'fields' => array( 'user_name' => 'rc_user_text', // inheritance
+ if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+ $conds[] = 'NOT EXISTS (' . $dbr->selectSQLText(
+ 'ipblocks', '1', array( 'rc_user=ipb_user', 'ipb_deleted' => 1 )
+ ) . ')';
+ }
+
+ return array(
+ 'tables' => array( 'recentchanges' ),
+ 'fields' => array(
+ 'user_name' => 'rc_user_text', // for Pager inheritance
'rc_user_text', // for Pager
- 'user_id',
- 'recentedits' => 'COUNT(*)',
- 'blocked' => 'MAX(ipb_user)'
+ 'user_id' => 'MAX(rc_user)', // Postgres
+ 'recentedits' => 'COUNT(*)'
),
'options' => array(
- 'GROUP BY' => array( 'rc_user_text', 'user_id' ),
+ 'GROUP BY' => array( 'rc_user_text' ),
'USE INDEX' => array( 'recentchanges' => 'rc_user_text' )
),
- 'join_conds' => array(
- 'user' => array( 'INNER JOIN', 'rc_user_text=user_name' ),
- 'ipblocks' => array( 'LEFT JOIN', array(
- 'user_id=ipb_user',
- 'ipb_auto' => 0,
- 'ipb_deleted' => 1
- )),
- ),
'conds' => $conds
);
- return $query;
+ }
+
+ function doBatchLookups() {
+ $uids = array();
+ foreach ( $this->mResult as $row ) {
+ $uids[] = $row->user_id;
+ }
+ // Fetch the block status of the user for showing "(blocked)" text and for
+ // striking out names of suppressed users when privileged user views the list.
+ // Although the first query already hits the block table for un-privileged, this
+ // is done in two queries to avoid huge quicksorts and to make COUNT(*) correct.
+ $dbr = $this->getDatabase();
+ $res = $dbr->select( 'ipblocks',
+ array( 'ipb_user', 'MAX(ipb_deleted) AS block_status' ),
+ array( 'ipb_user' => $uids ),
+ __METHOD__,
+ array( 'GROUP BY' => array( 'ipb_user' ) )
+ );
+ $this->blockStatusByUid = array();
+ foreach ( $res as $row ) {
+ $this->blockStatusByUid[$row->ipb_user] = $row->block_status; // 0 or 1
+ }
+ $this->mResult->seek( 0 );
}
function formatRow( $row ) {
@@ -138,7 +159,7 @@ class ActiveUsersPager extends UsersPager {
$user = User::newFromId( $row->user_id );
// User right filter
- foreach( $this->hideRights as $right ) {
+ 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
@@ -152,7 +173,7 @@ class ActiveUsersPager extends UsersPager {
// 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 ) {
+ foreach ( $user->getGroups() as $group ) {
if ( in_array( $group, $this->hideGroups ) ) {
return '';
}
@@ -162,9 +183,14 @@ class ActiveUsersPager extends UsersPager {
$groups = $lang->commaList( $list );
$item = $lang->specialList( $ulinks, $groups );
+
+ $isBlocked = isset( $this->blockStatusByUid[$row->user_id] );
+ if ( $isBlocked && $this->blockStatusByUid[$row->user_id] == 1 ) {
+ $item = "<span class=\"deleted\">$item</span>";
+ }
$count = $this->msg( 'activeusers-count' )->numParams( $row->recentedits )
->params( $userName )->numParams( $this->RCMaxAge )->escaped();
- $blocked = $row->blocked ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
+ $blocked = $isBlocked ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" );
}
@@ -180,15 +206,15 @@ class ActiveUsersPager extends UsersPager {
$out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
$out .= Xml::inputLabel( $this->msg( 'activeusers-from' )->text(),
- 'username', 'offset', 20, $this->requestedUser ) . '<br />';# Username field
+ 'username', 'offset', 20, $this->requestedUser, array( 'tabindex' => 1 ) ) . '<br />';# Username field
$out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(),
- 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ) );
+ 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ), array( 'tabindex' => 2 ) );
$out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(),
- 'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ) ) . '<br />';
+ 'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ), array( 'tabindex' => 3 ) ) . '<br />';
- $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n";# Submit button and form bottom
+ $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text(), array( 'tabindex' => 4 ) ) . "\n";# Submit button and form bottom
$out .= Xml::closeElement( 'fieldset' );
$out .= Xml::closeElement( 'form' );
@@ -240,4 +266,7 @@ class SpecialActiveUsers extends SpecialPage {
}
}
+ protected function getGroupName() {
+ return 'users';
+ }
}