* Re-applying r34449, r34500 and r34518 which Brion reverted by accident
[lhc/web/wiklou.git] / includes / api / ApiQueryUsers.php
index c0cae50..1d94648 100644 (file)
@@ -72,24 +72,26 @@ if (!defined('MEDIAWIKI')) {
                        return $retval;
 
                $db = $this->getDb();
-               $userTable = $db->tableName('user');
-               $tables = "$userTable AS u1";
+               $this->addTables('user', 'u1');
                $this->addFields('u1.user_name');
                $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'])) {
-                       $ug = $db->tableName('user_groups');
-                       $tables = "$tables LEFT JOIN $ug ON ug_user=u1.user_id";
+                       $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'])) {
-                       $ipb = $db->tableName('ipblocks');
-                       $tables = "$tables LEFT JOIN $ipb ON ipb_user=u1.user_id";
-                       $tables = "$tables LEFT JOIN $userTable AS u2 ON ipb_by=u2.user_id";
-                       $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name'));
+                       $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'));
                }
-               $this->addTables($tables);
 
                $data = array();
                $res = $this->select(__METHOD__);
@@ -97,6 +99,8 @@ if (!defined('MEDIAWIKI')) {
                        $data[$r->user_name]['name'] = $r->user_name;
                        if(isset($this->prop['editcount']))
                                $data[$r->user_name]['editcount'] = $r->user_editcount;
+                       if(isset($this->prop['registration']))
+                               $data[$r->user_name]['registration'] = wfTimestamp(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))
@@ -129,7 +133,8 @@ if (!defined('MEDIAWIKI')) {
                                ApiBase :: PARAM_TYPE => array (
                                        'blockinfo',
                                        'groups',
-                                       'editcount'
+                                       'editcount',
+                                       'registration'
                                )
                        ),
                        'users' => array(