Index: trunk/phase3/includes/api/ApiQueryAllUsers.php |
— | — | @@ -85,6 +85,10 @@ |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
| 89 | + if ( !is_null( $params['group'] ) && !is_null( $params['excludegroup'] ) ) { |
| 90 | + $this->dieUsage( 'group and excludegroup cannot be used together', 'group-excludegroup' ); |
| 91 | + } |
| 92 | + |
89 | 93 | if ( !is_null( $params['group'] ) && count( $params['group'] ) ) { |
90 | 94 | $useIndex = false; |
91 | 95 | // Filter only users that belong to a given group |
— | — | @@ -93,6 +97,23 @@ |
94 | 98 | 'ug1.ug_group' => $params['group'] ) ) ) ); |
95 | 99 | } |
96 | 100 | |
| 101 | + if ( !is_null( $params['excludegroup'] ) && count( $params['excludegroup'] ) ) { |
| 102 | + $useIndex = false; |
| 103 | + // Filter only users don't belong to a given group |
| 104 | + $this->addTables( 'user_groups', 'ug1' ); |
| 105 | + |
| 106 | + if ( count( $params['excludegroup'] ) == 1 ) { |
| 107 | + $exclude = array( 'ug1.ug_group = ' . $db->addQuotes( $params['excludegroup'][0] ) ); |
| 108 | + } else { |
| 109 | + $exclude = array( $db->makeList( array( 'ug1.ug_group' => $params['excludegroup'] ), LIST_OR ) ); |
| 110 | + } |
| 111 | + $this->addJoinConds( array( 'ug1' => array( 'LEFT OUTER JOIN', |
| 112 | + array_merge( array( 'ug1.ug_user=user_id' ), $exclude ) |
| 113 | + ) |
| 114 | + ) ); |
| 115 | + $this->addWhere( 'ug1.ug_user IS NULL' ); |
| 116 | + } |
| 117 | + |
97 | 118 | if ( $params['witheditsonly'] ) { |
98 | 119 | $this->addWhere( 'user_editcount > 0' ); |
99 | 120 | } |
— | — | @@ -254,6 +275,7 @@ |
255 | 276 | } |
256 | 277 | |
257 | 278 | public function getAllowedParams() { |
| 279 | + $userGroups = User::getAllGroups(); |
258 | 280 | return array( |
259 | 281 | 'from' => null, |
260 | 282 | 'to' => null, |
— | — | @@ -266,9 +288,13 @@ |
267 | 289 | ), |
268 | 290 | ), |
269 | 291 | 'group' => array( |
270 | | - ApiBase::PARAM_TYPE => User::getAllGroups(), |
| 292 | + ApiBase::PARAM_TYPE => $userGroups, |
271 | 293 | ApiBase::PARAM_ISMULTI => true, |
272 | 294 | ), |
| 295 | + 'excludegroup' => array( |
| 296 | + ApiBase::PARAM_TYPE => $userGroups, |
| 297 | + ApiBase::PARAM_ISMULTI => true, |
| 298 | + ), |
273 | 299 | 'rights' => array( |
274 | 300 | ApiBase::PARAM_TYPE => User::getAllRights(), |
275 | 301 | ApiBase::PARAM_ISMULTI => true, |
— | — | @@ -303,6 +329,7 @@ |
304 | 330 | 'prefix' => 'Search for all users that begin with this value', |
305 | 331 | 'dir' => 'Direction to sort in', |
306 | 332 | 'group' => 'Limit users to given group name(s)', |
| 333 | + 'excludegroup' => 'Exclude users in given group name(s)', |
307 | 334 | 'rights' => 'Limit users to given right(s)', |
308 | 335 | 'prop' => array( |
309 | 336 | 'What pieces of information to include.', |
— | — | @@ -322,6 +349,12 @@ |
323 | 350 | return 'Enumerate all registered users'; |
324 | 351 | } |
325 | 352 | |
| 353 | + public function getPossibleErrors() { |
| 354 | + return array_merge( parent::getPossibleErrors(), array( |
| 355 | + array( 'code' => 'group-excludegroup', 'info' => 'group and excludegroup cannot be used together' ), |
| 356 | + ) ); |
| 357 | + } |
| 358 | + |
326 | 359 | protected function getExamples() { |
327 | 360 | return array( |
328 | 361 | 'api.php?action=query&list=allusers&aufrom=Y', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -368,6 +368,7 @@ |
369 | 369 | * (bug 27179) API: List of extension tags through meta=siteinfo |
370 | 370 | * Get a list of function hooks through meta=siteinfo |
371 | 371 | * Get a list of all subscribed hooks, and those subscribers |
| 372 | +* (bug 28225) Allow hiding of user groups in list=allusers |
372 | 373 | |
373 | 374 | === Languages updated in 1.18 === |
374 | 375 | |