summaryrefslogtreecommitdiff
path: root/includes/api/ApiQueryUsers.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-06-10 13:00:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2009-06-10 13:00:47 +0200
commit72e90545454c0e014318fa3c81658e035aac58c1 (patch)
tree9212e3f46868989c4d57ae9a5c8a1a80e4dc0702 /includes/api/ApiQueryUsers.php
parent565a0ccc371ec1a2a0e9b39487cbac18e6f60e25 (diff)
applying patch to version 1.15.0
Diffstat (limited to 'includes/api/ApiQueryUsers.php')
-rw-r--r--includes/api/ApiQueryUsers.php121
1 files changed, 65 insertions, 56 deletions
diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php
index e50d8d82..b8aa60e7 100644
--- a/includes/api/ApiQueryUsers.php
+++ b/includes/api/ApiQueryUsers.php
@@ -51,82 +51,91 @@ if (!defined('MEDIAWIKI')) {
$this->prop = array();
}
- if(is_array($params['users'])) {
- $r = $this->getOtherUsersInfo($params['users']);
- $result->setIndexedTagName($r, 'user');
- }
- $result->addValue("query", $this->getModuleName(), $r);
- }
-
- protected function getOtherUsersInfo($users) {
- $goodNames = $retval = array();
+ $users = (array)$params['users'];
+ $goodNames = $done = array();
+ $result = $this->getResult();
// Canonicalize user names
foreach($users as $u) {
$n = User::getCanonicalName($u);
if($n === false || $n === '')
- $retval[] = array('name' => $u, 'invalid' => '');
+ {
+ $vals = array('name' => $u, 'invalid' => '');
+ $fit = $result->addValue(array('query', $this->getModuleName()),
+ null, $vals);
+ if(!$fit)
+ {
+ $this->setContinueEnumParameter('users',
+ implode('|', array_diff($users, $done)));
+ $goodNames = array();
+ break;
+ }
+ $done[] = $u;
+ }
else
$goodNames[] = $n;
}
- if(!count($goodNames))
- return $retval;
-
- $db = $this->getDB();
- $this->addTables('user', 'u1');
- $this->addFields('u1.*');
- $this->addWhereFld('u1.user_name', $goodNames);
-
- if(isset($this->prop['groups'])) {
- $this->addTables('user_groups');
- $this->addJoinConds(array('user_groups' => array('LEFT JOIN', 'ug_user=u1.user_id')));
- $this->addFields('ug_group');
- }
- if(isset($this->prop['blockinfo'])) {
- $this->addTables('ipblocks');
- $this->addTables('user', 'u2');
- $u2 = $this->getAliasedName('user', 'u2');
- $this->addJoinConds(array(
- 'ipblocks' => array('LEFT JOIN', 'ipb_user=u1.user_id'),
- $u2 => array('LEFT JOIN', 'ipb_by=u2.user_id')));
- $this->addFields(array('ipb_reason', 'u2.user_name blocker_name'));
- }
+ if(count($goodNames))
+ {
+ $db = $this->getDb();
+ $this->addTables('user', 'u1');
+ $this->addFields('u1.*');
+ $this->addWhereFld('u1.user_name', $goodNames);
+
+ if(isset($this->prop['groups'])) {
+ $this->addTables('user_groups');
+ $this->addJoinConds(array('user_groups' => array('LEFT JOIN', 'ug_user=u1.user_id')));
+ $this->addFields('ug_group');
+ }
+ if(isset($this->prop['blockinfo'])) {
+ $this->addTables('ipblocks');
+ $this->addTables('user', 'u2');
+ $u2 = $this->getAliasedName('user', 'u2');
+ $this->addJoinConds(array(
+ 'ipblocks' => array('LEFT JOIN', 'ipb_user=u1.user_id'),
+ $u2 => array('LEFT JOIN', 'ipb_by=u2.user_id')));
+ $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name'));
+ }
- $data = array();
- $res = $this->select(__METHOD__);
- while(($r = $db->fetchObject($res))) {
- $user = User::newFromRow($r);
- $name = $user->getName();
- $data[$name]['name'] = $name;
- if(isset($this->prop['editcount']))
- // No proper member function in User class for this
- $data[$name]['editcount'] = $r->user_editcount;
- if(isset($this->prop['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 = array();
+ $res = $this->select(__METHOD__);
+ while(($r = $db->fetchObject($res))) {
+ $user = User::newFromRow($r);
+ $name = $user->getName();
+ $data[$name]['name'] = $name;
+ if(isset($this->prop['editcount']))
+ $data[$name]['editcount'] = intval($user->getEditCount());
+ if(isset($this->prop['registration']))
+ $data[$name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $user->getRegistration());
+ if(isset($this->prop['groups']) && !is_null($r->ug_group))
+ // This row contains only one group, others will be added from other rows
$data[$name]['groups'][] = $r->ug_group;
- if(isset($this->prop['blockinfo']))
- if(!is_null($r->blocker_name)) {
+ if(isset($this->prop['blockinfo']) && !is_null($r->blocker_name)) {
$data[$name]['blockedby'] = $r->blocker_name;
$data[$name]['blockreason'] = $r->ipb_reason;
}
- if(isset($this->prop['emailable']) && $user->canReceiveEmail())
- $data[$name]['emailable'] = '';
+ if(isset($this->prop['emailable']) && $user->canReceiveEmail())
+ $data[$name]['emailable'] = '';
+ }
}
-
// Second pass: add result data to $retval
foreach($goodNames as $u) {
if(!isset($data[$u]))
- $retval[] = array('name' => $u, 'missing' => '');
+ $data[$u] = array('name' => $u, 'missing' => '');
else {
if(isset($this->prop['groups']) && isset($data[$u]['groups']))
$this->getResult()->setIndexedTagName($data[$u]['groups'], 'g');
- $retval[] = $data[$u];
}
+ $fit = $result->addValue(array('query', $this->getModuleName()),
+ null, $data[$u]);
+ if(!$fit)
+ {
+ $this->setContinueEnumParameter('users',
+ implode('|', array_diff($users, $done)));
+ break;
+ }
+ $done[] = $u;
}
- return $retval;
+ return $this->getResult()->setIndexedTagName_internal(array('query', $this->getModuleName()), 'user');
}
public function getAllowedParams() {
@@ -171,6 +180,6 @@ if (!defined('MEDIAWIKI')) {
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiQueryUsers.php 44231 2008-12-04 14:42:30Z catrope $';
+ return __CLASS__ . ': $Id: ApiQueryUsers.php 50094 2009-05-01 06:24:09Z tstarling $';
}
}