r44182 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44181‎ | r44182 | r44183 >
Date:19:07, 3 December 2008
Author:catrope
Status:reverted (Comments)
Tags:
Comment:
* API: (bug 16526) Added usprop=canemail to list=users, which tells whether a user can (and wants to be) e-mailed through [[Special:Emailuser]].
* Refactored some code to use a User object
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUsers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -73,10 +73,8 @@
7474
7575 $db = $this->getDB();
7676 $this->addTables('user', 'u1');
77 - $this->addFields('u1.user_name');
 77+ $this->addFields('u1.*');
7878 $this->addWhereFld('u1.user_name', $goodNames);
79 - $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount']));
80 - $this->addFieldsIf('u1.user_registration', isset($this->prop['registration']));
8179
8280 if(isset($this->prop['groups'])) {
8381 $this->addTables('user_groups');
@@ -96,20 +94,26 @@
9795 $data = array();
9896 $res = $this->select(__METHOD__);
9997 while(($r = $db->fetchObject($res))) {
100 - $data[$r->user_name]['name'] = $r->user_name;
 98+ $user = User::newFromRow($r);
 99+ $name = $user->getName();
 100+ $data[$name]['name'] = $name;
101101 if(isset($this->prop['editcount']))
102 - $data[$r->user_name]['editcount'] = $r->user_editcount;
 102+ // No proper member function in User class for this
 103+ $data[$name]['editcount'] = $r->user_editcount;
103104 if(isset($this->prop['registration']))
104 - $data[$r->user_name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $r->user_registration);
 105+ // Nor for this one
 106+ $data[$name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $r->user_registration);
105107 if(isset($this->prop['groups']))
106108 // This row contains only one group, others will be added from other rows
107109 if(!is_null($r->ug_group))
108 - $data[$r->user_name]['groups'][] = $r->ug_group;
 110+ $data[$name]['groups'][] = $r->ug_group;
109111 if(isset($this->prop['blockinfo']))
110112 if(!is_null($r->blocker_name)) {
111 - $data[$r->user_name]['blockedby'] = $r->blocker_name;
112 - $data[$r->user_name]['blockreason'] = $r->ipb_reason;
 113+ $data[$name]['blockedby'] = $r->blocker_name;
 114+ $data[$name]['blockreason'] = $r->ipb_reason;
113115 }
 116+ if(isset($this->prop['canemail']) && $user->canReceiveEmail())
 117+ $data[$name]['canemail'] = '';
114118 }
115119
116120 // Second pass: add result data to $retval
@@ -134,7 +138,8 @@
135139 'blockinfo',
136140 'groups',
137141 'editcount',
138 - 'registration'
 142+ 'registration',
 143+ 'canemail',
139144 )
140145 ),
141146 'users' => array(
@@ -147,9 +152,11 @@
148153 return array (
149154 'prop' => array(
150155 'What pieces of information to include',
151 - ' blockinfo - tags if the user is blocked, by whom, and for what reason',
152 - ' groups - lists all the groups the user belongs to',
153 - ' editcount - adds the user\'s edit count'
 156+ ' blockinfo - tags if the user is blocked, by whom, and for what reason',
 157+ ' groups - lists all the groups the user belongs to',
 158+ ' editcount - adds the user\'s edit count',
 159+ ' registration - adds the user\'s registration timestamp',
 160+ ' canemail - tags if the user can and wants to receive e-mail through [[Special:Emailuser]]',
154161 ),
155162 'users' => 'A list of users to obtain the same information for'
156163 );
Index: trunk/phase3/RELEASE-NOTES
@@ -483,6 +483,7 @@
484484 * (bug 16421) Made list=logevents's leuser accept user names with underscores
485485 instead of spaces
486486 * (bug 16516) Made rvsection=T-2 work
 487+* (bug 16526) Added usprop=canemail to list=users
487488
488489 === Languages updated in 1.14 ===
489490

Follow-up revisions

RevisionCommit summaryAuthorDate
r44202Pull back r44182 for now "* API: (bug 16526) Added usprop=canemail to list=us...brion23:37, 3 December 2008
r44231API: Recommit r44182 (Added usprop=canemail to list=users) and rename canemai...catrope14:42, 4 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   23:39, 3 December 2008

Reverted in r44202 -- "canemail" is an ambiguous term, and I strongly recommend using something that's more clear about who's doing the emailing.

Status & tagging log