24 namespace MediaWiki\Specials;
61 parent::__construct(
'Activeusers' );
62 $this->linkBatchFactory = $linkBatchFactory;
63 $this->dbProvider = $dbProvider;
64 $this->userGroupManager = $userGroupManager;
65 $this->userIdentityLookup = $userIdentityLookup;
79 $opts->add(
'username',
'' );
80 $opts->add(
'groups', [] );
81 $opts->add(
'excludegroups', [] );
86 $opts->fetchValuesFromRequest( $this->
getRequest() );
88 if ( $par !==
null ) {
89 $opts->setValue(
'username', $par );
95 $this->linkBatchFactory,
97 $this->userGroupManager,
98 $this->userIdentityLookup,
101 $usersBody = $pager->getBody();
107 $pager->getNavigationBar() .
109 $pager->getNavigationBar()
111 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
113 $out->addWikiMsg(
'activeusers-noresult' );
121 $groups = $this->userGroupManager->listAllGroups();
125 foreach ( $groups as $group ) {
126 $msg = htmlspecialchars( $lang->getGroupName( $group ) );
127 $options[$msg] = $group;
133 $excludeDefault = [];
134 if ( $req->getCheck(
'hidebots' ) ) {
135 $excludeDefault[] =
'bot';
137 if ( $req->getCheck(
'hidesysops' ) ) {
138 $excludeDefault[] =
'sysop';
144 'name' =>
'username',
145 'label-message' =>
'activeusers-from',
148 'type' =>
'multiselect',
152 'label-message' =>
'activeusers-groups',
153 'options' => $options,
156 'type' =>
'multiselect',
159 'name' =>
'excludegroups',
160 'label-message' =>
'activeusers-excludegroups',
161 'options' => $options,
162 'default' => $excludeDefault,
168 ->setFormIdentifier(
'specialactiveusers' )
170 ->setWrapperLegendMsg(
'activeusers' )
171 ->setSubmitTextMsg(
'activeusers-submit' )
176 ->displayForm(
false );
186 $intro = $this->
msg(
'activeusers-intro' )->numParams( $days )->parse();
189 $dbr = $this->dbProvider->getReplicaDatabase();
191 $rcMax = $dbr->newSelectQueryBuilder()
192 ->select(
'MAX(rc_timestamp)' )
193 ->from(
'recentchanges' )
194 ->caller( __METHOD__ )->fetchField();
196 $cTime = $dbr->newSelectQueryBuilder()
197 ->select(
'qci_timestamp' )
198 ->from(
'querycache_info' )
199 ->where( [
'qci_type' =>
'activeusers' ] )
200 ->caller( __METHOD__ )->fetchField();
204 $rcMin = $dbr->newSelectQueryBuilder()
205 ->select(
'MIN(rc_timestamp)' )
206 ->from(
'recentchanges' )
207 ->caller( __METHOD__ )->fetchField();
208 $secondsOld = time() - (int)
wfTimestamp( TS_UNIX, $rcMin );
210 if ( $secondsOld > 0 ) {
211 $intro .= $this->
msg(
'cachedspecial-viewing-cached-ttl' )
212 ->durationParams( $secondsOld )->parseAsBlock();
227 class_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 Per default the message key is the canonical name o...