25use Wikimedia\Timestamp\TimestampFormat as TS;
36 private const WL_UNREAD_LIMIT = 1000;
54 parent::__construct( $query, $moduleName,
'ui' );
61 if ( $this->params[
'prop'] !==
null ) {
62 $this->prop = array_fill_keys( $this->params[
'prop'],
true );
84 $attachedWiki = UserIdentity::LOCAL
90 'attachedlocal' => [],
94 if ( $attachedWiki ) {
95 $ret[
'attachedwiki'] = [];
101 ->getCentralIdLookupFactory();
102 foreach ( $providerIds as $providerId ) {
103 $provider = $centralIdLookupFactory->getLookup( $providerId );
104 $ret[
'centralids'][$providerId] = $provider->centralIdFromName( $name );
105 $ret[
'attachedlocal'][$providerId] = $provider->isAttached( $user );
106 if ( $attachedWiki ) {
107 $ret[
'attachedwiki'][$providerId] = $provider->isAttached( $user, $attachedWiki );
117 $vals[
'id'] = $user->getId();
118 $vals[
'name'] = $user->getName();
120 if ( !$user->isRegistered() ) {
121 $vals[
'anon'] =
true;
124 if ( $user->isTemp() ) {
125 $vals[
'temp'] =
true;
128 if ( isset( $this->prop[
'blockinfo'] ) ) {
129 $block = $user->getBlock();
131 $vals = array_merge( $vals, $this->getBlockDetails( $block ) );
135 if ( isset( $this->prop[
'hasmsg'] ) ) {
136 $vals[
'messages'] = $this->talkPageNotificationManager->userHasNewMessages( $user );
139 if ( isset( $this->prop[
'groups'] ) ) {
140 $vals[
'groups'] = $this->userGroupManager->getUserEffectiveGroups( $user );
145 if ( isset( $this->prop[
'groupmemberships'] ) ) {
146 $ugms = $this->userGroupManager->getUserGroupMemberships( $user );
147 $vals[
'groupmemberships'] = [];
148 foreach ( $ugms as $group => $ugm ) {
149 $vals[
'groupmemberships'][] = [
158 if ( isset( $this->prop[
'implicitgroups'] ) ) {
159 $vals[
'implicitgroups'] = $this->userGroupManager->getUserImplicitGroups( $user );
164 if ( isset( $this->prop[
'rights'] ) ) {
170 if ( isset( $this->prop[
'changeablegroups'] ) ) {
171 $vals[
'changeablegroups'] = $this->userGroupManager->getGroupsChangeableBy( $this->
getAuthority() );
178 if ( isset( $this->prop[
'options'] ) ) {
179 $vals[
'options'] = $this->userOptionsLookup->getOptions( $user );
183 if ( isset( $this->prop[
'editcount'] ) ) {
186 $vals[
'editcount'] = (int)$user->getEditCount();
189 if ( isset( $this->prop[
'ratelimits'] ) ) {
193 if ( isset( $this->prop[
'theoreticalratelimits'] ) ) {
195 $vals[
'theoreticalratelimits'] = $this->
getRateLimits(
false );
198 if ( isset( $this->prop[
'realname'] ) &&
201 $vals[
'realname'] = $user->getRealName();
204 if ( $this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) && isset( $this->prop[
'email'] ) ) {
205 $vals[
'email'] = $user->getEmail();
206 $auth = $user->getEmailAuthenticationTimestamp();
207 if ( $auth !==
null ) {
208 $vals[
'emailauthenticated'] =
wfTimestamp( TS::ISO_8601, $auth );
212 if ( isset( $this->prop[
'registrationdate'] ) ) {
213 $regDate = $user->getRegistration();
214 if ( $regDate !==
false ) {
219 if ( isset( $this->prop[
'acceptlang'] ) ) {
220 $langs = $this->
getRequest()->getAcceptLang();
222 foreach ( $langs as $lang => $val ) {
223 $r = [
'q' => $val ];
228 $vals[
'acceptlang'] = $acceptLang;
231 if ( isset( $this->prop[
'unreadcount'] ) ) {
232 $unreadNotifications = $this->watchedItemStore->countUnreadNotifications(
234 self::WL_UNREAD_LIMIT
237 if ( $unreadNotifications ===
true ) {
238 $vals[
'unreadcount'] = self::WL_UNREAD_LIMIT .
'+';
240 $vals[
'unreadcount'] = $unreadNotifications;
245 if ( isset( $this->prop[
'watchlistlabels'] ) &&
248 $labels = $this->watchlistLabelStore->loadAllForUser( $user );
249 $wl = array_map(
static fn ( $label ) => [
250 'id' => $label->getId(),
251 'name' => $label->getName(),
255 $vals[
'watchlistlabels'] = $wl;
258 if ( isset( $this->prop[
'centralids'] ) ) {
264 if ( isset( $this->prop[
'latestcontrib'] ) ) {
266 if ( $ts !==
null ) {
267 $vals[
'latestcontrib'] = $ts;
271 if ( isset( $this->prop[
'cancreateaccount'] ) ) {
272 $status = PermissionStatus::newEmpty();
273 $vals[
'cancreateaccount'] = $user->definitelyCan(
'createaccount',
275 if ( !$status->isGood() ) {
276 $vals[
'cancreateaccounterror'] = $this->
getErrorFormatter()->arrayFromStatus( $status );
296 if ( $applyNoRateLimit && !$user->isPingLimitable() ) {
302 if ( !$user->isRegistered() ) {
303 $categories[] =
'anon';
305 $categories[] =
'user';
307 if ( $user->isNewbie() ) {
308 $categories[] =
'ip';
309 $categories[] =
'subnet';
310 if ( $user->isRegistered() ) {
311 $categories[] =
'newbie';
314 $categories = array_merge( $categories, $this->userGroupManager->getUserGroups( $user ) );
318 foreach ( $categories as $cat ) {
319 if ( isset( $limits[$cat] ) ) {
320 $retval[$action][$cat][
'hits'] = (int)$limits[$cat][0];
321 $retval[$action][$cat][
'seconds'] = (int)$limits[$cat][1];
333 $timestamp = $this->userEditTracker->getLatestEditTimestamp( $this->
getUser() );
334 if ( $timestamp ===
false ) {
337 return MWTimestamp::convert( TS::ISO_8601, $timestamp );
344 ParamValidator::PARAM_ISMULTI =>
true,
345 ParamValidator::PARAM_ALL =>
true,
346 ParamValidator::PARAM_TYPE => [
357 'theoreticalratelimits',
370 'apihelp-query+userinfo-paramvalue-prop-unreadcount',
371 self::WL_UNREAD_LIMIT - 1,
372 self::WL_UNREAD_LIMIT .
'+',
376 'attachedwiki' =>
null,
383 'action=query&meta=userinfo'
384 =>
'apihelp-query+userinfo-example-simple',
385 'action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg'
386 =>
'apihelp-query+userinfo-example-data',
392 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Userinfo';
397class_alias( ApiQueryUserInfo::class,
'ApiQueryUserInfo' );
wfTimestampOrNull( $outputtype=TS::UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.
A class containing constants representing the names of configuration variables.
const HiddenPrefs
Name constant for the HiddenPrefs setting, for use with Config::get()
const CentralIdLookupProviders
Name constant for the CentralIdLookupProviders setting, for use with Config::get()
const EnableWatchlistLabels
Name constant for the EnableWatchlistLabels setting, for use with Config::get()
const RateLimits
Name constant for the RateLimits setting, for use with Config::get()
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Manages user talk page notifications.