48 private const WL_UNREAD_LIMIT = 1000;
71 parent::__construct( $query, $moduleName,
'ui' );
72 $this->talkPageNotificationManager = $talkPageNotificationManager;
73 $this->watchedItemStore = $watchedItemStore;
74 $this->userEditTracker = $userEditTracker;
75 $this->userOptionsLookup = $userOptionsLookup;
76 $this->userGroupManager = $userGroupManager;
83 if ( $this->params[
'prop'] !==
null ) {
84 $this->prop = array_fill_keys( $this->params[
'prop'],
true );
106 $attachedWiki = UserIdentity::LOCAL
112 'attachedlocal' => [],
116 if ( $attachedWiki ) {
117 $ret[
'attachedwiki'] = [];
123 ->getCentralIdLookupFactory();
124 foreach ( $providerIds as $providerId ) {
125 $provider = $centralIdLookupFactory->getLookup( $providerId );
126 $ret[
'centralids'][$providerId] = $provider->centralIdFromName( $name );
127 $ret[
'attachedlocal'][$providerId] = $provider->isAttached( $user );
128 if ( $attachedWiki ) {
129 $ret[
'attachedwiki'][$providerId] = $provider->isAttached( $user, $attachedWiki );
139 $vals[
'id'] = $user->getId();
140 $vals[
'name'] = $user->getName();
142 if ( !$user->isRegistered() ) {
143 $vals[
'anon'] =
true;
146 if ( $user->isTemp() ) {
147 $vals[
'temp'] =
true;
150 if ( isset( $this->prop[
'blockinfo'] ) ) {
151 $block = $user->getBlock();
153 $vals = array_merge( $vals, $this->getBlockDetails( $block ) );
157 if ( isset( $this->prop[
'hasmsg'] ) ) {
158 $vals[
'messages'] = $this->talkPageNotificationManager->userHasNewMessages( $user );
161 if ( isset( $this->prop[
'groups'] ) ) {
162 $vals[
'groups'] = $this->userGroupManager->getUserEffectiveGroups( $user );
167 if ( isset( $this->prop[
'groupmemberships'] ) ) {
168 $ugms = $this->userGroupManager->getUserGroupMemberships( $user );
169 $vals[
'groupmemberships'] = [];
170 foreach ( $ugms as $group => $ugm ) {
171 $vals[
'groupmemberships'][] = [
180 if ( isset( $this->prop[
'implicitgroups'] ) ) {
181 $vals[
'implicitgroups'] = $this->userGroupManager->getUserImplicitGroups( $user );
186 if ( isset( $this->prop[
'rights'] ) ) {
192 if ( isset( $this->prop[
'changeablegroups'] ) ) {
193 $vals[
'changeablegroups'] = $this->userGroupManager->getGroupsChangeableBy( $this->
getAuthority() );
200 if ( isset( $this->prop[
'options'] ) ) {
201 $vals[
'options'] = $this->userOptionsLookup->getOptions( $user );
205 if ( isset( $this->prop[
'editcount'] ) ) {
208 $vals[
'editcount'] = (int)$user->getEditCount();
211 if ( isset( $this->prop[
'ratelimits'] ) ) {
215 if ( isset( $this->prop[
'theoreticalratelimits'] ) ) {
217 $vals[
'theoreticalratelimits'] = $this->
getRateLimits(
false );
220 if ( isset( $this->prop[
'realname'] ) &&
223 $vals[
'realname'] = $user->getRealName();
226 if ( $this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) && isset( $this->prop[
'email'] ) ) {
227 $vals[
'email'] = $user->getEmail();
228 $auth = $user->getEmailAuthenticationTimestamp();
229 if ( $auth !==
null ) {
230 $vals[
'emailauthenticated'] =
wfTimestamp( TS_ISO_8601, $auth );
234 if ( isset( $this->prop[
'registrationdate'] ) ) {
235 $regDate = $user->getRegistration();
236 if ( $regDate !==
false ) {
241 if ( isset( $this->prop[
'acceptlang'] ) ) {
242 $langs = $this->
getRequest()->getAcceptLang();
244 foreach ( $langs as $lang => $val ) {
245 $r = [
'q' => $val ];
250 $vals[
'acceptlang'] = $acceptLang;
253 if ( isset( $this->prop[
'unreadcount'] ) ) {
254 $unreadNotifications = $this->watchedItemStore->countUnreadNotifications(
256 self::WL_UNREAD_LIMIT
259 if ( $unreadNotifications ===
true ) {
260 $vals[
'unreadcount'] = self::WL_UNREAD_LIMIT .
'+';
262 $vals[
'unreadcount'] = $unreadNotifications;
266 if ( isset( $this->prop[
'centralids'] ) ) {
272 if ( isset( $this->prop[
'latestcontrib'] ) ) {
274 if ( $ts !==
null ) {
275 $vals[
'latestcontrib'] = $ts;
279 if ( isset( $this->prop[
'cancreateaccount'] ) ) {
280 $status = PermissionStatus::newEmpty();
281 $vals[
'cancreateaccount'] = $user->definitelyCan(
'createaccount',
283 if ( !$status->isGood() ) {
284 $vals[
'cancreateaccounterror'] = $this->
getErrorFormatter()->arrayFromStatus( $status );
304 if ( $applyNoRateLimit && !$user->isPingLimitable() ) {
310 if ( !$user->isRegistered() ) {
311 $categories[] =
'anon';
313 $categories[] =
'user';
315 if ( $user->isNewbie() ) {
316 $categories[] =
'ip';
317 $categories[] =
'subnet';
318 if ( $user->isRegistered() ) {
319 $categories[] =
'newbie';
322 $categories = array_merge( $categories, $this->userGroupManager->getUserGroups( $user ) );
326 foreach ( $categories as $cat ) {
327 if ( isset( $limits[$cat] ) ) {
328 $retval[$action][$cat][
'hits'] = (int)$limits[$cat][0];
329 $retval[$action][$cat][
'seconds'] = (int)$limits[$cat][1];
341 $timestamp = $this->userEditTracker->getLatestEditTimestamp( $this->
getUser() );
342 if ( $timestamp ===
false ) {
345 return MWTimestamp::convert( TS_ISO_8601, $timestamp );
351 ParamValidator::PARAM_ISMULTI =>
true,
352 ParamValidator::PARAM_ALL =>
true,
353 ParamValidator::PARAM_TYPE => [
364 'theoreticalratelimits',
376 'apihelp-query+userinfo-paramvalue-prop-unreadcount',
377 self::WL_UNREAD_LIMIT - 1,
378 self::WL_UNREAD_LIMIT .
'+',
382 'attachedwiki' =>
null,
388 'action=query&meta=userinfo'
389 =>
'apihelp-query+userinfo-example-simple',
390 'action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg'
391 =>
'apihelp-query+userinfo-example-data',
396 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Userinfo';
401class_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.