70 $providerIds = array_keys( $config->
get(
'CentralIdLookupProviders' ) );
74 'attachedlocal' => [],
76 ApiResult::setArrayType( $ret[
'centralids'],
'assoc' );
77 ApiResult::setArrayType( $ret[
'attachedlocal'],
'assoc' );
78 if ( $attachedWiki ) {
79 $ret[
'attachedwiki'] = [];
80 ApiResult::setArrayType( $ret[
'attachedwiki'],
'assoc' );
84 foreach ( $providerIds as $providerId ) {
85 $provider = CentralIdLookup::factory( $providerId );
86 $ret[
'centralids'][$providerId] = $provider->centralIdFromName( $name );
87 $ret[
'attachedlocal'][$providerId] = $provider->isAttached( $user );
88 if ( $attachedWiki ) {
89 $ret[
'attachedwiki'][$providerId] = $provider->isAttached( $user, $attachedWiki );
99 $vals[
'id'] = (int)$user->getId();
100 $vals[
'name'] = $user->getName();
102 if ( $user->isAnon() ) {
103 $vals[
'anon'] =
true;
106 if ( isset( $this->prop[
'blockinfo'] ) ) {
107 $block = $user->getBlock();
109 $vals = array_merge( $vals, $this->getBlockDetails( $block ) );
113 if ( isset( $this->prop[
'hasmsg'] ) ) {
114 $vals[
'messages'] = MediaWikiServices::getInstance()
115 ->getTalkPageNotificationManager()->userHasNewMessages( $user );
118 if ( isset( $this->prop[
'groups'] ) ) {
119 $vals[
'groups'] = $user->getEffectiveGroups();
120 ApiResult::setArrayType( $vals[
'groups'],
'array' );
121 ApiResult::setIndexedTagName( $vals[
'groups'],
'g' );
124 if ( isset( $this->prop[
'groupmemberships'] ) ) {
125 $ugms = $user->getGroupMemberships();
126 $vals[
'groupmemberships'] = [];
127 foreach ( $ugms as $group => $ugm ) {
128 $vals[
'groupmemberships'][] = [
130 'expiry' => ApiResult::formatExpiry( $ugm->getExpiry() ),
133 ApiResult::setArrayType( $vals[
'groupmemberships'],
'array' );
134 ApiResult::setIndexedTagName( $vals[
'groupmemberships'],
'groupmembership' );
137 if ( isset( $this->prop[
'implicitgroups'] ) ) {
138 $vals[
'implicitgroups'] = $user->getAutomaticGroups();
139 ApiResult::setArrayType( $vals[
'implicitgroups'],
'array' );
140 ApiResult::setIndexedTagName( $vals[
'implicitgroups'],
'g' );
143 if ( isset( $this->prop[
'rights'] ) ) {
145 ApiResult::setArrayType( $vals[
'rights'],
'array' );
146 ApiResult::setIndexedTagName( $vals[
'rights'],
'r' );
149 if ( isset( $this->prop[
'changeablegroups'] ) ) {
150 $vals[
'changeablegroups'] = $user->changeableGroups();
151 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'add'],
'g' );
152 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'remove'],
'g' );
153 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'add-self'],
'g' );
154 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'remove-self'],
'g' );
157 if ( isset( $this->prop[
'options'] ) ) {
158 $vals[
'options'] = $user->getOptions();
159 $vals[
'options'][ApiResult::META_BC_BOOLS] = array_keys( $vals[
'options'] );
162 if ( isset( $this->prop[
'preferencestoken'] ) &&
166 $vals[
'preferencestoken'] = $user->getEditToken(
'', $this->
getMain()->
getRequest() );
169 if ( isset( $this->prop[
'editcount'] ) ) {
172 $vals[
'editcount'] = (int)$user->getEditCount();
175 if ( isset( $this->prop[
'ratelimits'] ) ) {
179 if ( isset( $this->prop[
'realname'] ) &&
180 !in_array(
'realname', $this->
getConfig()->
get(
'HiddenPrefs' ) )
182 $vals[
'realname'] = $user->getRealName();
186 isset( $this->prop[
'email'] ) ) {
187 $vals[
'email'] = $user->getEmail();
188 $auth = $user->getEmailAuthenticationTimestamp();
189 if ( $auth !==
null ) {
190 $vals[
'emailauthenticated'] =
wfTimestamp( TS_ISO_8601, $auth );
194 if ( isset( $this->prop[
'registrationdate'] ) ) {
195 $regDate = $user->getRegistration();
196 if ( $regDate !==
false ) {
197 $vals[
'registrationdate'] =
wfTimestamp( TS_ISO_8601, $regDate );
201 if ( isset( $this->prop[
'acceptlang'] ) ) {
202 $langs = $this->
getRequest()->getAcceptLang();
204 foreach ( $langs as
$lang => $val ) {
205 $r = [
'q' => $val ];
206 ApiResult::setContentValue( $r,
'code',
$lang );
209 ApiResult::setIndexedTagName( $acceptLang,
'lang' );
210 $vals[
'acceptlang'] = $acceptLang;
213 if ( isset( $this->prop[
'unreadcount'] ) ) {
214 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
215 $unreadNotifications = $store->countUnreadNotifications(
217 self::WL_UNREAD_LIMIT
220 if ( $unreadNotifications ===
true ) {
221 $vals[
'unreadcount'] = self::WL_UNREAD_LIMIT .
'+';
223 $vals[
'unreadcount'] = $unreadNotifications;
227 if ( isset( $this->prop[
'centralids'] ) ) {
233 if ( isset( $this->prop[
'latestcontrib'] ) ) {
235 if ( $ts !==
null ) {
236 $vals[
'latestcontrib'] = $ts;
245 ApiResult::META_TYPE =>
'assoc',
249 if ( !$user->isPingLimitable() ) {
255 if ( $user->isAnon() ) {
256 $categories[] =
'anon';
258 $categories[] =
'user';
260 if ( $user->isNewbie() ) {
261 $categories[] =
'ip';
262 $categories[] =
'subnet';
263 if ( !$user->isAnon() ) {
264 $categories[] =
'newbie';
267 $categories = array_merge( $categories, $user->getGroups() );
270 foreach ( $this->
getConfig()->
get(
'RateLimits' ) as $action => $limits ) {
271 foreach ( $categories as $cat ) {
272 if ( isset( $limits[$cat] ) ) {
273 $retval[$action][$cat][
'hits'] = (int)$limits[$cat][0];
274 $retval[$action][$cat][
'seconds'] = (int)$limits[$cat][1];