summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialListusers.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialListusers.php')
-rw-r--r--includes/specials/SpecialListusers.php68
1 files changed, 32 insertions, 36 deletions
diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php
index 0531444a..d743712d 100644
--- a/includes/specials/SpecialListusers.php
+++ b/includes/specials/SpecialListusers.php
@@ -3,7 +3,7 @@
* Implements Special:Listusers
*
* Copyright © 2004 Brion Vibber, lcrocker, Tim Starling,
- * Domas Mituzas, Ashar Voultoiz, Jens Frank, Zhengzhu,
+ * Domas Mituzas, Antoine Musso, Jens Frank, Zhengzhu,
* 2006 Rob Church <robchur@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -34,25 +34,30 @@
*/
class UsersPager extends AlphabeticPager {
- function __construct( $par=null ) {
- global $wgRequest;
- $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) );
+ function __construct( IContextSource $context = null, $par = null ) {
+ if ( $context ) {
+ $this->setContext( $context );
+ }
+
+ $request = $this->getRequest();
+ $par = ( $par !== null ) ? $par : '';
+ $parms = explode( '/', $par );
$symsForAll = array( '*', 'user' );
if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) {
$this->requestedGroup = $par;
- $un = $wgRequest->getText( 'username' );
+ $un = $request->getText( 'username' );
} elseif ( count( $parms ) == 2 ) {
$this->requestedGroup = $parms[0];
$un = $parms[1];
} else {
- $this->requestedGroup = $wgRequest->getVal( 'group' );
- $un = ( $par != '' ) ? $par : $wgRequest->getText( 'username' );
+ $this->requestedGroup = $request->getVal( 'group' );
+ $un = ( $par != '' ) ? $par : $request->getText( 'username' );
}
if ( in_array( $this->requestedGroup, $symsForAll ) ) {
$this->requestedGroup = '';
}
- $this->editsOnly = $wgRequest->getBool( 'editsOnly' );
- $this->creationSort = $wgRequest->getBool( 'creationSort' );
+ $this->editsOnly = $request->getBool( 'editsOnly' );
+ $this->creationSort = $request->getBool( 'creationSort' );
$this->requestedUser = '';
if ( $un != '' ) {
@@ -64,20 +69,15 @@ class UsersPager extends AlphabeticPager {
parent::__construct();
}
- function getTitle() {
- return SpecialPage::getTitleFor( 'Listusers' );
- }
-
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') ) {
+ if( !$this->getUser()->isAllowed('hideuser') ) {
$conds[] = 'ipb_deleted IS NULL';
}
@@ -126,32 +126,32 @@ class UsersPager extends AlphabeticPager {
}
function formatRow( $row ) {
- global $wgLang;
-
if ($row->user_id == 0) #Bug 16487
return '';
$userPage = Title::makeTitle( NS_USER, $row->user_name );
$name = Linker::link( $userPage, htmlspecialchars( $userPage->getText() ) );
+ $lang = $this->getLanguage();
+
$groups_list = self::getGroups( $row->user_id );
if( count( $groups_list ) > 0 ) {
$list = array();
foreach( $groups_list as $group )
- $list[] = self::buildGroupLink( $group );
- $groups = $wgLang->commaList( $list );
+ $list[] = self::buildGroupLink( $group, $userPage->getText() );
+ $groups = $lang->commaList( $list );
} else {
$groups = '';
}
- $item = wfSpecialList( $name, $groups );
+ $item = $lang->specialList( $name, $groups );
if( $row->ipb_deleted ) {
$item = "<span class=\"deleted\">$item</span>";
}
global $wgEdititis;
if ( $wgEdititis ) {
- $editCount = $wgLang->formatNum( $row->edits );
+ $editCount = $lang->formatNum( $row->edits );
$edits = ' [' . wfMsgExt( 'usereditcount', array( 'parsemag', 'escape' ), $editCount ) . ']';
} else {
$edits = '';
@@ -160,10 +160,9 @@ class UsersPager extends AlphabeticPager {
$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 );
+ $d = $lang->date( wfTimestamp( TS_MW, $row->creation ), true );
+ $t = $lang->time( wfTimestamp( TS_MW, $row->creation ), true );
+ $created = ' (' . wfMsgExt( 'usercreated', array( 'parsemag', 'escape' ), $d, $t, $row->user_name ) . ')';
}
wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) );
@@ -186,12 +185,13 @@ class UsersPager extends AlphabeticPager {
function getPageHeader( ) {
global $wgScript;
- $self = $this->getTitle();
+ // @todo Add a PrefixedBaseDBKey
+ list( $self ) = explode( '/', $this->getTitle()->getPrefixedDBkey() );
# Form tag
$out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listusers-form' ) ) .
Xml::fieldset( wfMsg( 'listusers' ) ) .
- Html::hidden( 'title', $self->getPrefixedDbKey() );
+ Html::hidden( 'title', $self );
# Username field
$out .= Xml::label( wfMsg( 'listusersfrom' ), 'offset' ) . ' ' .
@@ -264,13 +264,11 @@ class UsersPager extends AlphabeticPager {
* Format a link to a group description page
*
* @param $group String: group name
+ * @param $username String Username
* @return string
*/
- protected static function buildGroupLink( $group ) {
- static $cache = array();
- if( !isset( $cache[$group] ) )
- $cache[$group] = User::makeGroupLinkHtml( $group, htmlspecialchars( User::getGroupMember( $group ) ) );
- return $cache[$group];
+ protected static function buildGroupLink( $group, $username ) {
+ return User::makeGroupLinkHtml( $group, htmlspecialchars( User::getGroupMember( $group, $username ) ) );
}
}
@@ -292,12 +290,10 @@ class SpecialListUsers extends SpecialPage {
* @param $par string (optional) A group to list users from
*/
public function execute( $par ) {
- global $wgOut;
-
$this->setHeaders();
$this->outputHeader();
- $up = new UsersPager( $par );
+ $up = new UsersPager( $this->getContext(), $par );
# getBody() first to check, if empty
$usersbody = $up->getBody();
@@ -311,6 +307,6 @@ class SpecialListUsers extends SpecialPage {
$s .= wfMessage( 'listusers-noresult' )->parseAsBlock();
}
- $wgOut->addHTML( $s );
+ $this->getOutput()->addHTML( $s );
}
}