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' => [],
97 ApiResult::setArrayType( $ret[
'centralids'],
'assoc' );
98 ApiResult::setArrayType( $ret[
'attachedlocal'],
'assoc' );
99 if ( $attachedWiki ) {
100 $ret[
'attachedwiki'] = [];
101 ApiResult::setArrayType( $ret[
'attachedwiki'],
'assoc' );
105 foreach ( $providerIds as $providerId ) {
106 $provider = CentralIdLookup::factory( $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();
140 ApiResult::setArrayType( $vals[
'groups'],
'array' );
141 ApiResult::setIndexedTagName( $vals[
'groups'],
'g' );
144 if ( isset( $this->prop[
'groupmemberships'] ) ) {
145 $ugms = $user->getGroupMemberships();
146 $vals[
'groupmemberships'] = [];
147 foreach ( $ugms as $group => $ugm ) {
148 $vals[
'groupmemberships'][] = [
150 'expiry' => ApiResult::formatExpiry( $ugm->getExpiry() ),
153 ApiResult::setArrayType( $vals[
'groupmemberships'],
'array' );
154 ApiResult::setIndexedTagName( $vals[
'groupmemberships'],
'groupmembership' );
157 if ( isset( $this->prop[
'implicitgroups'] ) ) {
158 $vals[
'implicitgroups'] = $user->getAutomaticGroups();
159 ApiResult::setArrayType( $vals[
'implicitgroups'],
'array' );
160 ApiResult::setIndexedTagName( $vals[
'implicitgroups'],
'g' );
163 if ( isset( $this->prop[
'rights'] ) ) {
165 ApiResult::setArrayType( $vals[
'rights'],
'array' );
166 ApiResult::setIndexedTagName( $vals[
'rights'],
'r' );
169 if ( isset( $this->prop[
'changeablegroups'] ) ) {
170 $vals[
'changeablegroups'] = $user->changeableGroups();
171 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'add'],
'g' );
172 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'remove'],
'g' );
173 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'add-self'],
'g' );
174 ApiResult::setIndexedTagName( $vals[
'changeablegroups'][
'remove-self'],
'g' );
177 if ( isset( $this->prop[
'options'] ) ) {
178 $vals[
'options'] = $user->getOptions();
179 $vals[
'options'][ApiResult::META_BC_BOOLS] = array_keys( $vals[
'options'] );
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 ];
226 ApiResult::setContentValue( $r,
'code',
$lang );
229 ApiResult::setIndexedTagName( $acceptLang,
'lang' );
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;
265 ApiResult::META_TYPE =>
'assoc',
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';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
getMain()
Get the main module.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
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.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
lacksSameOriginSecurity()
Returns true if the current request breaks the same-origin policy.
This is a base class for all Query modules.
getDB()
Get the Query database connection (read-only)
Query module to get information about the currently logged-in user.
getExamplesMessages()
Returns usage examples for this module.
getLatestContributionTime()
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
static getCentralUserInfo(Config $config, User $user, $attachedWiki=null)
Get central user info.
static getBlockInfo(AbstractBlock $block)
Get basic info about a given block.
__construct(ApiQuery $query, $moduleName)
This is the main query class.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
if(!isset( $args[0])) $lang