From: Roan Kattouw Date: Fri, 9 May 2008 10:00:34 +0000 (+0000) Subject: (bug 14022) Added usprop=registration and auprop=blockinfo X-Git-Tag: 1.31.0-rc.0~47791 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=10274469e56518657dad3a7ae6fdf8fb0b7d442c;p=lhc%2Fweb%2Fwiklou.git (bug 14022) Added usprop=registration and auprop=blockinfo --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7953c87d09..cd67eb0229 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -325,6 +325,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14018) Introduced alcontinue to list=alllinks to improve paging * (bug 14013) Added rcshow=patrolled to list=recentchanges * (bug 14028) Added language attribute to interwiki map in meta=siteinfo +* (bug 14022) Added usprop=registration and auprop=blockinfo === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 71ea2886c5..62fa95cbda 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -49,22 +49,28 @@ class ApiQueryAllUsers extends ApiQueryBase { $fld_editcount = isset($prop['editcount']); $fld_groups = isset($prop['groups']); $fld_registration = isset($prop['registration']); + $fld_blockinfo = isset($prop['blockinfo']); } else { - $fld_editcount = $fld_groups = $fld_registration = false; + $fld_editcount = $fld_groups = $fld_registration = $fld_blockinfo = false; } $limit = $params['limit']; if( !is_null( $params['from'] ) ) - $this->addWhere( 'user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) ); + $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) ); if( isset( $params['prefix'] ) ) - $this->addWhere( 'user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' ); + $this->addWhere( 'u1.user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' ); + $join = false; + $tables = array('user'); + $types = array(); + $conds = array(); + $aliases = array('u1'); if (!is_null($params['group'])) { // Filter only users that belong to a given group $this->addTables('user_groups', 'ug1'); - $this->addWhere('ug1.ug_user=user_id'); + $this->addWhere('ug1.ug_user=u1.user_id'); $this->addWhereFld('ug1.ug_group', $params['group']); } if ($fld_groups) { @@ -72,26 +78,43 @@ class ApiQueryAllUsers extends ApiQueryBase { // request more than needed to avoid not getting all rows that belong to one user $groupCount = count(User::getAllGroups()); $sqlLimit = $limit+$groupCount+1; - $this->addJoin( - array('user', 'user_groups'), - array(ApiQueryBase::LEFT_JOIN), - array('ug2.ug_user=user_id'), - array(null, 'ug2')); + + $join = true; + $tables[] = 'user_groups'; + $types[] = ApiQueryBase::LEFT_JOIN; + $conds[] = 'ug2.ug_user=u1.user_id'; + $aliases[] = 'ug2'; $this->addFields('ug2.ug_group ug_group2'); } else { - $this->addTables('user'); $sqlLimit = $limit+1; } - - if ($fld_registration) - $this->addFields('user_registration'); + if ($fld_blockinfo) { + $join = true; + $tables[] = 'ipblocks'; + $types[] = ApiQueryBase::LEFT_JOIN; + $conds[] = 'ipb_user=u1.user_id'; + $aliases[] = null; + + $tables[] = 'user'; + $types[] = ApiQueryBase::LEFT_JOIN; + $conds[] = 'ipb_by=u2.user_id'; + $aliases[] = 'u2'; + $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name')); + } + + if ($join) { + $this->addJoin($tables, $types, $conds, $aliases); + } else { + $this->addTables('user', 'u1'); + } $this->addOption('LIMIT', $sqlLimit); - $this->addFields('user_name'); - $this->addFieldsIf('user_editcount', $fld_editcount); + $this->addFields('u1.user_name'); + $this->addFieldsIf('u1.user_editcount', $fld_editcount); + $this->addFieldsIf('u1.user_registration', $fld_registration); - $this->addOption('ORDER BY', 'user_name'); + $this->addOption('ORDER BY', 'u1.user_name'); $res = $this->select(__METHOD__); @@ -135,6 +158,10 @@ class ApiQueryAllUsers extends ApiQueryBase { $lastUserData['editcount'] = intval($row->user_editcount); if ($fld_registration) $lastUserData['registration'] = wfTimestamp(TS_ISO_8601, $row->user_registration); + if ($fld_blockinfo && !is_null($row->blocker_name)) { + $lastUserData['blockedby'] = $row->blocker_name; + $lastUserData['blockreason'] = $row->ipb_reason; + } } @@ -171,6 +198,7 @@ class ApiQueryAllUsers extends ApiQueryBase { 'editcount', 'groups', 'registration', + 'blockinfo' ) ), 'limit' => array ( diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index 82908189fe..9f6bf7af7a 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -75,6 +75,7 @@ if (!defined('MEDIAWIKI')) { $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'])); $join = false; $tables = array('user'); @@ -114,6 +115,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)) @@ -146,7 +149,8 @@ if (!defined('MEDIAWIKI')) { ApiBase :: PARAM_TYPE => array ( 'blockinfo', 'groups', - 'editcount' + 'editcount', + 'registration' ) ), 'users' => array(