10use MediaWiki\Cache\LinkBatchFactory;
15use MediaWiki\Pager\ActiveUsersPager;
22use Wikimedia\Timestamp\TimestampFormat as TS;
31 private LinkBatchFactory $linkBatchFactory;
40 LinkBatchFactory $linkBatchFactory,
48 parent::__construct(
'Activeusers' );
49 $this->linkBatchFactory = $linkBatchFactory;
50 $this->dbProvider = $dbProvider;
51 $this->userGroupManager = $userGroupManager;
52 $this->userIdentityLookup = $userIdentityLookup;
53 $this->hideUserUtils = $hideUserUtils;
54 $this->tempUserConfig = $tempUserConfig;
55 $this->recentChangeLookup = $recentChangeLookup;
69 $opts->add(
'username',
'' );
70 $opts->add(
'groups', [] );
71 $opts->add(
'excludegroups', [] );
73 $opts->add(
'hidebots',
false, FormOptions::BOOL );
74 $opts->add(
'hidesysops',
false, FormOptions::BOOL );
76 $opts->fetchValuesFromRequest( $this->
getRequest() );
78 if ( $par !==
null ) {
79 $opts->setValue(
'username', $par );
82 $pager =
new ActiveUsersPager(
85 $this->linkBatchFactory,
87 $this->userGroupManager,
88 $this->userIdentityLookup,
90 $this->tempUserConfig,
91 $this->recentChangeLookup,
94 $usersBody = $pager->getBody();
100 $pager->getNavigationBar() .
101 Html::rawElement(
'ul', [], $usersBody ) .
102 $pager->getNavigationBar()
104 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
106 $out->addWikiMsg(
'activeusers-noresult' );
114 $groups = $this->userGroupManager->listAllGroups();
118 foreach ( $groups as $group ) {
119 $msg = htmlspecialchars( $lang->getGroupName( $group ) );
120 $options[$msg] = $group;
126 $excludeDefault = [];
127 if ( $req->getCheck(
'hidebots' ) ) {
128 $excludeDefault[] =
'bot';
130 if ( $req->getCheck(
'hidesysops' ) ) {
131 $excludeDefault[] =
'sysop';
137 'name' =>
'username',
138 'label-message' =>
'activeusers-from',
141 'type' =>
'multiselect',
145 'label-message' =>
'activeusers-groups',
146 'options' => $options,
149 'type' =>
'multiselect',
152 'name' =>
'excludegroups',
153 'label-message' =>
'activeusers-excludegroups',
154 'options' => $options,
155 'default' => $excludeDefault,
159 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
161 ->setFormIdentifier(
'specialactiveusers' )
163 ->setWrapperLegendMsg(
'activeusers' )
164 ->setSubmitTextMsg(
'activeusers-submit' )
169 ->displayForm(
false );
179 $intro = $this->
msg(
'activeusers-intro' )->numParams( $days )->parse();
182 $dbr = $this->dbProvider->getReplicaDatabase();
184 $rcMax = $dbr->newSelectQueryBuilder()
185 ->select(
'MAX(rc_timestamp)' )
186 ->from(
'recentchanges' )
187 ->caller( __METHOD__ )->fetchField();
189 $cTime = $dbr->newSelectQueryBuilder()
190 ->select(
'qci_timestamp' )
191 ->from(
'querycache_info' )
192 ->where( [
'qci_type' =>
'activeusers' ] )
193 ->caller( __METHOD__ )->fetchField();
197 $rcMin = $dbr->newSelectQueryBuilder()
198 ->select(
'MIN(rc_timestamp)' )
199 ->from(
'recentchanges' )
200 ->caller( __METHOD__ )->fetchField();
201 $secondsOld = time() - (int)
wfTimestamp( TS::UNIX, $rcMin );
203 if ( $secondsOld > 0 ) {
204 $intro .= $this->
msg(
'cachedspecial-viewing-cached-ttl' )
205 ->durationParams( $secondsOld )->parseAsBlock();
219class_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...