34 private const WL_UNREAD_LIMIT = 1000;
57 parent::__construct( $query, $moduleName,
'ui' );
58 $this->talkPageNotificationManager = $talkPageNotificationManager;
59 $this->watchedItemStore = $watchedItemStore;
60 $this->userEditTracker = $userEditTracker;
61 $this->userOptionsLookup = $userOptionsLookup;
62 $this->userGroupManager = $userGroupManager;
69 if ( $this->params[
'prop'] !==
null ) {
70 $this->prop = array_fill_keys( $this->params[
'prop'],
true );
92 $attachedWiki = UserIdentity::LOCAL
98 'attachedlocal' => [],
102 if ( $attachedWiki ) {
103 $ret[
'attachedwiki'] = [];
109 ->getCentralIdLookupFactory();
110 foreach ( $providerIds as $providerId ) {
111 $provider = $centralIdLookupFactory->getLookup( $providerId );
112 $ret[
'centralids'][$providerId] = $provider->centralIdFromName( $name );
113 $ret[
'attachedlocal'][$providerId] = $provider->isAttached( $user );
114 if ( $attachedWiki ) {
115 $ret[
'attachedwiki'][$providerId] = $provider->isAttached( $user, $attachedWiki );
125 $vals[
'id'] = $user->getId();
126 $vals[
'name'] = $user->getName();
128 if ( !$user->isRegistered() ) {
129 $vals[
'anon'] =
true;
132 if ( $user->isTemp() ) {
133 $vals[
'temp'] =
true;
136 if ( isset( $this->prop[
'blockinfo'] ) ) {
137 $block = $user->getBlock();
139 $vals = array_merge( $vals, $this->getBlockDetails( $block ) );
143 if ( isset( $this->prop[
'hasmsg'] ) ) {
144 $vals[
'messages'] = $this->talkPageNotificationManager->userHasNewMessages( $user );
147 if ( isset( $this->prop[
'groups'] ) ) {
148 $vals[
'groups'] = $this->userGroupManager->getUserEffectiveGroups( $user );
153 if ( isset( $this->prop[
'groupmemberships'] ) ) {
154 $ugms = $this->userGroupManager->getUserGroupMemberships( $user );
155 $vals[
'groupmemberships'] = [];
156 foreach ( $ugms as $group => $ugm ) {
157 $vals[
'groupmemberships'][] = [
166 if ( isset( $this->prop[
'implicitgroups'] ) ) {
167 $vals[
'implicitgroups'] = $this->userGroupManager->getUserImplicitGroups( $user );
172 if ( isset( $this->prop[
'rights'] ) ) {
178 if ( isset( $this->prop[
'changeablegroups'] ) ) {
179 $vals[
'changeablegroups'] = $this->userGroupManager->getGroupsChangeableBy( $this->
getAuthority() );
186 if ( isset( $this->prop[
'options'] ) ) {
187 $vals[
'options'] = $this->userOptionsLookup->getOptions( $user );
191 if ( isset( $this->prop[
'editcount'] ) ) {
194 $vals[
'editcount'] = (int)$user->getEditCount();
197 if ( isset( $this->prop[
'ratelimits'] ) ) {
201 if ( isset( $this->prop[
'theoreticalratelimits'] ) ) {
203 $vals[
'theoreticalratelimits'] = $this->
getRateLimits(
false );
206 if ( isset( $this->prop[
'realname'] ) &&
209 $vals[
'realname'] = $user->getRealName();
212 if ( $this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) && isset( $this->prop[
'email'] ) ) {
213 $vals[
'email'] = $user->getEmail();
214 $auth = $user->getEmailAuthenticationTimestamp();
215 if ( $auth !==
null ) {
216 $vals[
'emailauthenticated'] =
wfTimestamp( TS_ISO_8601, $auth );
220 if ( isset( $this->prop[
'registrationdate'] ) ) {
221 $regDate = $user->getRegistration();
222 if ( $regDate !==
false ) {
227 if ( isset( $this->prop[
'acceptlang'] ) ) {
228 $langs = $this->
getRequest()->getAcceptLang();
230 foreach ( $langs as $lang => $val ) {
231 $r = [
'q' => $val ];
236 $vals[
'acceptlang'] = $acceptLang;
239 if ( isset( $this->prop[
'unreadcount'] ) ) {
240 $unreadNotifications = $this->watchedItemStore->countUnreadNotifications(
242 self::WL_UNREAD_LIMIT
245 if ( $unreadNotifications ===
true ) {
246 $vals[
'unreadcount'] = self::WL_UNREAD_LIMIT .
'+';
248 $vals[
'unreadcount'] = $unreadNotifications;
252 if ( isset( $this->prop[
'centralids'] ) ) {
258 if ( isset( $this->prop[
'latestcontrib'] ) ) {
260 if ( $ts !==
null ) {
261 $vals[
'latestcontrib'] = $ts;
265 if ( isset( $this->prop[
'cancreateaccount'] ) ) {
266 $status = PermissionStatus::newEmpty();
267 $vals[
'cancreateaccount'] = $user->definitelyCan(
'createaccount',
269 if ( !$status->isGood() ) {
270 $vals[
'cancreateaccounterror'] = $this->
getErrorFormatter()->arrayFromStatus( $status );
290 if ( $applyNoRateLimit && !$user->isPingLimitable() ) {
296 if ( !$user->isRegistered() ) {
297 $categories[] =
'anon';
299 $categories[] =
'user';
301 if ( $user->isNewbie() ) {
302 $categories[] =
'ip';
303 $categories[] =
'subnet';
304 if ( $user->isRegistered() ) {
305 $categories[] =
'newbie';
308 $categories = array_merge( $categories, $this->userGroupManager->getUserGroups( $user ) );
312 foreach ( $categories as $cat ) {
313 if ( isset( $limits[$cat] ) ) {
314 $retval[$action][$cat][
'hits'] = (int)$limits[$cat][0];
315 $retval[$action][$cat][
'seconds'] = (int)$limits[$cat][1];
327 $timestamp = $this->userEditTracker->getLatestEditTimestamp( $this->
getUser() );
328 if ( $timestamp ===
false ) {
331 return MWTimestamp::convert( TS_ISO_8601, $timestamp );
338 ParamValidator::PARAM_ISMULTI =>
true,
339 ParamValidator::PARAM_ALL =>
true,
340 ParamValidator::PARAM_TYPE => [
351 'theoreticalratelimits',
363 'apihelp-query+userinfo-paramvalue-prop-unreadcount',
364 self::WL_UNREAD_LIMIT - 1,
365 self::WL_UNREAD_LIMIT .
'+',
369 'attachedwiki' =>
null,
376 'action=query&meta=userinfo'
377 =>
'apihelp-query+userinfo-example-simple',
378 'action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg'
379 =>
'apihelp-query+userinfo-example-data',
385 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Userinfo';
390class_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 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.