3 # Copyright (C) 2008 Aaron Schulz
5 # http://www.mediawiki.org/
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 * @addtogroup SpecialPage
27 * This class is used to get a list of user. The ones with specials
28 * rights (sysop, bureaucrat, developer) will have them displayed
29 * next to their names.
31 * @addtogroup SpecialPage
34 class ActiveUsersPager
extends UsersPager
{
36 function __construct($group=null) {
38 $un = $wgRequest->getText( 'username' );
39 $this->requestedUser
= '';
41 $username = Title
::makeTitleSafe( NS_USER
, $un );
42 if( ! is_null( $username ) ) {
43 $this->requestedUser
= $username->getText();
46 parent
::__construct();
50 function getIndexField() {
51 return 'rc_user_text';
54 function getQueryInfo() {
55 $dbr = wfGetDB( DB_SLAVE
);
56 $conds = array('rc_user > 0'); // Users - no anons
57 $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names
58 $useIndex = $dbr->useIndexClause('rc_user_text');
59 if( $this->requestedUser
!= "" ) {
60 $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser
);
63 list ($recentchanges,$ipblocks,$user) = $dbr->tableNamesN('recentchanges','ipblocks','user');
66 'tables' => " $recentchanges $useIndex
67 LEFT JOIN $ipblocks ON rc_user=ipb_user AND ipb_auto=0 AND ipb_deleted=1
68 INNER JOIN $user ON rc_user=user_id ",
69 'fields' => array('rc_user_text AS user_name', // inheritance
70 'rc_user_text', // for Pager
71 'MAX(rc_user) AS user_id',
72 'COUNT(*) AS recentedits',
73 'MAX(ipb_user) AS blocked'),
74 'options' => array('GROUP BY' => 'rc_user_text'),
80 function formatRow( $row ) {
81 $userName = $row->rc_user_text
;
82 $userPage = Title
::makeTitle( NS_USER
, $userName );
83 $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
86 foreach( self
::getGroups( $row->user_id
) as $group )
87 $list[] = self
::buildGroupLink( $group );
88 $groups = implode( ', ', $list );
90 $item = wfSpecialList( $name, $groups );
91 $count = wfMsgExt( 'activeusers-count', array('parsemag'), $row->recentedits
, $userName );
92 $blocked = $row->blocked ?
' ' . wfMsgExt( 'listusers-blocked', array( 'parsemag' ), $userName ) : '';
94 return "<li>{$item} [{$count}]{$blocked}</li>";
97 function getPageHeader() {
98 global $wgScript, $wgRequest;
99 $self = $this->getTitle();
102 $out = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
104 Xml
::element( 'legend', array(), wfMsg( 'activeusers' ) );
105 $out .= Xml
::hidden( 'title', $self->getPrefixedDbKey() );
108 $out .= Xml
::label( wfMsg( 'activeusers-from' ), 'offset' ) . ' ' .
109 Xml
::input( 'username', 20, $this->requestedUser
, array( 'id' => 'offset' ) ) . ' ';
111 # Submit button and form bottom
113 $out .= Xml
::hidden( 'limit', $this->mLimit
);
114 $out .= Xml
::submitButton( wfMsg( 'allpagessubmit' ) );
116 $out .= '</fieldset>' . Xml
::closeElement( 'form' );
124 * $par string (optional) A group to list users from
126 function wfSpecialActiveusers( $par = null ) {
127 global $wgRequest, $wgOut;
129 $up = new ActiveUsersPager();
131 # getBody() first to check, if empty
132 $usersbody = $up->getBody();
133 $s = $up->getPageHeader();
135 $s .= $up->getNavigationBar();
136 $s .= '<ul>' . $usersbody . '</ul>';
137 $s .= $up->getNavigationBar() ;
139 $s .= '<p>' . wfMsgHTML('activeusers-noresult') . '</p>';
142 $wgOut->addHTML( $s );