if-if-else without curly braces [api/ApiQuerySiteinfo.php] --> adding Unused global declaration: $wgGroupPermissions --> removing Unused global declaration: $wgEmailConfirmToEdit (line 301) --> removing Variable $id appears only once (line 1021) --> removing Variable $m was used before it was defined (line 805) --> defining. Variable $retval was used before it was defined (line 2346) --> renaming to $result Variable $rcid appears only once (line 244 of RecentChange.php) --> using this instead of $change [Note: was left over from r24607 refactoring, revert if wrong please] Unused global declaration: $wgCommandLineMode (line 11) --> removing Variable $k appears only once (line 132 of ImagePage.php) --> removing. Variable $info appears only once (line 311 of ImagePage.php) --> removing. Unused global declaration: $wgTitle (line 569 of ImagePage.php) -> removing. Variable $handlerParams was used before it was defined (line 616 of Linker.php) --> resolved by Raymond in r24966 Variable $match was used before it was defined (line 1031 of Linker.php) --> defining. Unused global declaration: $wgEnotifWatchlist (line 253 of UserMailer.php) --> removing Unused global declaration: $wgShowUpdatedMarker (line 253 of UserMailer.php) --> removing Variable $img appears only once (line 446 of SpecialUpload.php) --> added definition, defined as null, flagged with @todo [Note: should $img be defined in this context, or is it intended to be null? And should the return value after the hook be checked in some way?] Unused global declaration: $wgEnableAPI (line 739 of SpecialUpload.php) --> removing. Unused global declaration: $wgNamespaceProtection (line 1030 of OutputPage.php) --> removing. Unused global declaration: $wgContLang (line 18 of SpecialWatchlist.php) --> removing. Unused global declaration: $wgRawHtml (line 269 of SpecialMovepage.php) --> removing. The value of variable $page was never used (line 331 of SpecialUndelete.php) --> removing line, as $page gets redefined a few lines down. Variable $synIndex appears only once (line 521 of MagicWord.php) --> commenting out. Variable $case appears only once (line 539 of MagicWord.php) --> removing from foreach index key usage. Variable $wgUser appears only once (line 1039 of Title.php) --> adding line to declare as a global, would be null otherwise. Variable $m was used before it was defined (line 285 of Title.php) --> defining. Variable $id appears only once (line 1150 of Title.php) --> removing from foreach index key usage. Variable $subpage appears only once (line 1297 of Title.php) --> commenting out. Variable $restrictions appears only once (line 1399 of Title.php) --> commenting out. Variable $mime appears only once (line 210 of filerepo/OldLocalFile.php) --> removing. Variable $deprefixedName appears only once (line 213 of filerepo/LocalFile.php) --> removing. Variable $m appears only once (line 541 of filerepo/LocalFile.php) --> removing. Variable $where appears only once (line 1245 of filerepo/LocalFile.php) --> removing. Variable $info appears only once (line 1427 of filerepo/LocalFile.php) --> removing. Variable $rel appears only once (line 138 of filerepo/RepoGroup.php) --> commenting out. Variable $zone appears only once (line 138 of filerepo/RepoGroup.php) --> commenting out. Variable $nbytes appears only once (line 208 of media/Generic.php) --> added a return line that uses $nbytes. [Note: I'm assuming that this was the intent] Variable $offset appears only once (line 201 of SpecialListusers.php) --> removing. Variable $limit appears only once (line 201 of SpecialListusers.php) --> removing. Variable $groupTarget appears only once (line 203 of SpecialListusers.php) --> removing. Unused global declaration: $wgLang (line 74 of SpecialWantedpages.php) --> removing. Variable $block appears only once (line 244 of SpecialProtectedpages.php) --> removing. Variable $offset appears only once (line 281 of SpecialProtectedpages.php) --> removing. Variable $limit appears only once (line 281 of SpecialProtectedpages.php) --> removing. Unused global declaration: $wgLang (line 30 of FileDeleteForm.php) --> removing. Unused global declaration: $wgServer (line 30 of FileDeleteForm.php) --> removing.
217 lines
6.1 KiB
PHP
217 lines
6.1 KiB
PHP
<?php
|
|
|
|
# Copyright (C) 2004 Brion Vibber, lcrocker, Tim Starling,
|
|
# Domas Mituzas, Ashar Voultoiz, Jens Frank, Zhengzhu.
|
|
#
|
|
# © 2006 Rob Church <robchur@gmail.com>
|
|
#
|
|
# 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
|
|
/**
|
|
*
|
|
* @addtogroup 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.
|
|
*
|
|
* @addtogroup SpecialPage
|
|
*/
|
|
|
|
class UsersPager extends AlphabeticPager {
|
|
|
|
function __construct($group=null) {
|
|
global $wgRequest;
|
|
$this->requestedGroup = $group != "" ? $group : $wgRequest->getVal( 'group' );
|
|
$un = $wgRequest->getText( 'username' );
|
|
$this->requestedUser = '';
|
|
if ( $un != '' ) {
|
|
$username = Title::makeTitleSafe( NS_USER, $un );
|
|
if( ! is_null( $username ) ) {
|
|
$this->requestedUser = $username->getText();
|
|
}
|
|
}
|
|
parent::__construct();
|
|
}
|
|
|
|
|
|
function getIndexField() {
|
|
return 'user_name';
|
|
}
|
|
|
|
function getQueryInfo() {
|
|
$conds=array();
|
|
// don't show hidden names
|
|
$conds[]='ipb_deleted IS NULL OR ipb_deleted = 0';
|
|
if ($this->requestedGroup != "") {
|
|
$conds['ug_group'] = $this->requestedGroup;
|
|
}
|
|
if ($this->requestedUser != "") {
|
|
$conds[] = 'user_name >= ' . wfGetDB()->addQuotes( $this->requestedUser );
|
|
}
|
|
|
|
list ($user,$user_groups,$ipblocks) = wfGetDB()->tableNamesN('user','user_groups','ipblocks');
|
|
|
|
return array(
|
|
'tables' => " $user LEFT JOIN $user_groups ON user_id=ug_user LEFT JOIN $ipblocks ON user_id=ipb_user AND ipb_auto=0 ",
|
|
'fields' => array('user_name',
|
|
'MAX(user_id) AS user_id',
|
|
'COUNT(ug_group) AS numgroups',
|
|
'MAX(ug_group) AS singlegroup'),
|
|
'options' => array('GROUP BY' => 'user_name'),
|
|
'conds' => $conds
|
|
);
|
|
|
|
}
|
|
|
|
function formatRow( $row ) {
|
|
$userPage = Title::makeTitle( NS_USER, $row->user_name );
|
|
$name = $this->getSkin()->makeLinkObj( $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 = implode( ', ', $list );
|
|
} elseif( $row->numgroups == 1 ) {
|
|
$groups = self::buildGroupLink( $row->singlegroup );
|
|
} else {
|
|
$groups = '';
|
|
}
|
|
|
|
return '<li>' . wfSpecialList( $name, $groups ) . '</li>';
|
|
}
|
|
|
|
function getBody() {
|
|
if (!$this->mQueryDone) {
|
|
$this->doQuery();
|
|
}
|
|
$batch = new LinkBatch;
|
|
|
|
$this->mResult->rewind();
|
|
|
|
while ( $row = $this->mResult->fetchObject() ) {
|
|
$batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
|
|
}
|
|
$batch->execute();
|
|
$this->mResult->rewind();
|
|
return parent::getBody();
|
|
}
|
|
|
|
function getPageHeader( ) {
|
|
global $wgScript, $wgRequest;
|
|
$self = $this->getTitle();
|
|
|
|
# Form tag
|
|
$out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
|
|
'<fieldset>' .
|
|
Xml::element( 'legend', array(), wfMsg( 'listusers' ) );
|
|
$out .= Xml::hidden( 'title', $self->getPrefixedDbKey() );
|
|
|
|
# Username field
|
|
$out .= Xml::label( wfMsg( 'listusersfrom' ), 'offset' ) . ' ' .
|
|
Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' ';
|
|
|
|
# Group drop-down list
|
|
$out .= Xml::label( wfMsg( 'group' ), 'group' ) . ' ' .
|
|
Xml::openElement('select', array( 'name' => 'group', 'id' => 'group' ) ) .
|
|
Xml::option( wfMsg( 'group-all' ), '' );
|
|
foreach( User::getAllGroups() as $group )
|
|
$out .= Xml::option( User::getGroupName( $group ), $group, $group == $this->requestedGroup );
|
|
$out .= Xml::closeElement( 'select' ) . ' ';
|
|
|
|
# Submit button and form bottom
|
|
if( $this->mLimit )
|
|
$out .= Xml::hidden( 'limit', $this->mLimit );
|
|
$out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
|
|
'</fieldset>' .
|
|
Xml::closeElement( 'form' );
|
|
|
|
return $out;
|
|
}
|
|
|
|
/**
|
|
* Preserve group and username offset parameters when paging
|
|
* @return array
|
|
*/
|
|
function getDefaultQuery() {
|
|
$query = parent::getDefaultQuery();
|
|
if( $this->requestedGroup != '' )
|
|
$query['group'] = $this->requestedGroup;
|
|
if( $this->requestedUser != '' )
|
|
$query['username'] = $this->requestedUser;
|
|
return $query;
|
|
}
|
|
|
|
/**
|
|
* Get a list of groups the specified user belongs to
|
|
*
|
|
* @param int $uid
|
|
* @return array
|
|
*/
|
|
private static function getGroups( $uid ) {
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
$groups = array();
|
|
$res = $dbr->select( 'user_groups', 'ug_group', array( 'ug_user' => $uid ), __METHOD__ );
|
|
if( $res && $dbr->numRows( $res ) > 0 ) {
|
|
while( $row = $dbr->fetchObject( $res ) )
|
|
$groups[] = $row->ug_group;
|
|
$dbr->freeResult( $res );
|
|
}
|
|
return $groups;
|
|
}
|
|
|
|
/**
|
|
* Format a link to a group description page
|
|
*
|
|
* @param string $group
|
|
* @return string
|
|
*/
|
|
private static function buildGroupLink( $group ) {
|
|
static $cache = array();
|
|
if( !isset( $cache[$group] ) )
|
|
$cache[$group] = User::makeGroupLinkHtml( $group, User::getGroupMember( $group ) );
|
|
return $cache[$group];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* constructor
|
|
* $par string (optional) A group to list users from
|
|
*/
|
|
function wfSpecialListusers( $par = null ) {
|
|
global $wgRequest, $wgOut;
|
|
|
|
$up = new UsersPager($par);
|
|
|
|
# getBody() first to check, if empty
|
|
$usersbody = $up->getBody();
|
|
$s = $up->getPageHeader();
|
|
if( $usersbody ) {
|
|
$s .= $up->getNavigationBar();
|
|
$s .= '<ul>' . $usersbody . '</ul>';
|
|
$s .= $up->getNavigationBar() ;
|
|
} else {
|
|
$s .= '<p>' . wfMsgHTML('listusers-noresult') . '</p>';
|
|
};
|
|
|
|
$wgOut->addHTML( $s );
|
|
}
|
|
|
|
|