2 # Copyright (C) 2008 Aaron Schulz
4 # http://www.mediawiki.org/
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # http://www.gnu.org/copyleft/gpl.html
22 * This class is used to get a list of active users. The ones with specials
23 * rights (sysop, bureaucrat, developer) will have them displayed
24 * next to their names.
27 * @ingroup SpecialPage
29 class ActiveUsersPager
extends UsersPager
{
31 function __construct( $group = null ) {
33 $un = $wgRequest->getText( 'username' );
34 $this->requestedUser
= '';
36 $username = Title
::makeTitleSafe( NS_USER
, $un );
37 if( !is_null( $username ) ) {
38 $this->requestedUser
= $username->getText();
41 parent
::__construct();
44 function getIndexField() {
45 return 'rc_user_text';
48 function getQueryInfo() {
49 $dbr = wfGetDB( DB_SLAVE
);
50 $conds = array( 'rc_user > 0' ); // Users - no anons
51 $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names
52 $conds[] = 'rc_log_type IS NULL OR rc_log_type != "newusers"';
53 if( $this->requestedUser
!= '' ) {
54 $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser
);
58 'tables' => array( 'recentchanges', 'user', 'ipblocks' ),
59 'fields' => array( 'rc_user_text AS user_name', // inheritance
60 'rc_user_text', // for Pager
62 'COUNT(*) AS recentedits',
63 'MAX(ipb_user) AS blocked'
66 'GROUP BY' => 'rc_user_text',
67 'USE INDEX' => array( 'recentchanges' => 'rc_user_text' )
69 'join_conds' => array(
70 'user' => array( 'INNER JOIN', 'rc_user_text=user_name' ),
71 'ipblocks' => array( 'LEFT JOIN', 'user_id=ipb_user AND ipb_auto=0 AND ipb_deleted=1' ),
78 function formatRow( $row ) {
79 $userName = $row->user_name
;
80 $userPage = Title
::makeTitle( NS_USER
, $userName );
81 $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
84 foreach( self
::getGroups( $row->user_id
) as $group )
85 $list[] = self
::buildGroupLink( $group );
86 $groups = implode( ', ', $list );
88 $item = wfSpecialList( $name, $groups );
89 $count = wfMsgExt( 'activeusers-count', array( 'parsemag' ), $row->recentedits
, $userName );
90 $blocked = $row->blocked ?
' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : '';
92 return "<li>{$item} [{$count}]{$blocked}</li>";
95 function getPageHeader() {
96 global $wgScript, $wgRequest;
97 $self = $this->getTitle();
100 $out = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
102 Xml
::element( 'legend', array(), wfMsg( 'activeusers' ) );
103 $out .= Xml
::hidden( 'title', $self->getPrefixedDBkey() );
106 $out .= Xml
::label( wfMsg( 'activeusers-from' ), 'offset' ) . ' ' .
107 Xml
::input( 'username', 20, $this->requestedUser
, array( 'id' => 'offset' ) ) . ' ';
109 # Submit button and form bottom
111 $out .= Xml
::hidden( 'limit', $this->mLimit
);
112 $out .= Xml
::submitButton( wfMsg( 'allpagessubmit' ) );
114 $out .= '</fieldset>' . Xml
::closeElement( 'form' );
121 * @ingroup SpecialPage
123 class SpecialActiveUsers
extends SpecialPage
{
128 public function __construct() {
129 parent
::__construct( 'Activeusers' );
133 * Show the special page
135 * @param $par Mixed: parameter passed to the page or null
137 public function execute( $par ) {
142 $up = new ActiveUsersPager();
144 # getBody() first to check, if empty
145 $usersbody = $up->getBody();
146 $s = $up->getPageHeader();
148 $s .= $up->getNavigationBar();
149 $s .= '<ul>' . $usersbody . '</ul>';
150 $s .= $up->getNavigationBar();
152 $s .= '<p>' . wfMsgHtml( 'activeusers-noresult' ) . '</p>';
155 $wgOut->addHTML( $s );