Resolve fixme of r66539
authorSam Reed <reedy@users.mediawiki.org>
Tue, 22 Jun 2010 12:10:26 +0000 (12:10 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 22 Jun 2010 12:10:26 +0000 (12:10 +0000)
Move getWatchlistUser to ApiBase

includes/api/ApiBase.php
includes/api/ApiQueryWatchlist.php
includes/api/ApiQueryWatchlistRaw.php

index 3262f40..3656c2c 100644 (file)
@@ -1082,6 +1082,30 @@ abstract class ApiBase {
                return false;
        }
 
+       /**
+       * Gets the user for whom to get the watchlist
+       *  
+       * @returns User
+       */
+       public function getWatchlistUser( $params ) {
+               global $wgUser;
+               if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) {
+                       $user = User::newFromName( $params['owner'], false );
+                       if ( !$user->getId() ) {
+                               $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' );
+                       }
+                       $token = $user->getOption( 'watchlisttoken' );
+                       if ( $token == '' || $token != $params['token'] ) {
+                               $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' );
+                       }
+               } elseif ( !$wgUser->isLoggedIn() ) {
+                       $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
+               } else {
+                       $user = $wgUser;
+               }
+               return $user;
+       }
+
        /**
         * Returns a list of all possible errors returned by the module
         * @return array in the format of array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
index aecfc88..b027cd9 100644 (file)
@@ -57,7 +57,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
 
                $params = $this->extractRequestParams();
                
-               $user = ApiQueryWatchlist::getWatchlistUser( $params );
+               $user = $this->getWatchlistUser( $params );
 
                if ( !is_null( $params['prop'] ) && is_null( $resultPageSet ) ) {
                        $prop = array_flip( $params['prop'] );
@@ -258,7 +258,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                }
 
                if ( $this->fld_notificationtimestamp ) {
-                       $vals['notificationtimestamp'] = ( $row->wl_notificationtimestamp == null ) ? '' : wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp );
+                       $vals['notificationtimestamp'] = ( $row->wl_notificationtimestamp == null ) 
+                               ? '' 
+                               : wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp );
                }
 
                if ( $this->fld_comment && isset( $row->rc_comment ) ) {
@@ -273,30 +275,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                return $vals;
        }
 
-       /**
-       * Gets the user for whom to get the watchlist
-       *  
-       * @returns User
-       */
-       public static function getWatchlistUser( $params ) {
-               global $wgUser;
-               if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) {
-                       $user = User::newFromName( $params['owner'], false );
-                       if ( !$user->getId() ) {
-                               $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' );
-                       }
-                       $token = $user->getOption( 'watchlisttoken' );
-                       if ( $token == '' || $token != $params['token'] ) {
-                               $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' );
-                       }
-               } elseif ( !$wgUser->isLoggedIn() ) {
-                       $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
-               } else {
-                       $user = $wgUser;
-               }
-               return $user;
-       }
-
        public function getAllowedParams() {
                return array(
                        'allrev' => false,
index bc2a9a7..3354cc4 100644 (file)
@@ -53,7 +53,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase {
                
                $params = $this->extractRequestParams();
 
-               $user = ApiQueryWatchlist::getWatchlistUser( $params );
+               $user = $this->getWatchlistUser( $params );
 
                $prop = array_flip( (array)$params['prop'] );
                $show = array_flip( (array)$params['show'] );