Index: trunk/phase3/includes/api/ApiQueryAllUsers.php |
— | — | @@ -51,8 +51,9 @@ |
52 | 52 | $fld_groups = isset( $prop['groups'] ); |
53 | 53 | $fld_rights = isset( $prop['rights'] ); |
54 | 54 | $fld_registration = isset( $prop['registration'] ); |
| 55 | + $fld_implicitgroups = isset( $prop['implicitgroups'] ); |
55 | 56 | } else { |
56 | | - $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = $fld_rights = false; |
| 57 | + $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = $fld_rights = $fld_implicitgroups = false; |
57 | 58 | } |
58 | 59 | |
59 | 60 | $limit = $params['limit']; |
— | — | @@ -246,6 +247,10 @@ |
247 | 248 | $result->setIndexedTagName( $lastUserData['groups'], 'g' ); |
248 | 249 | } |
249 | 250 | |
| 251 | + if ( $fld_implicitgroups && !isset( $lastUserData['implicitgroups'] ) ) { |
| 252 | + $lastUserData['implicitgroups'] = ApiQueryUsers::getAutoGroups( User::newFromName( $lastUser ) ); |
| 253 | + $result->setIndexedTagName( $lastUserData['implicitgroups'], 'g' ); |
| 254 | + } |
250 | 255 | if ( $fld_rights ) { |
251 | 256 | if ( !isset( $lastUserData['rights'] ) ) { |
252 | 257 | $lastUserData['rights'] = User::getGroupPermissions( User::newFromName( $lastUser )->getAutomaticGroups() ); |
— | — | @@ -304,6 +309,7 @@ |
305 | 310 | ApiBase::PARAM_TYPE => array( |
306 | 311 | 'blockinfo', |
307 | 312 | 'groups', |
| 313 | + 'implicitgroups', |
308 | 314 | 'rights', |
309 | 315 | 'editcount', |
310 | 316 | 'registration' |
— | — | @@ -333,11 +339,12 @@ |
334 | 340 | 'rights' => 'Limit users to given right(s)', |
335 | 341 | 'prop' => array( |
336 | 342 | 'What pieces of information to include.', |
337 | | - ' blockinfo - Adds the information about a current block on the user', |
338 | | - ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit', |
339 | | - ' rights - Lists rights that the user has', |
340 | | - ' editcount - Adds the edit count of the user', |
341 | | - ' registration - Adds the timestamp of when the user registered if available (may be blank)', |
| 343 | + ' blockinfo - Adds the information about a current block on the user', |
| 344 | + ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit', |
| 345 | + ' implicitgroups - Lists all the groups the user is automatically in', |
| 346 | + ' rights - Lists rights that the user has', |
| 347 | + ' editcount - Adds the edit count of the user', |
| 348 | + ' registration - Adds the timestamp of when the user registered if available (may be blank)', |
342 | 349 | ), |
343 | 350 | 'limit' => 'How many total user names to return', |
344 | 351 | 'witheditsonly' => 'Only list users who have made edits', |
Index: trunk/phase3/includes/api/ApiQueryUsers.php |
— | — | @@ -152,6 +152,10 @@ |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
| 156 | + if ( isset( $this->prop['implicitgroups'] ) && !isset( $data[$name]['implicitgroups'] ) ) { |
| 157 | + $data[$name]['implicitgroups'] = self::getAutoGroups( $user ); |
| 158 | + } |
| 159 | + |
156 | 160 | if ( isset( $this->prop['rights'] ) ) { |
157 | 161 | if ( !isset( $data[$name]['rights'] ) ) { |
158 | 162 | $data[$name]['rights'] = User::getGroupPermissions( $user->getAutomaticGroups() ); |
— | — | @@ -226,6 +230,9 @@ |
227 | 231 | if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) { |
228 | 232 | $result->setIndexedTagName( $data[$u]['groups'], 'g' ); |
229 | 233 | } |
| 234 | + if ( isset( $this->prop['implicitgroups'] ) && isset( $data[$u]['implicitgroups'] ) ) { |
| 235 | + $result->setIndexedTagName( $data[$u]['implicitgroups'], 'g' ); |
| 236 | + } |
230 | 237 | if ( isset( $this->prop['rights'] ) && isset( $data[$u]['rights'] ) ) { |
231 | 238 | $result->setIndexedTagName( $data[$u]['rights'], 'r' ); |
232 | 239 | } |
— | — | @@ -256,12 +263,7 @@ |
257 | 264 | $groups[] = 'user'; |
258 | 265 | } |
259 | 266 | |
260 | | - $builtGroups = array(); |
261 | | - foreach( array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) ) as $i => $group ) { |
262 | | - $builtGroups[$i] = array( 'implicit' => '' ); |
263 | | - ApiResult::setContent( $builtGroups[$i], $group ); |
264 | | - } |
265 | | - return $builtGroups; |
| 267 | + return array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) ); |
266 | 268 | } |
267 | 269 | |
268 | 270 | public function getCacheMode( $params ) { |
— | — | @@ -280,6 +282,7 @@ |
281 | 283 | ApiBase::PARAM_TYPE => array( |
282 | 284 | 'blockinfo', |
283 | 285 | 'groups', |
| 286 | + 'implicitgroups', |
284 | 287 | 'rights', |
285 | 288 | 'editcount', |
286 | 289 | 'registration', |
— | — | @@ -301,13 +304,14 @@ |
302 | 305 | return array( |
303 | 306 | 'prop' => array( |
304 | 307 | 'What pieces of information to include', |
305 | | - ' blockinfo - Tags if the user is blocked, by whom, and for what reason', |
306 | | - ' groups - Lists all the groups the user(s) belongs to', |
307 | | - ' rights - Lists all the rights the user(s) has', |
308 | | - ' editcount - Adds the user\'s edit count', |
309 | | - ' registration - Adds the user\'s registration timestamp', |
310 | | - ' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]', |
311 | | - ' gender - Tags the gender of the user. Returns "male", "female", or "unknown"', |
| 308 | + ' blockinfo - Tags if the user is blocked, by whom, and for what reason', |
| 309 | + ' groups - Lists all the groups the user(s) belongs to', |
| 310 | + ' implicitgroups - Lists all the groups a user is automatically a member of', |
| 311 | + ' rights - Lists all the rights the user(s) has', |
| 312 | + ' editcount - Adds the user\'s edit count', |
| 313 | + ' registration - Adds the user\'s registration timestamp', |
| 314 | + ' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]', |
| 315 | + ' gender - Tags the gender of the user. Returns "male", "female", or "unknown"', |
312 | 316 | ), |
313 | 317 | 'users' => 'A list of users to obtain the same information for', |
314 | 318 | 'token' => 'Which tokens to obtain for each user', |