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 * @ingroup SpecialPage
29 class SpecialActiveUsers
extends SpecialPage
{
34 public function __construct() {
35 parent
::__construct( 'Activeusers' );
39 * Show the special page
41 * @param string $par Parameter passed to the page or null
43 public function execute( $par ) {
44 $days = $this->getConfig()->get( 'ActiveUserDays' );
47 $this->outputHeader();
49 $out = $this->getOutput();
50 $out->wrapWikiMsg( "<div class='mw-activeusers-intro'>\n$1\n</div>",
51 [ 'activeusers-intro', $this->getLanguage()->formatNum( $days ) ] );
53 // Mention the level of cache staleness...
54 $dbr = wfGetDB( DB_SLAVE
, 'recentchanges' );
55 $rcMax = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__
);
57 $cTime = $dbr->selectField( 'querycache_info',
59 [ 'qci_type' => 'activeusers' ],
63 $secondsOld = wfTimestamp( TS_UNIX
, $rcMax ) - wfTimestamp( TS_UNIX
, $cTime );
65 $rcMin = $dbr->selectField( 'recentchanges', 'MIN(rc_timestamp)' );
66 $secondsOld = time() - wfTimestamp( TS_UNIX
, $rcMin );
68 if ( $secondsOld > 0 ) {
69 $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl',
70 $this->getLanguage()->formatDuration( $secondsOld ) );
74 $up = new ActiveUsersPager( $this->getContext(), null, $par );
76 # getBody() first to check, if empty
77 $usersbody = $up->getBody();
79 $out->addHTML( $up->getPageHeader() );
82 $up->getNavigationBar() .
83 Html
::rawElement( 'ul', [], $usersbody ) .
84 $up->getNavigationBar()
87 $out->addWikiMsg( 'activeusers-noresult' );
91 protected function getGroupName() {