54 parent::__construct(
'Activeusers' );
71 $opts->add(
'username',
'' );
72 $opts->add(
'groups', [] );
73 $opts->add(
'excludegroups', [] );
75 $opts->add(
'hidebots',
false, FormOptions::BOOL );
76 $opts->add(
'hidesysops',
false, FormOptions::BOOL );
78 $opts->fetchValuesFromRequest( $this->
getRequest() );
80 if ( $par !==
null ) {
81 $opts->setValue(
'username', $par );
87 $this->linkBatchFactory,
90 $this->userGroupManager
92 $usersBody = $pager->getBody();
98 $pager->getNavigationBar() .
99 Html::rawElement(
'ul', [], $usersBody ) .
100 $pager->getNavigationBar()
102 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
104 $out->addWikiMsg(
'activeusers-noresult' );
112 $groups = $this->userGroupManager->listAllGroups();
115 foreach ( $groups as $group ) {
116 $msg = htmlspecialchars( UserGroupMembership::getGroupName( $group ) );
117 $options[$msg] = $group;
123 $excludeDefault = [];
124 if ( $req->getCheck(
'hidebots' ) ) {
125 $excludeDefault[] =
'bot';
127 if ( $req->getCheck(
'hidesysops' ) ) {
128 $excludeDefault[] =
'sysop';
134 'name' =>
'username',
135 'label-message' =>
'activeusers-from',
138 'type' =>
'multiselect',
142 'label-message' =>
'activeusers-groups',
143 'options' => $options,
146 'type' =>
'multiselect',
149 'name' =>
'excludegroups',
150 'label-message' =>
'activeusers-excludegroups',
151 'options' => $options,
152 'default' => $excludeDefault,
156 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
158 ->setFormIdentifier(
'specialactiveusers' )
160 ->setWrapperLegendMsg(
'activeusers' )
161 ->setSubmitTextMsg(
'activeusers-submit' )
166 ->displayForm(
false );
174 $days = $this->
getConfig()->get(
'ActiveUserDays' );
176 $intro = $this->
msg(
'activeusers-intro' )->numParams( $days )->parse();
179 $dbr = $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA,
'recentchanges' );
180 $rcMax =
$dbr->selectField(
'recentchanges',
'MAX(rc_timestamp)',
'', __METHOD__ );
182 $cTime =
$dbr->selectField(
'querycache_info',
184 [
'qci_type' =>
'activeusers' ],
190 $rcMin =
$dbr->selectField(
'recentchanges',
'MIN(rc_timestamp)',
'', __METHOD__ );
191 $secondsOld = time() -
wfTimestamp( TS_UNIX, $rcMin );
193 if ( $secondsOld > 0 ) {
194 $intro .= $this->
msg(
'cachedspecial-viewing-cached-ttl' )
195 ->durationParams( $secondsOld )->parseAsBlock();
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Implements Special:Activeusers.
__construct(LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, UserGroupManager $userGroupManager)
LinkBatchFactory $linkBatchFactory
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.
UserGroupManager $userGroupManager
ILoadBalancer $loadBalancer
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.