89 parent::__construct( $query, $moduleName,
'ui' );
101 if ( $this->params[
'prop'] !==
null ) {
102 $this->prop = array_fill_keys( $this->params[
'prop'],
true );
124 $attachedWiki = UserIdentity::LOCAL
126 $providerIds = array_keys( $config->
get( MainConfigNames::CentralIdLookupProviders ) );
130 'attachedlocal' => [],
134 if ( $attachedWiki ) {
135 $ret[
'attachedwiki'] = [];
140 $centralIdLookupFactory = MediaWikiServices::getInstance()
141 ->getCentralIdLookupFactory();
142 foreach ( $providerIds as $providerId ) {
143 $provider = $centralIdLookupFactory->getLookup( $providerId );
144 $ret[
'centralids'][$providerId] = $provider->centralIdFromName( $name );
145 $ret[
'attachedlocal'][$providerId] = $provider->isAttached( $user );
146 if ( $attachedWiki ) {
147 $ret[
'attachedwiki'][$providerId] = $provider->isAttached( $user, $attachedWiki );
157 $vals[
'id'] = $user->getId();
158 $vals[
'name'] = $user->getName();
160 if ( !$user->isRegistered() ) {
161 $vals[
'anon'] =
true;
164 if ( isset( $this->prop[
'blockinfo'] ) ) {
165 $block = $user->getBlock();
167 $vals = array_merge( $vals, $this->getBlockDetails( $block ) );
171 if ( isset( $this->prop[
'hasmsg'] ) ) {
172 $vals[
'messages'] = $this->talkPageNotificationManager->userHasNewMessages( $user );
175 if ( isset( $this->prop[
'groups'] ) ) {
176 $vals[
'groups'] = $this->userGroupManager->getUserEffectiveGroups( $user );
181 if ( isset( $this->prop[
'groupmemberships'] ) ) {
182 $ugms = $this->userGroupManager->getUserGroupMemberships( $user );
183 $vals[
'groupmemberships'] = [];
184 foreach ( $ugms as $group => $ugm ) {
185 $vals[
'groupmemberships'][] = [
194 if ( isset( $this->prop[
'implicitgroups'] ) ) {
195 $vals[
'implicitgroups'] = $this->userGroupManager->getUserImplicitGroups( $user );
200 if ( isset( $this->prop[
'rights'] ) ) {
206 if ( isset( $this->prop[
'changeablegroups'] ) ) {
207 $vals[
'changeablegroups'] = $this->userGroupManager->getGroupsChangeableBy( $this->
getAuthority() );
214 if ( isset( $this->prop[
'options'] ) ) {
215 $vals[
'options'] = $this->userOptionsLookup->getOptions( $user );
219 if ( isset( $this->prop[
'editcount'] ) ) {
222 $vals[
'editcount'] = (int)$user->getEditCount();
225 if ( isset( $this->prop[
'ratelimits'] ) ) {
229 if ( isset( $this->prop[
'theoreticalratelimits'] ) ) {
231 $vals[
'theoreticalratelimits'] = $this->
getRateLimits(
false );
234 if ( isset( $this->prop[
'realname'] ) &&
235 !in_array(
'realname', $this->
getConfig()->
get( MainConfigNames::HiddenPrefs ) )
237 $vals[
'realname'] = $user->getRealName();
240 if ( $this->
getAuthority()->isAllowed(
'viewmyprivateinfo' ) && isset( $this->prop[
'email'] ) ) {
241 $vals[
'email'] = $user->getEmail();
242 $auth = $user->getEmailAuthenticationTimestamp();
243 if ( $auth !==
null ) {
244 $vals[
'emailauthenticated'] =
wfTimestamp( TS_ISO_8601, $auth );
248 if ( isset( $this->prop[
'registrationdate'] ) ) {
249 $regDate = $user->getRegistration();
250 if ( $regDate !==
false ) {
251 $vals[
'registrationdate'] =
wfTimestamp( TS_ISO_8601, $regDate );
255 if ( isset( $this->prop[
'acceptlang'] ) ) {
256 $langs = $this->
getRequest()->getAcceptLang();
258 foreach ( $langs as
$lang => $val ) {
259 $r = [
'q' => $val ];
264 $vals[
'acceptlang'] = $acceptLang;
267 if ( isset( $this->prop[
'unreadcount'] ) ) {
268 $unreadNotifications = $this->watchedItemStore->countUnreadNotifications(
270 self::WL_UNREAD_LIMIT
273 if ( $unreadNotifications ===
true ) {
274 $vals[
'unreadcount'] = self::WL_UNREAD_LIMIT .
'+';
276 $vals[
'unreadcount'] = $unreadNotifications;
280 if ( isset( $this->prop[
'centralids'] ) ) {
286 if ( isset( $this->prop[
'latestcontrib'] ) ) {
288 if ( $ts !==
null ) {
289 $vals[
'latestcontrib'] = $ts;
309 if ( $applyNoRateLimit && !$user->isPingLimitable() ) {
315 if ( !$user->isRegistered() ) {
316 $categories[] =
'anon';
318 $categories[] =
'user';
320 if ( $user->isNewbie() ) {
321 $categories[] =
'ip';
322 $categories[] =
'subnet';
323 if ( $user->isRegistered() ) {
324 $categories[] =
'newbie';
327 $categories = array_merge( $categories, $this->userGroupManager->getUserGroups( $user ) );
330 foreach ( $this->
getConfig()->
get( MainConfigNames::RateLimits ) as $action => $limits ) {
331 foreach ( $categories as $cat ) {
332 if ( isset( $limits[$cat] ) ) {
333 $retval[$action][$cat][
'hits'] = (int)$limits[$cat][0];
334 $retval[$action][$cat][
'seconds'] = (int)$limits[$cat][1];
346 $timestamp = $this->userEditTracker->getLatestEditTimestamp( $this->
getUser() );
347 if ( $timestamp ===
false ) {
350 return MWTimestamp::convert( TS_ISO_8601, $timestamp );
369 'theoreticalratelimits',
380 'apihelp-query+userinfo-paramvalue-prop-unreadcount',
381 self::WL_UNREAD_LIMIT - 1,
382 self::WL_UNREAD_LIMIT .
'+',
386 'attachedwiki' =>
null,
392 'action=query&meta=userinfo'
393 =>
'apihelp-query+userinfo-example-simple',
394 'action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg'
395 =>
'apihelp-query+userinfo-example-data',
400 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Userinfo';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
This is a base class for all Query modules.
Query module to get information about the currently logged-in user.
getExamplesMessages()
Returns usage examples for this module.
UserGroupManager $userGroupManager
static getCentralUserInfo(Config $config, UserIdentity $user, $attachedWiki=UserIdentity::LOCAL)
Get central user info.
getLatestContributionTime()
getHelpUrls()
Return links to more detailed help pages about the module.
UserOptionsLookup $userOptionsLookup
UserEditTracker $userEditTracker
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getRateLimits(bool $applyNoRateLimit)
Get the rate limits that apply to the user, or the rate limits that would apply if the user didn't ha...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
TalkPageNotificationManager $talkPageNotificationManager
__construct(ApiQuery $query, $moduleName, TalkPageNotificationManager $talkPageNotificationManager, WatchedItemStore $watchedItemStore, UserEditTracker $userEditTracker, UserOptionsLookup $userOptionsLookup, UserGroupManager $userGroupManager)
WatchedItemStore $watchedItemStore
This is the main query class.
const META_TYPE
Key for the 'type' metadata item.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
const META_BC_BOOLS
Key for the 'BC bools' metadata item.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
static formatExpiry( $expiry, $infinity='infinity')
Format an expiry timestamp for API output.
A class containing constants representing the names of configuration variables.
Manages user talk page notifications.
Storage layer class for WatchedItems.
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
if(!isset( $args[0])) $lang