X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryAllUsers.php;h=e110e6770b02fa3cc0c5fc025ce196bcec200bc9;hb=3d58f903d84426658300d17da5ccd0e1f2557de5;hp=3c19c18cb1c57bbfff4d654bed2bbdc033db37ae;hpb=6cf8cd357ec0370fdfafc8e2056a555b930a5d70;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 3c19c18cb1..e110e6770b 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -34,6 +34,16 @@ class ApiQueryAllUsers extends ApiQueryBase { parent::__construct( $query, $moduleName, 'au' ); } + /** + * This function converts the user name to a canonical form + * which is stored in the database. + * @param String $name + * @return String + */ + private function getCanonicalUserName( $name ) { + return str_replace( '_', ' ', $name ); + } + public function execute() { $db = $this->getDB(); $params = $this->extractRequestParams(); @@ -57,8 +67,8 @@ class ApiQueryAllUsers extends ApiQueryBase { $useIndex = true; $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); - $from = is_null( $params['from'] ) ? null : $this->keyToTitle( $params['from'] ); - $to = is_null( $params['to'] ) ? null : $this->keyToTitle( $params['to'] ); + $from = is_null( $params['from'] ) ? null : $this->getCanonicalUserName( $params['from'] ); + $to = is_null( $params['to'] ) ? null : $this->getCanonicalUserName( $params['to'] ); # MySQL doesn't seem to use 'equality propagation' here, so like the # ActiveUsers special page, we have to use rc_user_text for some cases. @@ -68,7 +78,7 @@ class ApiQueryAllUsers extends ApiQueryBase { if ( !is_null( $params['prefix'] ) ) { $this->addWhere( $userFieldToSort . - $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); + $db->buildLike( $this->getCanonicalUserName( $params['prefix'] ), $db->anyString() ) ); } if ( !is_null( $params['rights'] ) ) { @@ -144,9 +154,9 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addFields( 'COUNT(*) AS recentedits' ); - $this->addWhere( "rc_log_type IS NULL OR rc_log_type != 'newusers'" ); + $this->addWhere( 'rc_log_type IS NULL OR rc_log_type != ' . $db->addQuotes( 'newusers' ) ); $timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays*24*3600 ); - $this->addWhere( "rc_timestamp >= {$db->addQuotes( $timestamp )}" ); + $this->addWhere( 'rc_timestamp >= ' . $db->addQuotes( $timestamp ) ); $this->addOption( 'GROUP BY', $userFieldToSort ); } @@ -208,7 +218,9 @@ class ApiQueryAllUsers extends ApiQueryBase { 'name' => $lastUser, ); if ( $fld_blockinfo && !is_null( $row->ipb_by_text ) ) { + $lastUserData['blockid'] = $row->ipb_id; $lastUserData['blockedby'] = $row->ipb_by_text; + $lastUserData['blockedbyid'] = $row->ipb_by; $lastUserData['blockreason'] = $row->ipb_reason; $lastUserData['blockexpiry'] = $row->ipb_expiry; } @@ -349,7 +361,7 @@ class ApiQueryAllUsers extends ApiQueryBase { 'dir' => 'Direction to sort in', 'group' => 'Limit users to given group name(s)', 'excludegroup' => 'Exclude users in given group name(s)', - 'rights' => 'Limit users to given right(s)', + 'rights' => 'Limit users to given right(s) (does not include rights granted by implicit or auto-promoted groups like *, user, or autoconfirmed)', 'prop' => array( 'What pieces of information to include.', ' blockinfo - Adds the information about a current block on the user',