3 # Copyright (C) 2004 Brion Vibber, lcrocker, Tim Starling,
4 # Domas Mituzas, Ashar Voultoiz, Jens Frank, Zhengzhu.
6 # © 2006 Rob Church <robchur@gmail.com>
8 # http://www.mediawiki.org/
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 # http://www.gnu.org/copyleft/gpl.html
26 * @addtogroup SpecialPage
30 * This class is used to get a list of user. The ones with specials
31 * rights (sysop, bureaucrat, developer) will have them displayed
32 * next to their names.
34 * @addtogroup SpecialPage
37 class UsersPager
extends AlphabeticPager
{
39 function __construct($group=null) {
41 $this->groupRequested
= $group != "" ?
$group : $wgRequest->getVal( 'group' );
43 parent
::__construct();
47 function getIndexField() {
51 function getQueryInfo() {
53 if ($this->groupRequested
!= "") {
54 $conds['ug_group'] = $this->groupRequested
;
57 list ($user,$user_groups) = wfGetDB()->tableNamesN('user','user_groups');
60 'tables' => " $user LEFT JOIN $user_groups ON user_id=ug_user ",
61 'fields' => array('user_name',
62 'MAX(user_id) AS user_id',
63 'COUNT(ug_group) AS numgroups',
64 'MAX(ug_group) AS singlegroup'),
65 'options' => array('GROUP BY' => 'user_name'),
70 function formatRow($row) {
71 $userPage = Title
::makeTitle(NS_USER
, $row->user_name
);
72 $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
74 if ($row->numgroups
> 1 ||
( $this->groupRequested
and $row->numgroups
== 1) ) {
75 $dbr = wfGetDB(DB_SLAVE
);
76 $result = $dbr->select( 'user_groups', 'ug_group',
77 array( 'ug_user' => $row->user_id
),
78 'UsersPager::formatRow' );
79 while ( $group = $dbr->fetchObject($result)) {
80 $groups[$group->ug_group
] = User
::getGroupMember ( $group->ug_group
);
82 $dbr->freeResult($result);
83 } elseif ($row->numgroups
== 1 ) { // MAX hack inside query :)
84 $groups[$row->singlegroup
] = User
::getGroupMember( $row->singlegroup
);
87 if ( count($groups) > 0 ) {
88 foreach( $groups as $group => $desc ) {
89 $list[] = User
::makeGroupLinkHTML( $group, $desc);
91 $groups = implode( ', ', $list);
95 return '<li>' . wfSpecialList ($name, $groups) .'</li>';
99 if (!$this->mQueryDone
) {
102 $batch = new LinkBatch
;
105 $this->mResult
->rewind();
107 while ( $row = $this->mResult
->fetchObject() ) {
108 $batch->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_name
) );
111 $this->mResult
->rewind();
112 return parent
::getBody();
115 function getPageHeader( ) {
116 $self = $this->getTitle();
119 $out = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
121 # Group drop-down list
122 $out .= wfElement( 'label', array( 'for' => 'group' ), wfMsg( 'group' ) ) . ' ';
123 $out .= wfOpenElement( 'select', array( 'name' => 'group', 'id' => 'group' ) );
124 $out .= wfElement( 'option', array( 'value' => '' ), wfMsg( 'group-all' ) ); # Item for "all groups"
125 $groups = User
::getAllGroups();
126 foreach( $groups as $group ) {
127 $attribs = array( 'value' => $group );
128 if( $group == $this->requestedGroup
)
129 $attribs['selected'] = 'selected';
130 $out .= wfElement( 'option', $attribs, User
::getGroupName( $group ) );
132 $out .= wfCloseElement( 'select' ) . ' ';;# . wfElement( 'br' );
135 $out .= wfElement( 'label', array( 'for' => 'offset' ), wfMsg( 'listusersfrom' ) ) . ' ';
136 $out .= wfElement( 'input', array( 'type' => 'text', 'id' => 'offset', 'name' => 'offset',
137 'value' => $this->requestedUser
) ) . ' ';
140 $out .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'limit', 'value' => $this->mLimit
) );
142 # Submit button and form bottom
143 $out .= wfElement( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'allpagessubmit' ) ) );
144 $out .= wfCloseElement( 'form' );
152 * $par string (optional) A group to list users from
154 function wfSpecialListusers( $par = null ) {
155 global $wgRequest, $wgOut;
157 list( $limit, $offset ) = wfCheckLimits();
159 $groupTarget = isset($par) ?
$par : $wgRequest->getVal( 'group' );
161 $up = new UsersPager($par);
163 $up->getPageHeader().
164 $up->getNavigationBar().
168 $up->getNavigationBar()