Index: trunk/phase3/includes/api/ApiQueryAllUsers.php |
— | — | @@ -49,22 +49,28 @@ |
50 | 50 | $fld_editcount = isset($prop['editcount']); |
51 | 51 | $fld_groups = isset($prop['groups']); |
52 | 52 | $fld_registration = isset($prop['registration']); |
| 53 | + $fld_blockinfo = isset($prop['blockinfo']); |
53 | 54 | } else { |
54 | | - $fld_editcount = $fld_groups = $fld_registration = false; |
| 55 | + $fld_editcount = $fld_groups = $fld_registration = $fld_blockinfo = false; |
55 | 56 | } |
56 | 57 | |
57 | 58 | $limit = $params['limit']; |
58 | 59 | |
59 | 60 | if( !is_null( $params['from'] ) ) |
60 | | - $this->addWhere( 'user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) ); |
| 61 | + $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) ); |
61 | 62 | |
62 | 63 | if( isset( $params['prefix'] ) ) |
63 | | - $this->addWhere( 'user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' ); |
| 64 | + $this->addWhere( 'u1.user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' ); |
64 | 65 | |
| 66 | + $join = false; |
| 67 | + $tables = array('user'); |
| 68 | + $types = array(); |
| 69 | + $conds = array(); |
| 70 | + $aliases = array('u1'); |
65 | 71 | if (!is_null($params['group'])) { |
66 | 72 | // Filter only users that belong to a given group |
67 | 73 | $this->addTables('user_groups', 'ug1'); |
68 | | - $this->addWhere('ug1.ug_user=user_id'); |
| 74 | + $this->addWhere('ug1.ug_user=u1.user_id'); |
69 | 75 | $this->addWhereFld('ug1.ug_group', $params['group']); |
70 | 76 | } |
71 | 77 | if ($fld_groups) { |
— | — | @@ -72,26 +78,43 @@ |
73 | 79 | // request more than needed to avoid not getting all rows that belong to one user |
74 | 80 | $groupCount = count(User::getAllGroups()); |
75 | 81 | $sqlLimit = $limit+$groupCount+1; |
76 | | - $this->addJoin( |
77 | | - array('user', 'user_groups'), |
78 | | - array(ApiQueryBase::LEFT_JOIN), |
79 | | - array('ug2.ug_user=user_id'), |
80 | | - array(null, 'ug2')); |
| 82 | + |
| 83 | + $join = true; |
| 84 | + $tables[] = 'user_groups'; |
| 85 | + $types[] = ApiQueryBase::LEFT_JOIN; |
| 86 | + $conds[] = 'ug2.ug_user=u1.user_id'; |
| 87 | + $aliases[] = 'ug2'; |
81 | 88 | $this->addFields('ug2.ug_group ug_group2'); |
82 | 89 | } else { |
83 | | - $this->addTables('user'); |
84 | 90 | $sqlLimit = $limit+1; |
85 | 91 | } |
| 92 | + if ($fld_blockinfo) { |
| 93 | + $join = true; |
| 94 | + $tables[] = 'ipblocks'; |
| 95 | + $types[] = ApiQueryBase::LEFT_JOIN; |
| 96 | + $conds[] = 'ipb_user=u1.user_id'; |
| 97 | + $aliases[] = null; |
| 98 | + |
| 99 | + $tables[] = 'user'; |
| 100 | + $types[] = ApiQueryBase::LEFT_JOIN; |
| 101 | + $conds[] = 'ipb_by=u2.user_id'; |
| 102 | + $aliases[] = 'u2'; |
| 103 | + $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name')); |
| 104 | + } |
| 105 | + |
| 106 | + if ($join) { |
| 107 | + $this->addJoin($tables, $types, $conds, $aliases); |
| 108 | + } else { |
| 109 | + $this->addTables('user', 'u1'); |
| 110 | + } |
86 | 111 | |
87 | | - if ($fld_registration) |
88 | | - $this->addFields('user_registration'); |
89 | | - |
90 | 112 | $this->addOption('LIMIT', $sqlLimit); |
91 | 113 | |
92 | | - $this->addFields('user_name'); |
93 | | - $this->addFieldsIf('user_editcount', $fld_editcount); |
| 114 | + $this->addFields('u1.user_name'); |
| 115 | + $this->addFieldsIf('u1.user_editcount', $fld_editcount); |
| 116 | + $this->addFieldsIf('u1.user_registration', $fld_registration); |
94 | 117 | |
95 | | - $this->addOption('ORDER BY', 'user_name'); |
| 118 | + $this->addOption('ORDER BY', 'u1.user_name'); |
96 | 119 | |
97 | 120 | $res = $this->select(__METHOD__); |
98 | 121 | |
— | — | @@ -135,6 +158,10 @@ |
136 | 159 | $lastUserData['editcount'] = intval($row->user_editcount); |
137 | 160 | if ($fld_registration) |
138 | 161 | $lastUserData['registration'] = wfTimestamp(TS_ISO_8601, $row->user_registration); |
| 162 | + if ($fld_blockinfo && !is_null($row->blocker_name)) { |
| 163 | + $lastUserData['blockedby'] = $row->blocker_name; |
| 164 | + $lastUserData['blockreason'] = $row->ipb_reason; |
| 165 | + } |
139 | 166 | |
140 | 167 | } |
141 | 168 | |
— | — | @@ -171,6 +198,7 @@ |
172 | 199 | 'editcount', |
173 | 200 | 'groups', |
174 | 201 | 'registration', |
| 202 | + 'blockinfo' |
175 | 203 | ) |
176 | 204 | ), |
177 | 205 | 'limit' => array ( |
Index: trunk/phase3/includes/api/ApiQueryUsers.php |
— | — | @@ -75,6 +75,7 @@ |
76 | 76 | $this->addFields('u1.user_name'); |
77 | 77 | $this->addWhereFld('u1.user_name', $goodNames); |
78 | 78 | $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount'])); |
| 79 | + $this->addFieldsIf('u1.user_registration', isset($this->prop['registration'])); |
79 | 80 | |
80 | 81 | $join = false; |
81 | 82 | $tables = array('user'); |
— | — | @@ -114,6 +115,8 @@ |
115 | 116 | $data[$r->user_name]['name'] = $r->user_name; |
116 | 117 | if(isset($this->prop['editcount'])) |
117 | 118 | $data[$r->user_name]['editcount'] = $r->user_editcount; |
| 119 | + if(isset($this->prop['registration'])) |
| 120 | + $data[$r->user_name]['registration'] = wfTimestamp(TS_ISO_8601, $r->user_registration); |
118 | 121 | if(isset($this->prop['groups'])) |
119 | 122 | // This row contains only one group, others will be added from other rows |
120 | 123 | if(!is_null($r->ug_group)) |
— | — | @@ -146,7 +149,8 @@ |
147 | 150 | ApiBase :: PARAM_TYPE => array ( |
148 | 151 | 'blockinfo', |
149 | 152 | 'groups', |
150 | | - 'editcount' |
| 153 | + 'editcount', |
| 154 | + 'registration' |
151 | 155 | ) |
152 | 156 | ), |
153 | 157 | 'users' => array( |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -325,6 +325,7 @@ |
326 | 326 | * (bug 14018) Introduced alcontinue to list=alllinks to improve paging |
327 | 327 | * (bug 14013) Added rcshow=patrolled to list=recentchanges |
328 | 328 | * (bug 14028) Added language attribute to interwiki map in meta=siteinfo |
| 329 | +* (bug 14022) Added usprop=registration and auprop=blockinfo |
329 | 330 | |
330 | 331 | === Languages updated in 1.13 === |
331 | 332 | |