40 private $linkBatchFactory;
43 private $loadBalancer;
46 private $userGroupManager;
49 private $userIdentityLookup;
63 parent::__construct(
'Activeusers' );
64 $this->linkBatchFactory = $linkBatchFactory;
65 $this->loadBalancer = $loadBalancer;
66 $this->userGroupManager = $userGroupManager;
67 $this->userIdentityLookup = $userIdentityLookup;
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,
103 $usersBody = $pager->getBody();
109 $pager->getNavigationBar() .
110 Html::rawElement(
'ul', [], $usersBody ) .
111 $pager->getNavigationBar()
113 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
115 $out->addWikiMsg(
'activeusers-noresult' );
123 $groups = $this->userGroupManager->listAllGroups();
127 foreach ( $groups as $group ) {
128 $msg = htmlspecialchars(
$lang->getGroupName( $group ) );
129 $options[$msg] = $group;
135 $excludeDefault = [];
136 if ( $req->getCheck(
'hidebots' ) ) {
137 $excludeDefault[] =
'bot';
139 if ( $req->getCheck(
'hidesysops' ) ) {
140 $excludeDefault[] =
'sysop';
146 'name' =>
'username',
147 'label-message' =>
'activeusers-from',
150 'type' =>
'multiselect',
154 'label-message' =>
'activeusers-groups',
155 'options' => $options,
158 'type' =>
'multiselect',
161 'name' =>
'excludegroups',
162 'label-message' =>
'activeusers-excludegroups',
163 'options' => $options,
164 'default' => $excludeDefault,
168 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
170 ->setFormIdentifier(
'specialactiveusers' )
172 ->setWrapperLegendMsg(
'activeusers' )
173 ->setSubmitTextMsg(
'activeusers-submit' )
178 ->displayForm(
false );
186 $days = $this->
getConfig()->get( MainConfigNames::ActiveUserDays );
188 $intro = $this->
msg(
'activeusers-intro' )->numParams( $days )->parse();
191 $dbr = $this->loadBalancer->getConnection( ILoadBalancer::DB_REPLICA );
192 $rcMax =
$dbr->newSelectQueryBuilder()
193 ->select(
'MAX(rc_timestamp)' )
194 ->from(
'recentchanges' )
195 ->caller( __METHOD__ )->fetchField();
197 $cTime =
$dbr->newSelectQueryBuilder()
198 ->select(
'qci_timestamp' )
199 ->from(
'querycache_info' )
200 ->where( [
'qci_type' =>
'activeusers' ] )
201 ->caller( __METHOD__ )->fetchField();
205 $rcMin =
$dbr->newSelectQueryBuilder()
206 ->select(
'MIN(rc_timestamp)' )
207 ->from(
'recentchanges' )
208 ->caller( __METHOD__ )->fetchField();
209 $secondsOld = time() - (int)
wfTimestamp( TS_UNIX, $rcMin );
211 if ( $secondsOld > 0 ) {
212 $intro .= $this->
msg(
'cachedspecial-viewing-cached-ttl' )
213 ->durationParams( $secondsOld )->parseAsBlock();
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.
Implements Special:Activeusers.
__construct(LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, UserGroupManager $userGroupManager, UserIdentityLookup $userIdentityLookup)
buildForm()
Generate and output the form.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getIntroText()
Return introductory message.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
if(!isset( $args[0])) $lang