62 parent::__construct(
'Activeusers' );
63 $this->linkBatchFactory = $linkBatchFactory;
64 $this->dbProvider = $dbProvider;
65 $this->userGroupManager = $userGroupManager;
66 $this->userIdentityLookup = $userIdentityLookup;
67 $this->hideUserUtils = $hideUserUtils;
81 $opts->add(
'username',
'' );
82 $opts->add(
'groups', [] );
83 $opts->add(
'excludegroups', [] );
85 $opts->add(
'hidebots',
false, FormOptions::BOOL );
86 $opts->add(
'hidesysops',
false, FormOptions::BOOL );
88 $opts->fetchValuesFromRequest( $this->
getRequest() );
90 if ( $par !==
null ) {
91 $opts->setValue(
'username', $par );
97 $this->linkBatchFactory,
99 $this->userGroupManager,
100 $this->userIdentityLookup,
101 $this->hideUserUtils,
104 $usersBody = $pager->getBody();
110 $pager->getNavigationBar() .
111 Html::rawElement(
'ul', [], $usersBody ) .
112 $pager->getNavigationBar()
114 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
116 $out->addWikiMsg(
'activeusers-noresult' );
124 $groups = $this->userGroupManager->listAllGroups();
128 foreach ( $groups as $group ) {
129 $msg = htmlspecialchars( $lang->getGroupName( $group ) );
130 $options[$msg] = $group;
136 $excludeDefault = [];
137 if ( $req->getCheck(
'hidebots' ) ) {
138 $excludeDefault[] =
'bot';
140 if ( $req->getCheck(
'hidesysops' ) ) {
141 $excludeDefault[] =
'sysop';
147 'name' =>
'username',
148 'label-message' =>
'activeusers-from',
151 'type' =>
'multiselect',
155 'label-message' =>
'activeusers-groups',
156 'options' => $options,
159 'type' =>
'multiselect',
162 'name' =>
'excludegroups',
163 'label-message' =>
'activeusers-excludegroups',
164 'options' => $options,
165 'default' => $excludeDefault,
169 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
171 ->setFormIdentifier(
'specialactiveusers' )
173 ->setWrapperLegendMsg(
'activeusers' )
174 ->setSubmitTextMsg(
'activeusers-submit' )
179 ->displayForm(
false );
189 $intro = $this->
msg(
'activeusers-intro' )->numParams( $days )->parse();
192 $dbr = $this->dbProvider->getReplicaDatabase();
194 $rcMax = $dbr->newSelectQueryBuilder()
195 ->select(
'MAX(rc_timestamp)' )
196 ->from(
'recentchanges' )
197 ->caller( __METHOD__ )->fetchField();
199 $cTime = $dbr->newSelectQueryBuilder()
200 ->select(
'qci_timestamp' )
201 ->from(
'querycache_info' )
202 ->where( [
'qci_type' =>
'activeusers' ] )
203 ->caller( __METHOD__ )->fetchField();
207 $rcMin = $dbr->newSelectQueryBuilder()
208 ->select(
'MIN(rc_timestamp)' )
209 ->from(
'recentchanges' )
210 ->caller( __METHOD__ )->fetchField();
211 $secondsOld = time() - (int)
wfTimestamp( TS_UNIX, $rcMin );
213 if ( $secondsOld > 0 ) {
214 $intro .= $this->
msg(
'cachedspecial-viewing-cached-ttl' )
215 ->durationParams( $secondsOld )->parseAsBlock();
228class_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()
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...