22use Wikimedia\Timestamp\TimestampFormat as TS;
40 parent::__construct(
'Activeusers' );
54 $opts->add(
'username',
'' );
55 $opts->add(
'groups', [] );
56 $opts->add(
'excludegroups', [] );
58 $opts->add(
'hidebots',
false, FormOptions::BOOL );
59 $opts->add(
'hidesysops',
false, FormOptions::BOOL );
61 $opts->fetchValuesFromRequest( $this->
getRequest() );
63 if ( $par !==
null ) {
64 $opts->setValue(
'username', $par );
70 $this->linkBatchFactory,
72 $this->userGroupManager,
73 $this->userIdentityLookup,
75 $this->tempUserConfig,
76 $this->recentChangeLookup,
79 $usersBody = $pager->getBody();
85 $pager->getNavigationBar() .
86 Html::rawElement(
'ul', [], $usersBody ) .
87 $pager->getNavigationBar()
89 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
91 $out->addWikiMsg(
'activeusers-noresult' );
99 $groups = $this->userGroupManager->listAllGroups();
103 foreach ( $groups as $group ) {
104 $msg = htmlspecialchars( $lang->getGroupName( $group ) );
105 $options[$msg] = $group;
111 $excludeDefault = [];
112 if ( $req->getCheck(
'hidebots' ) ) {
113 $excludeDefault[] =
'bot';
115 if ( $req->getCheck(
'hidesysops' ) ) {
116 $excludeDefault[] =
'sysop';
122 'name' =>
'username',
123 'label-message' =>
'activeusers-from',
126 'type' =>
'multiselect',
130 'label-message' =>
'activeusers-groups',
131 'options' => $options,
134 'type' =>
'multiselect',
137 'name' =>
'excludegroups',
138 'label-message' =>
'activeusers-excludegroups',
139 'options' => $options,
140 'default' => $excludeDefault,
144 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
146 ->setFormIdentifier(
'specialactiveusers' )
148 ->setWrapperLegendMsg(
'activeusers' )
149 ->setSubmitTextMsg(
'activeusers-submit' )
154 ->displayForm(
false );
164 $intro = $this->
msg(
'activeusers-intro' )->numParams( $days )->parse();
167 $dbr = $this->dbProvider->getReplicaDatabase();
169 $rcMax = $dbr->newSelectQueryBuilder()
170 ->select(
'MAX(rc_timestamp)' )
171 ->from(
'recentchanges' )
172 ->caller( __METHOD__ )->fetchField();
174 $cTime = $dbr->newSelectQueryBuilder()
175 ->select(
'qci_timestamp' )
176 ->from(
'querycache_info' )
177 ->where( [
'qci_type' =>
'activeusers' ] )
178 ->caller( __METHOD__ )->fetchField();
182 $rcMin = $dbr->newSelectQueryBuilder()
183 ->select(
'MIN(rc_timestamp)' )
184 ->from(
'recentchanges' )
185 ->caller( __METHOD__ )->fetchField();
186 $secondsOld = time() - (int)
wfTimestamp( TS::UNIX, $rcMin );
188 if ( $secondsOld > 0 ) {
189 $intro .= $this->
msg(
'cachedspecial-viewing-cached-ttl' )
190 ->durationParams( $secondsOld )->parseAsBlock();
204class_alias( SpecialActiveUsers::class,
'SpecialActiveUsers' );
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 ActiveUserDays
Name constant for the ActiveUserDays setting, for use with Config::get()
Factory for LinkBatch objects to batch query page metadata.
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getPageTitle( $subpage=false)
Get a self-referential title object.
getConfig()
Shortcut to get main config object.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...