r46177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46176‎ | r46177 | r46178 >
Date:01:22, 25 January 2009
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
(bug 3301) Optionally sort user list according to account creation time
Modified paths:
  • /trunk/phase3/includes/specials/SpecialListusers.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1411,7 +1411,9 @@
14121412 'listusers',
14131413 'listusers-summary',
14141414 'listusers-editsonly',
 1415+ 'listusers-creationsort',
14151416 'usereditcount',
 1417+ 'usercreated',
14161418 'newpages',
14171419 'newpages-summary',
14181420 'newpages-username',
Index: trunk/phase3/includes/specials/SpecialListusers.php
@@ -53,6 +53,7 @@
5454 $this->requestedGroup = '';
5555 }
5656 $this->editsOnly = $wgRequest->getBool( 'editsOnly' );
 57+ $this->creationSort = $wgRequest->getBool( 'creationSort' );
5758
5859 $this->requestedUser = '';
5960 if ( $un != '' ) {
@@ -66,7 +67,7 @@
6768
6869
6970 function getIndexField() {
70 - return 'user_name';
 71+ return $this->creationSort ? 'user_id' : 'user_name';
7172 }
7273
7374 function getQueryInfo() {
@@ -74,14 +75,19 @@
7576 $conds = array();
7677 // Don't show hidden names
7778 $conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0';
78 - if ($this->requestedGroup != "") {
 79+ if( $this->requestedGroup != '' ) {
7980 $conds['ug_group'] = $this->requestedGroup;
8081 $useIndex = '';
8182 } else {
82 - $useIndex = $dbr->useIndexClause('user_name');
 83+ $useIndex = $dbr->useIndexClause( $this->creationSort ? 'PRIMARY' : 'user_name');
8384 }
84 - if ($this->requestedUser != "") {
85 - $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser );
 85+ if( $this->requestedUser != '' ) {
 86+ # Sorted either by account creation or name
 87+ if( $this->creationSort ) {
 88+ $conds[] = 'user_id >= ' . User::idFromName( $this->requestedUser );
 89+ } else {
 90+ $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser );
 91+ }
8692 }
8793 if( $this->editsOnly ) {
8894 $conds[] = 'user_editcount > 0';
@@ -96,7 +102,8 @@
97103 'MAX(user_id) AS user_id',
98104 'MAX(user_editcount) AS edits',
99105 'COUNT(ug_group) AS numgroups',
100 - 'MAX(ug_group) AS singlegroup'),
 106+ 'MAX(ug_group) AS singlegroup',
 107+ 'MIN(user_registration) AS creation'),
101108 'options' => array('GROUP BY' => 'user_name'),
102109 'conds' => $conds
103110 );
@@ -131,8 +138,16 @@
132139 } else {
133140 $edits = '';
134141 }
 142+
 143+ $created = '';
 144+ # Some rows may be NULL
 145+ if( $row->creation ) {
 146+ $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->creation ), true );
 147+ $created = ' (' . wfMsgHtml( 'usercreated', $d ) . ')';
 148+ }
 149+
135150 wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) );
136 - return "<li>{$item}{$edits}</li>";
 151+ return "<li>{$item}{$edits}{$created}</li>";
137152 }
138153
139154 function getBody() {
@@ -172,12 +187,13 @@
173188 $out .= Xml::closeElement( 'select' ) . '<br/>';
174189 $out .= Xml::checkLabel( wfMsg('listusers-editsonly'), 'editsOnly', 'editsOnly', $this->editsOnly );
175190 $out .= '&nbsp;';
 191+ $out .= Xml::checkLabel( wfMsg('listusers-creationsort'), 'creationSort', 'creationSort', $this->creationSort );
 192+ $out .= '<br/>';
176193
177194 wfRunHooks( 'SpecialListusersHeaderForm', array( $this, &$out ) );
178195
179196 # Submit button and form bottom
180 - if( $this->mLimit )
181 - $out .= Xml::hidden( 'limit', $this->mLimit );
 197+ $out .= Xml::hidden( 'limit', $this->mLimit );
182198 $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
183199 wfRunHooks( 'SpecialListusersHeader', array( $this, &$out ) );
184200 $out .= '</fieldset>' .
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2130,7 +2130,9 @@
21312131 'protectedtitlesempty' => 'No titles are currently protected with these parameters.',
21322132 'listusers' => 'User list',
21332133 'listusers-summary' => '', # do not translate or duplicate this message to other languages
2134 -'listusers-editsonly' => 'Show users with edits only',
 2134+'listusers-editsonly' => 'Show only users with edits',
 2135+'listusers-creationsort' => 'Sort by creation date',
 2136+'usercreated' => 'Created on $1',
21352137 'usereditcount' => '$1 {{PLURAL:$1|edit|edits}}',
21362138 'newpages' => 'New pages',
21372139 'newpages-summary' => '', # do not translate or duplicate this message to other languages

Comments

#Comment by Brion VIBBER (talk | contribs)   23:21, 26 January 2009

Release notes?

#Comment by Brion VIBBER (talk | contribs)   23:23, 26 January 2009

There also seems to be no UI for selecting it, and the URL parameter 'creationSort' doesn't follow our typical naming patterns.

Consider 'sort=name' vs 'sort=id' or such, and provide a UI for selecting it.

#Comment by Aaron Schulz (talk | contribs)   03:34, 27 January 2009

There is a checkboxen

#Comment by Aaron Schulz (talk | contribs)   03:33, 27 January 2009

Updated release notes in r46317

Status & tagging log