123 $attachedWiki = UserIdentity::LOCAL
125 $providerIds = array_keys( $config->
get(
'CentralIdLookupProviders' ) );
129 'attachedlocal' => [],
131 ApiResult::setArrayType( $ret[
'centralids'],
'assoc' );
132 ApiResult::setArrayType( $ret[
'attachedlocal'],
'assoc' );
133 if ( $attachedWiki ) {
134 $ret[
'attachedwiki'] = [];
135 ApiResult::setArrayType( $ret[
'attachedwiki'],
'assoc' );
139 $centralIdLookupFactory = MediaWikiServices::getInstance()
140 ->getCentralIdLookupFactory();
141 foreach ( $providerIds as $providerId ) {
142 $provider = $centralIdLookupFactory->getLookup( $providerId );
143 $ret[
'centralids'][$providerId] = $provider->centralIdFromName( $name );
144 $ret[
'attachedlocal'][$providerId] = $provider->isAttached( $user );
145 if ( $attachedWiki ) {
146 $ret[
'attachedwiki'][$providerId] = $provider->isAttached( $user, $attachedWiki );
156 $vals[
'id'] = $user->getId();
157 $vals[
'name'] = $user->getName();
159 if ( !$user->isRegistered() ) {
160 $vals[
'anon'] =
true;
163 if ( isset( $this->prop[
'blockinfo'] ) ) {
164 $block = $user->getBlock();
166 $vals = array_merge( $vals, $this->getBlockDetails( $block ) );
170 if ( isset( $this->prop[
'hasmsg'] ) ) {
171 $vals[
'messages'] = $this->talkPageNotificationManager->userHasNewMessages( $user );
174 if ( isset( $this->prop[
'groups'] ) ) {
175 $vals[
'groups'] = $this->userGroupManager->getUserEffectiveGroups( $user );
176 ApiResult::setArrayType( $vals[
'groups'],
'array' );
177 ApiResult::setIndexedTagName( $vals[
'groups'],
'g' );
180 if ( isset( $this->prop[
'groupmemberships'] ) ) {
181 $ugms = $this->userGroupManager->getUserGroupMemberships( $user );
182 $vals[
'groupmemberships'] = [];
183 foreach ( $ugms as $group => $ugm ) {
184 $vals[
'groupmemberships'][] = [
186 'expiry' => ApiResult::formatExpiry( $ugm->getExpiry() ),
189 ApiResult::setArrayType( $vals[
'groupmemberships'],
'array' );
190 ApiResult::setIndexedTagName( $vals[
'groupmemberships'],
'groupmembership' );
193 if ( isset( $this->prop[
'implicitgroups'] ) ) {
194 $vals[
'implicitgroups'] = $this->userGroupManager->getUserImplicitGroups( $user );
195 ApiResult::setArrayType( $vals[
'implicitgroups'],
'array' );
196 ApiResult::setIndexedTagName( $vals[
'implicitgroups'],
'g' );
199 if ( isset( $this->prop[
'rights'] ) ) {
201 ApiResult::setArrayType( $vals[
'rights'],
'array' );
202 ApiResult::setIndexedTagName( $vals[
'rights'],
'r' );
205 if ( isset( $this->prop[
'changeablegroups'] ) ) {
206 $vals[
'changeablegroups'] = $this->userGroupManager->getGroupsChangeableBy( $this->
getAuthority() );
207 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'add'],
'g' );
208 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'remove'],
'g' );
209 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'add-self'],
'g' );
210 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'remove-self'],
'g' );
213 if ( isset( $this->prop[
'options'] ) ) {
214 $vals[
'options'] = $this->userOptionsLookup->getOptions( $user );
215 $vals[
'options'][ApiResult::META_BC_BOOLS] = array_keys( $vals[
'options'] );
218 if ( isset( $this->prop[
'editcount'] ) ) {
221 $vals[
'editcount'] = (int)$user->getEditCount();
224 if ( isset( $this->prop[
'ratelimits'] ) ) {
228 if ( isset( $this->prop[
'theoreticalratelimits'] ) ) {
230 $vals[
'theoreticalratelimits'] = $this->
getRateLimits(
false );
233 if ( isset( $this->prop[
'realname'] ) &&
234 !in_array(
'realname', $this->
getConfig()->
get(
'HiddenPrefs' ) )
236 $vals[
'realname'] = $user->getRealName();
239 if ( $this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) && isset( $this->prop[
'email'] ) ) {
240 $vals[
'email'] = $user->getEmail();
241 $auth = $user->getEmailAuthenticationTimestamp();
242 if ( $auth !==
null ) {
243 $vals[
'emailauthenticated'] =
wfTimestamp( TS_ISO_8601, $auth );
247 if ( isset( $this->prop[
'registrationdate'] ) ) {
248 $regDate = $user->getRegistration();
249 if ( $regDate !==
false ) {
250 $vals[
'registrationdate'] =
wfTimestamp( TS_ISO_8601, $regDate );
254 if ( isset( $this->prop[
'acceptlang'] ) ) {
255 $langs = $this->
getRequest()->getAcceptLang();
257 foreach ( $langs as
$lang => $val ) {
258 $r = [
'q' => $val ];
259 ApiResult::setContentValue( $r,
'code',
$lang );
262 ApiResult::setIndexedTagName( $acceptLang,
'lang' );
263 $vals[
'acceptlang'] = $acceptLang;
266 if ( isset( $this->prop[
'unreadcount'] ) ) {
267 $unreadNotifications = $this->watchedItemStore->countUnreadNotifications(
269 self::WL_UNREAD_LIMIT
272 if ( $unreadNotifications ===
true ) {
273 $vals[
'unreadcount'] = self::WL_UNREAD_LIMIT .
'+';
275 $vals[
'unreadcount'] = $unreadNotifications;
279 if ( isset( $this->prop[
'centralids'] ) ) {
285 if ( isset( $this->prop[
'latestcontrib'] ) ) {
287 if ( $ts !==
null ) {
288 $vals[
'latestcontrib'] = $ts;
304 ApiResult::META_TYPE =>
'assoc',
308 if ( $applyNoRateLimit && !$user->isPingLimitable() ) {
314 if ( !$user->isRegistered() ) {
315 $categories[] =
'anon';
317 $categories[] =
'user';
319 if ( $user->isNewbie() ) {
320 $categories[] =
'ip';
321 $categories[] =
'subnet';
322 if ( $user->isRegistered() ) {
323 $categories[] =
'newbie';
326 $categories = array_merge( $categories, $this->userGroupManager->getUserGroups( $user ) );
329 foreach ( $this->
getConfig()->
get(
'RateLimits' ) as $action => $limits ) {
330 foreach ( $categories as $cat ) {
331 if ( isset( $limits[$cat] ) ) {
332 $retval[$action][$cat][
'hits'] = (int)$limits[$cat][0];
333 $retval[$action][$cat][
'seconds'] = (int)$limits[$cat][1];