From: Roan Kattouw Date: Wed, 3 Dec 2008 19:07:16 +0000 (+0000) Subject: * API: (bug 16526) Added usprop=canemail to list=users, which tells whether a user... X-Git-Tag: 1.31.0-rc.0~44141 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=1040ce28e4ea559758f4ba4237420fbc4bb195fd;p=lhc%2Fweb%2Fwiklou.git * 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 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b1967b637d..3873c1e997 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -483,6 +483,7 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 16421) Made list=logevents's leuser accept user names with underscores instead of spaces * (bug 16516) Made rvsection=T-2 work +* (bug 16526) Added usprop=canemail to list=users === Languages updated in 1.14 === diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index a8b56321e2..7f4c60cfb0 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -73,10 +73,8 @@ if (!defined('MEDIAWIKI')) { $db = $this->getDB(); $this->addTables('user', 'u1'); - $this->addFields('u1.user_name'); + $this->addFields('u1.*'); $this->addWhereFld('u1.user_name', $goodNames); - $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount'])); - $this->addFieldsIf('u1.user_registration', isset($this->prop['registration'])); if(isset($this->prop['groups'])) { $this->addTables('user_groups'); @@ -96,20 +94,26 @@ if (!defined('MEDIAWIKI')) { $data = array(); $res = $this->select(__METHOD__); while(($r = $db->fetchObject($res))) { - $data[$r->user_name]['name'] = $r->user_name; + $user = User::newFromRow($r); + $name = $user->getName(); + $data[$name]['name'] = $name; if(isset($this->prop['editcount'])) - $data[$r->user_name]['editcount'] = $r->user_editcount; + // No proper member function in User class for this + $data[$name]['editcount'] = $r->user_editcount; if(isset($this->prop['registration'])) - $data[$r->user_name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $r->user_registration); + // Nor for this one + $data[$name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $r->user_registration); if(isset($this->prop['groups'])) // This row contains only one group, others will be added from other rows if(!is_null($r->ug_group)) - $data[$r->user_name]['groups'][] = $r->ug_group; + $data[$name]['groups'][] = $r->ug_group; if(isset($this->prop['blockinfo'])) if(!is_null($r->blocker_name)) { - $data[$r->user_name]['blockedby'] = $r->blocker_name; - $data[$r->user_name]['blockreason'] = $r->ipb_reason; + $data[$name]['blockedby'] = $r->blocker_name; + $data[$name]['blockreason'] = $r->ipb_reason; } + if(isset($this->prop['canemail']) && $user->canReceiveEmail()) + $data[$name]['canemail'] = ''; } // Second pass: add result data to $retval @@ -134,7 +138,8 @@ if (!defined('MEDIAWIKI')) { 'blockinfo', 'groups', 'editcount', - 'registration' + 'registration', + 'canemail', ) ), 'users' => array( @@ -147,9 +152,11 @@ if (!defined('MEDIAWIKI')) { return array ( 'prop' => array( 'What pieces of information to include', - ' blockinfo - tags if the user is blocked, by whom, and for what reason', - ' groups - lists all the groups the user belongs to', - ' editcount - adds the user\'s edit count' + ' blockinfo - tags if the user is blocked, by whom, and for what reason', + ' groups - lists all the groups the user belongs to', + ' editcount - adds the user\'s edit count', + ' registration - adds the user\'s registration timestamp', + ' canemail - tags if the user can and wants to receive e-mail through [[Special:Emailuser]]', ), 'users' => 'A list of users to obtain the same information for' );