Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -252,6 +252,7 @@ |
253 | 253 | * (bug 27342) Add audir param to list=allusers |
254 | 254 | * (bug 27203) add fato param to list=filearchive |
255 | 255 | * (bug 27341) Add drto param to list=deletedrevs |
| 256 | +* (bug 26630) Add api for Special:ActiveUsers |
256 | 257 | |
257 | 258 | === Languages updated in 1.18 === |
258 | 259 | |
Index: trunk/phase3/includes/api/ApiQueryAllUsers.php |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 | } |
58 | 58 | |
59 | 59 | $limit = $params['limit']; |
| 60 | + |
60 | 61 | $this->addTables( 'user' ); |
61 | 62 | $useIndex = true; |
62 | 63 | |
— | — | @@ -97,6 +98,8 @@ |
98 | 99 | $this->addWhere( 'user_editcount > 0' ); |
99 | 100 | } |
100 | 101 | |
| 102 | + $this->showHiddenUsersAddBlockInfo( $fld_blockinfo ); |
| 103 | + |
101 | 104 | if ( $fld_groups || $fld_rights ) { |
102 | 105 | // Show the groups the given users belong to |
103 | 106 | // request more than needed to avoid not getting all rows that belong to one user |
— | — | @@ -111,8 +114,21 @@ |
112 | 115 | $sqlLimit = $limit + 1; |
113 | 116 | } |
114 | 117 | |
115 | | - $this->showHiddenUsersAddBlockInfo( $fld_blockinfo ); |
| 118 | + if ( $params['activeusers'] ) { |
| 119 | + global $wgActiveUserDays; |
| 120 | + $this->addTables( 'recentchanges' ); |
116 | 121 | |
| 122 | + $this->addJoinConds( array( 'recentchanges' => array( |
| 123 | + 'INNER JOIN', 'rc_user=user_id' |
| 124 | + ) ) ); |
| 125 | + |
| 126 | + $this->addFields( 'COUNT(*) AS recentedits' ); |
| 127 | + |
| 128 | + $this->addWhere( "rc_log_type IS NULL OR rc_log_type != 'newusers'" ); |
| 129 | + $timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays*24*3600 ); |
| 130 | + $this->addWhere( "rc_timestamp >= {$db->addQuotes( $timestamp )}" ); |
| 131 | + } |
| 132 | + |
117 | 133 | $this->addOption( 'LIMIT', $sqlLimit ); |
118 | 134 | |
119 | 135 | $this->addFields( array( |
— | — | @@ -181,11 +197,13 @@ |
182 | 198 | if ( $fld_editcount ) { |
183 | 199 | $lastUserData['editcount'] = intval( $row->user_editcount ); |
184 | 200 | } |
| 201 | + if ( $params['activeusers'] ) { |
| 202 | + $lastUserData['recenteditcount'] = intval( $row->recentedits ); |
| 203 | + } |
185 | 204 | if ( $fld_registration ) { |
186 | 205 | $lastUserData['registration'] = $row->user_registration ? |
187 | 206 | wfTimestamp( TS_ISO_8601, $row->user_registration ) : ''; |
188 | 207 | } |
189 | | - |
190 | 208 | } |
191 | 209 | |
192 | 210 | if ( $sqlLimit == $count ) { |
— | — | @@ -270,10 +288,12 @@ |
271 | 289 | ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
272 | 290 | ), |
273 | 291 | 'witheditsonly' => false, |
| 292 | + 'activeusers' => false, |
274 | 293 | ); |
275 | 294 | } |
276 | 295 | |
277 | 296 | public function getParamDescription() { |
| 297 | + global $wgActiveUserDays; |
278 | 298 | return array( |
279 | 299 | 'from' => 'The user name to start enumerating from', |
280 | 300 | 'to' => 'The user name to stop enumerating at', |
— | — | @@ -291,6 +311,7 @@ |
292 | 312 | ), |
293 | 313 | 'limit' => 'How many total user names to return', |
294 | 314 | 'witheditsonly' => 'Only list users who have made edits', |
| 315 | + 'activeusers' => "Only list users active in the last {$wgActiveUserDays} days(s)" |
295 | 316 | ); |
296 | 317 | } |
297 | 318 | |