Index: branches/wmf/1.18wmf1/includes/api/ApiQueryUserInfo.php |
— | — | @@ -83,6 +83,11 @@ |
84 | 84 | $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty |
85 | 85 | } |
86 | 86 | |
| 87 | + if ( isset( $this->prop['implicitgroups'] ) ) { |
| 88 | + $vals['implicitgroups'] = ApiQueryUsers::getAutoGroups( $wgUser ); |
| 89 | + $result->setIndexedTagName( $vals['implicitgroups'], 'g' ); // even if empty |
| 90 | + } |
| 91 | + |
87 | 92 | if ( isset( $this->prop['rights'] ) ) { |
88 | 93 | // User::getRights() may return duplicate values, strip them |
89 | 94 | $vals['rights'] = array_values( array_unique( $wgUser->getRights() ) ); |
— | — | @@ -191,6 +196,7 @@ |
192 | 197 | 'blockinfo', |
193 | 198 | 'hasmsg', |
194 | 199 | 'groups', |
| 200 | + 'implicitgroups', |
195 | 201 | 'rights', |
196 | 202 | 'changeablegroups', |
197 | 203 | 'options', |
— | — | @@ -213,6 +219,7 @@ |
214 | 220 | ' blockinfo - Tags if the current user is blocked, by whom, and for what reason', |
215 | 221 | ' hasmsg - Adds a tag "message" if the current user has pending messages', |
216 | 222 | ' groups - Lists all the groups the current user belongs to', |
| 223 | + ' implicitgroups - Lists all the groups the current user is automatically a member of', |
217 | 224 | ' rights - Lists all the rights the current user has', |
218 | 225 | ' changeablegroups - Lists the groups the current user can add to and remove from', |
219 | 226 | ' options - Lists all preferences the current user has set', |
Index: branches/wmf/1.18wmf1/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,13 +247,17 @@ |
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() ); |
253 | 258 | } |
254 | 259 | if ( !is_null( $row->ug_group2 ) ) { |
255 | 260 | $lastUserData['rights'] = array_unique( array_merge( $lastUserData['rights'], |
256 | | - User::getGroupPermissions( array( $row->ug_group2 ) ) ) ); |
| 261 | + User::getGroupPermissions( array( $row->ug_group2 ) ) ) ); |
257 | 262 | } |
258 | 263 | $result->setIndexedTagName( $lastUserData['rights'], 'r' ); |
259 | 264 | } |
— | — | @@ -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: branches/wmf/1.18wmf1/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', |
Index: branches/REL1_18/phase3/includes/api/ApiQueryUserInfo.php |
— | — | @@ -83,6 +83,11 @@ |
84 | 84 | $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty |
85 | 85 | } |
86 | 86 | |
| 87 | + if ( isset( $this->prop['implicitgroups'] ) ) { |
| 88 | + $vals['implicitgroups'] = ApiQueryUsers::getAutoGroups( $wgUser ); |
| 89 | + $result->setIndexedTagName( $vals['implicitgroups'], 'g' ); // even if empty |
| 90 | + } |
| 91 | + |
87 | 92 | if ( isset( $this->prop['rights'] ) ) { |
88 | 93 | // User::getRights() may return duplicate values, strip them |
89 | 94 | $vals['rights'] = array_values( array_unique( $wgUser->getRights() ) ); |
— | — | @@ -191,6 +196,7 @@ |
192 | 197 | 'blockinfo', |
193 | 198 | 'hasmsg', |
194 | 199 | 'groups', |
| 200 | + 'implicitgroups', |
195 | 201 | 'rights', |
196 | 202 | 'changeablegroups', |
197 | 203 | 'options', |
— | — | @@ -213,6 +219,7 @@ |
214 | 220 | ' blockinfo - Tags if the current user is blocked, by whom, and for what reason', |
215 | 221 | ' hasmsg - Adds a tag "message" if the current user has pending messages', |
216 | 222 | ' groups - Lists all the groups the current user belongs to', |
| 223 | + ' implicitgroups - Lists all the groups the current user is automatically a member of', |
217 | 224 | ' rights - Lists all the rights the current user has', |
218 | 225 | ' changeablegroups - Lists the groups the current user can add to and remove from', |
219 | 226 | ' options - Lists all preferences the current user has set', |
Index: branches/REL1_18/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,13 +247,17 @@ |
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() ); |
253 | 258 | } |
254 | 259 | if ( !is_null( $row->ug_group2 ) ) { |
255 | 260 | $lastUserData['rights'] = array_unique( array_merge( $lastUserData['rights'], |
256 | | - User::getGroupPermissions( array( $row->ug_group2 ) ) ) ); |
| 261 | + User::getGroupPermissions( array( $row->ug_group2 ) ) ) ); |
257 | 262 | } |
258 | 263 | $result->setIndexedTagName( $lastUserData['rights'], 'r' ); |
259 | 264 | } |
— | — | @@ -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: branches/REL1_18/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', |