From: Sam Reed Date: Tue, 4 Jan 2011 02:06:55 +0000 (+0000) Subject: Rest of * (bug 25767) Add userrights properties to allusers and users query lists X-Git-Tag: 1.31.0-rc.0~32842 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=58df1dc8956e241fcf47cbd50c2c90479193bba0;p=lhc%2Fweb%2Fwiklou.git Rest of * (bug 25767) Add userrights properties to allusers and users query lists Add missing parameter from r79545 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fcf713f757..69a5d88e5e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -66,6 +66,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Add a &watchuser option to ApiBlock * (bug 26541) Generator-ise ApiQueryRecentChanges * action=parse now correctly returns an error for nonexistent pages +* (bug 25767) Add userrights properties to allusers and users query lists === Languages updated in 1.18 === diff --git a/includes/User.php b/includes/User.php index 4bada328ba..bafa5410cd 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3131,14 +3131,18 @@ class User { * non-existent/anonymous user accounts. */ public function getFirstEditTimestamp() { - if( $this->getId() == 0 ) return false; // anons + if( $this->getId() == 0 ) { + return false; // anons + } $dbr = wfGetDB( DB_SLAVE ); $time = $dbr->selectField( 'revision', 'rev_timestamp', array( 'rev_user' => $this->getId() ), __METHOD__, array( 'ORDER BY' => 'rev_timestamp ASC' ) ); - if( !$time ) return false; // no edits + if( !$time ) { + return false; // no edits + } return wfTimestamp( TS_MW, $time ); } diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index aee4212fd1..4e090e017c 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -71,6 +71,21 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addWhere( 'u1.user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); } + if ( !is_null( $params['rights'] ) ) { + $groups = array(); + foreach( $params['rights'] as $r ) { + $groups = array_merge( $groups, User::getGroupsWithPermission( $r ) ); + } + + $groups = array_diff( array_unique( $groups ), User::getImplicitGroups() ); + + if ( is_null( $params['group'] ) ) { + $params['group'] = $groups; + } else { + $params['group'] = array_unique( array_merge( $params['group'], $groups ) ); + } + } + if ( !is_null( $params['group'] ) ) { $useIndex = false; // Filter only users that belong to a given group @@ -222,7 +237,12 @@ class ApiQueryAllUsers extends ApiQueryBase { 'to' => null, 'prefix' => null, 'group' => array( - ApiBase::PARAM_TYPE => User::getAllGroups() + ApiBase::PARAM_TYPE => User::getAllGroups(), + ApiBase::PARAM_ISMULTI => true, + ), + 'rights' => array( + ApiBase::PARAM_TYPE => User::getAllRights(), + ApiBase::PARAM_ISMULTI => true, ), 'prop' => array( ApiBase::PARAM_ISMULTI => true, @@ -249,12 +269,13 @@ 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', - 'group' => 'Limit users to a given group name', + 'group' => 'Limit users to given group name(s)', + 'rights' => 'Limit users to given right(s)', 'prop' => array( 'What pieces of information to include.', ' blockinfo - Adds the information about a current block on the user', ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit', - ' rights - Lists groups that the user has', + ' rights - Lists rights that the user has', ' editcount - Adds the edit count of the user', ' registration - Adds the timestamp of when the user registered', ),