(bug 3301) Optionally sort user list according to account creation time
authorAaron Schulz <aaron@users.mediawiki.org>
Sun, 25 Jan 2009 01:22:58 +0000 (01:22 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sun, 25 Jan 2009 01:22:58 +0000 (01:22 +0000)
includes/specials/SpecialListusers.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 17bec70..3839427 100644 (file)
@@ -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 "<li>{$item}{$edits}</li>";
+               return "<li>{$item}{$edits}{$created}</li>";
        }
 
        function getBody() {
@@ -172,12 +187,13 @@ 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>' .
index e140bc9..f8d4c6f 100644 (file)
@@ -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
index eac36cf..424a25a 100644 (file)
@@ -1411,7 +1411,9 @@ $wgMessageStructure = array(
                'listusers',
                'listusers-summary',
                'listusers-editsonly',
+               'listusers-creationsort',
                'usereditcount',
+               'usercreated',
                'newpages',
                'newpages-summary',
                'newpages-username',