Show change flag tooltips everywhere, not just RC
[lhc/web/wiklou.git] / includes / specials / SpecialActiveusers.php
1 <?php
2 # Copyright (C) 2008 Aaron Schulz
3 #
4 # http://www.mediawiki.org/
5 #
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.
10 #
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.
15 #
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
20
21 /**
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.
25 *
26 * @file
27 * @ingroup SpecialPage
28 */
29 class ActiveUsersPager extends UsersPager {
30
31 function __construct( $group = null ) {
32 global $wgRequest;
33 $un = $wgRequest->getText( 'username' );
34 $this->requestedUser = '';
35 if ( $un != '' ) {
36 $username = Title::makeTitleSafe( NS_USER, $un );
37 if( !is_null( $username ) ) {
38 $this->requestedUser = $username->getText();
39 }
40 }
41 parent::__construct();
42 }
43
44 function getIndexField() {
45 return 'rc_user_text';
46 }
47
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 );
55 }
56
57 $query = array(
58 'tables' => array( 'recentchanges', 'user', 'ipblocks' ),
59 'fields' => array( 'rc_user_text AS user_name', // inheritance
60 'rc_user_text', // for Pager
61 'user_id',
62 'COUNT(*) AS recentedits',
63 'MAX(ipb_user) AS blocked'
64 ),
65 'options' => array(
66 'GROUP BY' => 'rc_user_text',
67 'USE INDEX' => array( 'recentchanges' => 'rc_user_text' )
68 ),
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' ),
72 ),
73 'conds' => $conds
74 );
75 return $query;
76 }
77
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() ) );
82
83 $list = array();
84 foreach( self::getGroups( $row->user_id ) as $group )
85 $list[] = self::buildGroupLink( $group );
86 $groups = implode( ', ', $list );
87
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 ) : '';
91
92 return "<li>{$item} [{$count}]{$blocked}</li>";
93 }
94
95 function getPageHeader() {
96 global $wgScript, $wgRequest;
97 $self = $this->getTitle();
98
99 # Form tag
100 $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
101 '<fieldset>' .
102 Xml::element( 'legend', array(), wfMsg( 'activeusers' ) );
103 $out .= Xml::hidden( 'title', $self->getPrefixedDBkey() );
104
105 # Username field
106 $out .= Xml::label( wfMsg( 'activeusers-from' ), 'offset' ) . ' ' .
107 Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' ';
108
109 # Submit button and form bottom
110 if( $this->mLimit )
111 $out .= Xml::hidden( 'limit', $this->mLimit );
112 $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
113
114 $out .= '</fieldset>' . Xml::closeElement( 'form' );
115
116 return $out;
117 }
118 }
119
120 /**
121 * @ingroup SpecialPage
122 */
123 class SpecialActiveUsers extends SpecialPage {
124
125 /**
126 * Constructor
127 */
128 public function __construct() {
129 parent::__construct( 'Activeusers' );
130 }
131
132 /**
133 * Show the special page
134 *
135 * @param $par Mixed: parameter passed to the page or null
136 */
137 public function execute( $par ) {
138 global $wgOut;
139
140 $this->setHeaders();
141
142 $up = new ActiveUsersPager();
143
144 # getBody() first to check, if empty
145 $usersbody = $up->getBody();
146 $s = $up->getPageHeader();
147 if( $usersbody ) {
148 $s .= $up->getNavigationBar();
149 $s .= '<ul>' . $usersbody . '</ul>';
150 $s .= $up->getNavigationBar();
151 } else {
152 $s .= '<p>' . wfMsgHtml( 'activeusers-noresult' ) . '</p>';
153 }
154
155 $wgOut->addHTML( $s );
156 }
157
158 }