Index: trunk/phase3/includes/api/ApiQueryWatchlistRaw.php |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | |
55 | 55 | $params = $this->extractRequestParams(); |
56 | 56 | |
57 | | - $user = ApiQueryWatchlist::getWatchlistUser( $params ); |
| 57 | + $user = $this->getWatchlistUser( $params ); |
58 | 58 | |
59 | 59 | $prop = array_flip( (array)$params['prop'] ); |
60 | 60 | $show = array_flip( (array)$params['show'] ); |
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | |
59 | 59 | $params = $this->extractRequestParams(); |
60 | 60 | |
61 | | - $user = ApiQueryWatchlist::getWatchlistUser( $params ); |
| 61 | + $user = $this->getWatchlistUser( $params ); |
62 | 62 | |
63 | 63 | if ( !is_null( $params['prop'] ) && is_null( $resultPageSet ) ) { |
64 | 64 | $prop = array_flip( $params['prop'] ); |
— | — | @@ -258,7 +258,9 @@ |
259 | 259 | } |
260 | 260 | |
261 | 261 | if ( $this->fld_notificationtimestamp ) { |
262 | | - $vals['notificationtimestamp'] = ( $row->wl_notificationtimestamp == null ) ? '' : wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp ); |
| 262 | + $vals['notificationtimestamp'] = ( $row->wl_notificationtimestamp == null ) |
| 263 | + ? '' |
| 264 | + : wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp ); |
263 | 265 | } |
264 | 266 | |
265 | 267 | if ( $this->fld_comment && isset( $row->rc_comment ) ) { |
— | — | @@ -273,30 +275,6 @@ |
274 | 276 | return $vals; |
275 | 277 | } |
276 | 278 | |
277 | | - /** |
278 | | - * Gets the user for whom to get the watchlist |
279 | | - * |
280 | | - * @returns User |
281 | | - */ |
282 | | - public static function getWatchlistUser( $params ) { |
283 | | - global $wgUser; |
284 | | - if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) { |
285 | | - $user = User::newFromName( $params['owner'], false ); |
286 | | - if ( !$user->getId() ) { |
287 | | - $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' ); |
288 | | - } |
289 | | - $token = $user->getOption( 'watchlisttoken' ); |
290 | | - if ( $token == '' || $token != $params['token'] ) { |
291 | | - $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' ); |
292 | | - } |
293 | | - } elseif ( !$wgUser->isLoggedIn() ) { |
294 | | - $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
295 | | - } else { |
296 | | - $user = $wgUser; |
297 | | - } |
298 | | - return $user; |
299 | | - } |
300 | | - |
301 | 279 | public function getAllowedParams() { |
302 | 280 | return array( |
303 | 281 | 'allrev' => false, |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -1083,6 +1083,30 @@ |
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | /** |
| 1087 | + * Gets the user for whom to get the watchlist |
| 1088 | + * |
| 1089 | + * @returns User |
| 1090 | + */ |
| 1091 | + public function getWatchlistUser( $params ) { |
| 1092 | + global $wgUser; |
| 1093 | + if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) { |
| 1094 | + $user = User::newFromName( $params['owner'], false ); |
| 1095 | + if ( !$user->getId() ) { |
| 1096 | + $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' ); |
| 1097 | + } |
| 1098 | + $token = $user->getOption( 'watchlisttoken' ); |
| 1099 | + if ( $token == '' || $token != $params['token'] ) { |
| 1100 | + $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' ); |
| 1101 | + } |
| 1102 | + } elseif ( !$wgUser->isLoggedIn() ) { |
| 1103 | + $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
| 1104 | + } else { |
| 1105 | + $user = $wgUser; |
| 1106 | + } |
| 1107 | + return $user; |
| 1108 | + } |
| 1109 | + |
| 1110 | + /** |
1087 | 1111 | * Returns a list of all possible errors returned by the module |
1088 | 1112 | * @return array in the format of array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... ) |
1089 | 1113 | */ |