From cb94b8f19133cbe45ff7b46045c15f94d90d2ec0 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 13 Mar 2011 17:23:45 +0000 Subject: [PATCH] * (bug 27342) Add audir param to list=allusers --- RELEASE-NOTES | 1 + includes/api/ApiQueryAllUsers.php | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 640d5e9da2..7a01d9c8a6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -249,6 +249,7 @@ PHP if you have not done so prior to upgrading MediaWiki. * (bug 27182) API: Add filter by prefix for meta=allmessages * (bug 27183) API: Add filter by customisation state for meta=allmessages * (bug 27340) API: Allow listing of "small" categories +* (bug 27342) Add audir param to list=allusers === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 6906aa260a..650c50cc3a 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -59,12 +59,11 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addTables( 'user' ); $useIndex = true; - if ( !is_null( $params['from'] ) ) { - $this->addWhere( 'user_name >= ' . $db->addQuotes( $this->keyToTitle( $params['from'] ) ) ); - } - if ( !is_null( $params['to'] ) ) { - $this->addWhere( 'user_name <= ' . $db->addQuotes( $this->keyToTitle( $params['to'] ) ) ); - } + $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'] ); + + $this->addWhereRange( 'user_name', $dir, $from, $to ); if ( !is_null( $params['prefix'] ) ) { $this->addWhere( 'user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); @@ -123,7 +122,6 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addFieldsIf( 'user_editcount', $fld_editcount ); $this->addFieldsIf( 'user_registration', $fld_registration ); - $this->addOption( 'ORDER BY', 'user_name' ); if ( $useIndex ) { $this->addOption( 'USE INDEX', array( 'user' => 'user_name' ) ); } @@ -239,6 +237,13 @@ class ApiQueryAllUsers extends ApiQueryBase { 'from' => null, 'to' => null, 'prefix' => null, + 'dir' => array( + ApiBase::PARAM_DFLT => 'ascending', + ApiBase::PARAM_TYPE => array( + 'ascending', + 'descending' + ), + ), 'group' => array( ApiBase::PARAM_TYPE => User::getAllGroups(), ApiBase::PARAM_ISMULTI => true, @@ -273,6 +278,7 @@ class ApiQueryAllUsers extends ApiQueryBase { 'from' => 'The user name to start enumerating from', 'to' => 'The user name to stop enumerating at', 'prefix' => 'Search for all users that begin with this value', + 'dir' => 'Direction to sort in', 'group' => 'Limit users to given group name(s)', 'rights' => 'Limit users to given right(s)', 'prop' => array( -- 2.20.1