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.php58
1 files changed, 40 insertions, 18 deletions
diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php
index 17bec70e..aa057801 100644
--- a/includes/specials/SpecialListusers.php
+++ b/includes/specials/SpecialListusers.php
@@ -53,6 +53,7 @@ class UsersPager extends AlphabeticPager {
$this->requestedGroup = '';
}
$this->editsOnly = $wgRequest->getBool( 'editsOnly' );
+ $this->creationSort = $wgRequest->getBool( 'creationSort' );
$this->requestedUser = '';
if ( $un != '' ) {
@@ -66,7 +67,7 @@ class UsersPager extends AlphabeticPager {
function getIndexField() {
- return 'user_name';
+ return $this->creationSort ? 'user_id' : 'user_name';
}
function getQueryInfo() {
@@ -74,14 +75,19 @@ class UsersPager extends AlphabeticPager {
$conds = array();
// Don't show hidden names
$conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0';
- if ($this->requestedGroup != "") {
+ if( $this->requestedGroup != '' ) {
$conds['ug_group'] = $this->requestedGroup;
$useIndex = '';
} else {
- $useIndex = $dbr->useIndexClause('user_name');
+ $useIndex = $dbr->useIndexClause( $this->creationSort ? 'PRIMARY' : 'user_name');
}
- if ($this->requestedUser != "") {
- $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser );
+ if( $this->requestedUser != '' ) {
+ # Sorted either by account creation or name
+ if( $this->creationSort ) {
+ $conds[] = 'user_id >= ' . User::idFromName( $this->requestedUser );
+ } else {
+ $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser );
+ }
}
if( $this->editsOnly ) {
$conds[] = 'user_editcount > 0';
@@ -92,12 +98,14 @@ class UsersPager extends AlphabeticPager {
$query = array(
'tables' => " $user $useIndex 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',
+ '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'),
- 'options' => array('GROUP BY' => 'user_name'),
+ 'MAX(ug_group) AS singlegroup',
+ 'MIN(user_registration) AS creation'),
+ 'options' => array('GROUP BY' => $this->creationSort ? 'user_id' : 'user_name'),
'conds' => $conds
);
@@ -115,7 +123,7 @@ class UsersPager extends AlphabeticPager {
$list = array();
foreach( self::getGroups( $row->user_id ) as $group )
$list[] = self::buildGroupLink( $group );
- $groups = implode( ', ', $list );
+ $groups = $wgLang->commaList( $list );
} elseif( $row->numgroups == 1 ) {
$groups = self::buildGroupLink( $row->singlegroup );
} else {
@@ -131,8 +139,17 @@ class UsersPager extends AlphabeticPager {
} 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 = ' (' . wfMsgHtml( 'usercreated', $d, $t ) . ')';
+ }
+
wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) );
- return "<li>{$item}{$edits}</li>";
+ return "<li>{$item}{$edits}{$created}</li>";
}
function getBody() {
@@ -154,10 +171,9 @@ class UsersPager extends AlphabeticPager {
$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() );
+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listusers-form' ) ) .
+ Xml::fieldset( wfMsg( 'listusers' ) ) .
+ Xml::hidden( 'title', $self->getPrefixedDbKey() );
# Username field
$out .= Xml::label( wfMsg( 'listusersfrom' ), 'offset' ) . ' ' .
@@ -172,25 +188,31 @@ class UsersPager extends AlphabeticPager {
$out .= Xml::closeElement( 'select' ) . '<br/>';
$out .= Xml::checkLabel( wfMsg('listusers-editsonly'), 'editsOnly', 'editsOnly', $this->editsOnly );
$out .= '&nbsp;';
+ $out .= Xml::checkLabel( wfMsg('listusers-creationsort'), 'creationSort', 'creationSort', $this->creationSort );
+ $out .= '<br/>';
wfRunHooks( 'SpecialListusersHeaderForm', array( $this, &$out ) );
# Submit button and form bottom
- if( $this->mLimit )
- $out .= Xml::hidden( 'limit', $this->mLimit );
+ $out .= Xml::hidden( 'limit', $this->mLimit );
$out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
wfRunHooks( 'SpecialListusersHeader', array( $this, &$out ) );
- $out .= '</fieldset>' .
+ $out .= Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' );
return $out;
}
+ /**
+ * Get a list of all explicit groups
+ * @return array
+ */
function getAllGroups() {
$result = array();
foreach( User::getAllGroups() as $group ) {
$result[$group] = User::getGroupName( $group );
}
+ asort( $result );
return $result;
}