From a5bd1dee3088234c5b3089d71076bfd4a63e4b0a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 25 Jan 2009 01:22:58 +0000 Subject: [PATCH] (bug 3301) Optionally sort user list according to account creation time --- includes/specials/SpecialListusers.php | 34 +++++++++++++++++++------- languages/messages/MessagesEn.php | 4 ++- maintenance/language/messages.inc | 2 ++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php index 17bec70e07..3839427680 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'; @@ -96,7 +102,8 @@ class UsersPager extends AlphabeticPager { 'MAX(user_id) AS user_id', 'MAX(user_editcount) AS edits', 'COUNT(ug_group) AS numgroups', - 'MAX(ug_group) AS singlegroup'), + 'MAX(ug_group) AS singlegroup', + 'MIN(user_registration) AS creation'), 'options' => array('GROUP BY' => 'user_name'), 'conds' => $conds ); @@ -131,8 +138,16 @@ class UsersPager extends AlphabeticPager { } else { $edits = ''; } + + $created = ''; + # Some rows may be NULL + if( $row->creation ) { + $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->creation ), true ); + $created = ' (' . wfMsgHtml( 'usercreated', $d ) . ')'; + } + wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) ); - return "
  • {$item}{$edits}
  • "; + return "
  • {$item}{$edits}{$created}
  • "; } function getBody() { @@ -172,12 +187,13 @@ class UsersPager extends AlphabeticPager { $out .= Xml::closeElement( 'select' ) . '
    '; $out .= Xml::checkLabel( wfMsg('listusers-editsonly'), 'editsOnly', 'editsOnly', $this->editsOnly ); $out .= ' '; + $out .= Xml::checkLabel( wfMsg('listusers-creationsort'), 'creationSort', 'creationSort', $this->creationSort ); + $out .= '
    '; 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 .= '' . diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index e140bc9330..f8d4c6f91e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2130,7 +2130,9 @@ Each row contains links to the first and second redirect, as well as the target 'protectedtitlesempty' => 'No titles are currently protected with these parameters.', 'listusers' => 'User list', 'listusers-summary' => '', # do not translate or duplicate this message to other languages -'listusers-editsonly' => 'Show users with edits only', +'listusers-editsonly' => 'Show only users with edits', +'listusers-creationsort' => 'Sort by creation date', +'usercreated' => 'Created on $1', 'usereditcount' => '$1 {{PLURAL:$1|edit|edits}}', 'newpages' => 'New pages', 'newpages-summary' => '', # do not translate or duplicate this message to other languages diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index eac36cf162..424a25a26c 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1411,7 +1411,9 @@ $wgMessageStructure = array( 'listusers', 'listusers-summary', 'listusers-editsonly', + 'listusers-creationsort', 'usereditcount', + 'usercreated', 'newpages', 'newpages-summary', 'newpages-username', -- 2.20.1