# # http://www.mediawiki.org/ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # http://www.gnu.org/copyleft/gpl.html /** * @file * @ingroup SpecialPage */ /** * This class is used to get a list of user. The ones with specials * rights (sysop, bureaucrat, developer) will have them displayed * next to their names. * * @ingroup SpecialPage */ class UsersPager extends AlphabeticPager { function __construct( $par=null ) { global $wgRequest; $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) ); $symsForAll = array( '*', 'user' ); if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) { $this->requestedGroup = $par; $un = $wgRequest->getText( 'username' ); } else if ( count( $parms ) == 2 ) { $this->requestedGroup = $parms[0]; $un = $parms[1]; } else { $this->requestedGroup = $wgRequest->getVal( 'group' ); $un = ( $par != '' ) ? $par : $wgRequest->getText( 'username' ); } if ( in_array( $this->requestedGroup, $symsForAll ) ) { $this->requestedGroup = ''; } $this->editsOnly = $wgRequest->getBool( 'editsOnly' ); $this->creationSort = $wgRequest->getBool( 'creationSort' ); $this->requestedUser = ''; if ( $un != '' ) { $username = Title::makeTitleSafe( NS_USER, $un ); if( ! is_null( $username ) ) { $this->requestedUser = $username->getText(); } } parent::__construct(); } function getIndexField() { return $this->creationSort ? 'user_id' : 'user_name'; } function getQueryInfo() { global $wgUser; $dbr = wfGetDB( DB_SLAVE ); $conds = array(); // Don't show hidden names if( !$wgUser->isAllowed('hideuser') ) $conds[] = 'ipb_deleted IS NULL'; if( $this->requestedGroup != '' ) { $conds['ug_group'] = $this->requestedGroup; $useIndex = ''; } else { $useIndex = $dbr->useIndexClause( $this->creationSort ? 'PRIMARY' : 'user_name'); } if( $this->requestedUser != '' ) { # Sorted either by account creation or name if( $this->creationSort ) { $conds[] = 'user_id >= ' . intval( User::idFromName( $this->requestedUser ) ); } else { $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser ); } } if( $this->editsOnly ) { $conds[] = 'user_editcount > 0'; } list ($user,$user_groups,$ipblocks) = $dbr->tableNamesN('user','user_groups','ipblocks'); $query = array( 'tables' => " $user $useIndex LEFT JOIN $user_groups ON user_id=ug_user LEFT JOIN $ipblocks ON user_id=ipb_user AND ipb_deleted=1 AND ipb_auto=0 ", 'fields' => array( $this->creationSort ? 'MAX(user_name) AS user_name' : 'user_name', $this->creationSort ? 'user_id' : 'MAX(user_id) AS user_id', 'MAX(user_editcount) AS edits', 'COUNT(ug_group) AS numgroups', 'MAX(ug_group) AS singlegroup', // the usergroup if there is only one 'MIN(user_registration) AS creation', 'MAX(ipb_deleted) AS ipb_deleted' // block/hide status ), 'options' => array('GROUP BY' => $this->creationSort ? 'user_id' : 'user_name'), 'conds' => $conds ); wfRunHooks( 'SpecialListusersQueryInfo', array( $this, &$query ) ); return $query; } function formatRow( $row ) { global $wgLang; $userPage = Title::makeTitle( NS_USER, $row->user_name ); $name = $this->getSkin()->link( $userPage, htmlspecialchars( $userPage->getText() ) ); if( $row->numgroups > 1 || ( $this->requestedGroup && $row->numgroups == 1 ) ) { $list = array(); foreach( self::getGroups( $row->user_id ) as $group ) $list[] = self::buildGroupLink( $group ); $groups = $wgLang->commaList( $list ); } elseif( $row->numgroups == 1 ) { $groups = self::buildGroupLink( $row->singlegroup ); } else { $groups = ''; } $item = wfSpecialList( $name, $groups ); if( $row->ipb_deleted ) { $item = "$item"; } global $wgEdititis; if ( $wgEdititis ) { $editCount = $wgLang->formatNum( $row->edits ); $edits = ' [' . wfMsgExt( 'usereditcount', array( 'parsemag', 'escape' ), $editCount ) . ']'; } else { $edits = ''; } $created = ''; # Some rows may be NULL if( $row->creation ) { $d = $wgLang->date( wfTimestamp( TS_MW, $row->creation ), true ); $t = $wgLang->time( wfTimestamp( TS_MW, $row->creation ), true ); $created = ' (' . wfMsg( 'usercreated', $d, $t ) . ')'; $created = htmlspecialchars( $created ); } wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) ); return "
' . wfMsgHTML('listusers-noresult') . '
'; }; $s .= XML::closeElement( 'div' ); $wgOut->addHTML( $s ); }