3 * Implements Special:Activeusers
5 * Copyright © 2008 Aaron Schulz
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
23 * @ingroup SpecialPage
27 * Implements Special:Activeusers
29 * @ingroup SpecialPage
31 class SpecialActiveUsers
extends SpecialPage
{
36 public function __construct() {
37 parent
::__construct( 'Activeusers' );
41 * Show the special page
43 * @param string $par Parameter passed to the page or null
45 public function execute( $par ) {
46 $out = $this->getOutput();
49 $this->outputHeader();
51 $opts = new FormOptions();
53 $opts->add( 'username', '' );
54 $opts->add( 'hidebots', false, FormOptions
::BOOL );
55 $opts->add( 'hidesysops', false, FormOptions
::BOOL );
57 $opts->fetchValuesFromRequest( $this->getRequest() );
59 if ( $par !== null ) {
60 $opts->setValue( 'username', $par );
63 // Mention the level of cache staleness...
65 $dbr = wfGetDB( DB_SLAVE
, 'recentchanges' );
66 $rcMax = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__
);
68 $cTime = $dbr->selectField( 'querycache_info',
70 [ 'qci_type' => 'activeusers' ],
74 $secondsOld = wfTimestamp( TS_UNIX
, $rcMax ) - wfTimestamp( TS_UNIX
, $cTime );
76 $rcMin = $dbr->selectField( 'recentchanges', 'MIN(rc_timestamp)' );
77 $secondsOld = time() - wfTimestamp( TS_UNIX
, $rcMin );
79 if ( $secondsOld > 0 ) {
80 $cacheTxt = '<br>' . $this->msg( 'cachedspecial-viewing-cached-ttl' )
81 ->durationParams( $secondsOld );
85 $pager = new ActiveUsersPager( $this->getContext(), $opts );
86 $usersBody = $pager->getBody();
88 $days = $this->getConfig()->get( 'ActiveUserDays' );
94 'label-message' => 'activeusers-from',
100 'label-message' => 'activeusers-hidebots',
106 'name' => 'hidesysops',
107 'label-message' => 'activeusers-hidesysops',
112 $htmlForm = HTMLForm
::factory( 'ooui', $formDescriptor, $this->getContext() )
113 ->setIntro( $this->msg( 'activeusers-intro' )->numParams( $days ) . $cacheText )
114 ->setWrapperLegendMsg( 'activeusers' )
115 ->setSubmitTextMsg( 'activeusers-submit' )
118 ->displayForm( false );
122 $pager->getNavigationBar() .
123 Html
::rawElement( 'ul', [], $usersBody ) .
124 $pager->getNavigationBar()
127 $out->addWikiMsg( 'activeusers-noresult' );
131 protected function getGroupName() {