Go to the documentation of this file.
33 use ApiBlockInfoTrait;
43 parent::__construct( $query, $moduleName,
'ui' );
50 if ( !is_null( $this->params[
'prop'] ) ) {
51 $this->prop = array_flip( $this->params[
'prop'] );
70 use ApiBlockInfoTrait {
71 getBlockDetails as
public;
75 return $dummy->getBlockDetails( $block );
91 $providerIds = array_keys( $config->
get(
'CentralIdLookupProviders' ) );
95 'attachedlocal' => [],
99 if ( $attachedWiki ) {
100 $ret[
'attachedwiki'] = [];
105 foreach ( $providerIds as $providerId ) {
107 $ret[
'centralids'][$providerId] = $provider->centralIdFromName( $name );
108 $ret[
'attachedlocal'][$providerId] = $provider->isAttached( $user );
109 if ( $attachedWiki ) {
110 $ret[
'attachedwiki'][$providerId] = $provider->isAttached( $user, $attachedWiki );
120 $vals[
'id'] = (int)$user->getId();
121 $vals[
'name'] = $user->getName();
123 if ( $user->isAnon() ) {
124 $vals[
'anon'] =
true;
127 if ( isset( $this->prop[
'blockinfo'] ) ) {
128 $block = $user->getBlock();
130 $vals = array_merge( $vals, $this->getBlockDetails( $block ) );
134 if ( isset( $this->prop[
'hasmsg'] ) ) {
135 $vals[
'messages'] = $user->getNewtalk();
138 if ( isset( $this->prop[
'groups'] ) ) {
139 $vals[
'groups'] = $user->getEffectiveGroups();
144 if ( isset( $this->prop[
'groupmemberships'] ) ) {
145 $ugms = $user->getGroupMemberships();
146 $vals[
'groupmemberships'] = [];
147 foreach ( $ugms as $group => $ugm ) {
148 $vals[
'groupmemberships'][] = [
157 if ( isset( $this->prop[
'implicitgroups'] ) ) {
158 $vals[
'implicitgroups'] = $user->getAutomaticGroups();
163 if ( isset( $this->prop[
'rights'] ) ) {
169 if ( isset( $this->prop[
'changeablegroups'] ) ) {
170 $vals[
'changeablegroups'] = $user->changeableGroups();
177 if ( isset( $this->prop[
'options'] ) ) {
178 $vals[
'options'] = $user->getOptions();
182 if ( isset( $this->prop[
'preferencestoken'] ) &&
186 $vals[
'preferencestoken'] = $user->getEditToken(
'', $this->
getMain()->
getRequest() );
189 if ( isset( $this->prop[
'editcount'] ) ) {
192 $vals[
'editcount'] = (int)$user->getEditCount();
195 if ( isset( $this->prop[
'ratelimits'] ) ) {
199 if ( isset( $this->prop[
'realname'] ) &&
200 !in_array(
'realname', $this->
getConfig()->
get(
'HiddenPrefs' ) )
202 $vals[
'realname'] = $user->getRealName();
206 isset( $this->prop[
'email'] ) ) {
207 $vals[
'email'] = $user->getEmail();
208 $auth = $user->getEmailAuthenticationTimestamp();
209 if ( $auth !==
null ) {
210 $vals[
'emailauthenticated'] =
wfTimestamp( TS_ISO_8601, $auth );
214 if ( isset( $this->prop[
'registrationdate'] ) ) {
215 $regDate = $user->getRegistration();
216 if ( $regDate !==
false ) {
217 $vals[
'registrationdate'] =
wfTimestamp( TS_ISO_8601, $regDate );
221 if ( isset( $this->prop[
'acceptlang'] ) ) {
222 $langs = $this->
getRequest()->getAcceptLang();
224 foreach ( $langs as
$lang => $val ) {
225 $r = [
'q' => $val ];
230 $vals[
'acceptlang'] = $acceptLang;
233 if ( isset( $this->prop[
'unreadcount'] ) ) {
234 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
235 $unreadNotifications = $store->countUnreadNotifications(
237 self::WL_UNREAD_LIMIT
240 if ( $unreadNotifications ===
true ) {
241 $vals[
'unreadcount'] = self::WL_UNREAD_LIMIT .
'+';
243 $vals[
'unreadcount'] = $unreadNotifications;
247 if ( isset( $this->prop[
'centralids'] ) ) {
253 if ( isset( $this->prop[
'latestcontrib'] ) ) {
255 if ( $ts !==
null ) {
256 $vals[
'latestcontrib'] = $ts;
269 if ( !$user->isPingLimitable() ) {
275 if ( $user->isAnon() ) {
276 $categories[] =
'anon';
278 $categories[] =
'user';
280 if ( $user->isNewbie() ) {
281 $categories[] =
'ip';
282 $categories[] =
'subnet';
283 if ( !$user->isAnon() ) {
284 $categories[] =
'newbie';
287 $categories = array_merge( $categories, $user->getGroups() );
290 foreach ( $this->
getConfig()->get(
'RateLimits' ) as $action => $limits ) {
291 foreach ( $categories as $cat ) {
292 if ( isset( $limits[$cat] ) && !is_null( $limits[$cat] ) ) {
293 $retval[$action][$cat][
'hits'] = (int)$limits[$cat][0];
294 $retval[$action][$cat][
'seconds'] = (int)$limits[$cat][1];
309 if ( $user->getActorId() === null ) {
312 $res =
$dbr->selectField(
'revision_actor_temp',
313 'MAX(revactor_timestamp)',
314 [
'revactor_actor' => $user->getActorId() ],
347 'apihelp-query+userinfo-paramvalue-prop-unreadcount',
348 self::WL_UNREAD_LIMIT - 1,
349 self::WL_UNREAD_LIMIT .
'+',
353 'preferencestoken' => [
354 'apiwarn-deprecation-withreplacement',
356 'action=query&meta=tokens',
360 'attachedwiki' =>
null,
366 'action=query&meta=userinfo'
367 =>
'apihelp-query+userinfo-example-simple',
368 'action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg'
369 =>
'apihelp-query+userinfo-example-data',
374 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Userinfo';
This is the main query class.
getLatestContributionTime()
if(!isset( $args[0])) $lang
const META_TYPE
Key for the 'type' metadata item.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Query module to get information about the currently logged-in user.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
Interface for configuration instances.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getExamplesMessages()
Returns usage examples for this module.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
This is a base class for all Query modules.
getDB()
Get the Query database connection (read-only)
const META_BC_BOOLS
Key for the 'BC bools' metadata item.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
__construct(ApiQuery $query, $moduleName)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
static formatExpiry( $expiry, $infinity='infinity')
Format an expiry timestamp for API output.
getMain()
Get the main module.
static getCentralUserInfo(Config $config, User $user, $attachedWiki=null)
Get central user info.
static factory( $providerId=null)
Fetch a CentralIdLookup.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getHelpUrls()
Return links to more detailed help pages about the module.
getName()
Get the user name, or the IP of an anonymous user.
static getBlockInfo(AbstractBlock $block)
Get basic info about a given block.