Merge "TimeAdjustTest: Use dataProvider"
[lhc/web/wiklou.git] / includes / api / ApiFeedWatchlist.php
index 6c793b3..fdbdcc3 100644 (file)
@@ -33,6 +33,9 @@
  */
 class ApiFeedWatchlist extends ApiBase {
 
+       private $linkToDiffs = false;
+       private $watchlistModule = null;
+
        /**
         * This module uses a custom feed wrapper printer.
         *
@@ -42,8 +45,6 @@ class ApiFeedWatchlist extends ApiBase {
                return new ApiFormatFeedWrapper( $this->getMain() );
        }
 
-       private $linkToDiffs = false;
-
        /**
         * Make a nested call to the API to request watchlist items in the last $hours.
         * Wrap the result as an RSS/Atom feed.
@@ -86,6 +87,9 @@ class ApiFeedWatchlist extends ApiBase {
                        if ( $params['wlexcludeuser'] !== null ) {
                                $fauxReqArr['wlexcludeuser'] = $params['wlexcludeuser'];
                        }
+                       if ( $params['wlshow'] !== null ) {
+                               $fauxReqArr['wlshow'] = $params['wlshow'];
+                       }
 
                        // Support linking to diffs instead of article
                        if ( $params['linktodiffs'] ) {
@@ -168,10 +172,18 @@ class ApiFeedWatchlist extends ApiBase {
                return new FeedItem( $titleStr, $completeText, $titleUrl, $timestamp, $user );
        }
 
-       public function getAllowedParams() {
+       private function getWatchlistModule() {
+               if ( $this->watchlistModule === null ) {
+                       $this->watchlistModule = $this->getMain()->getModuleManager()->getModule( 'query' )
+                               ->getModuleManager()->getModule( 'watchlist' );
+               }
+               return $this->watchlistModule;
+       }
+
+       public function getAllowedParams( $flags = 0 ) {
                global $wgFeedClasses;
                $feedFormatNames = array_keys( $wgFeedClasses );
-               return array (
+               $ret = array(
                        'feedformat' => array(
                                ApiBase::PARAM_DFLT => 'rss',
                                ApiBase::PARAM_TYPE => $feedFormatNames
@@ -182,29 +194,36 @@ class ApiFeedWatchlist extends ApiBase {
                                ApiBase::PARAM_MIN => 1,
                                ApiBase::PARAM_MAX => 72,
                        ),
-                       'allrev' => false,
-                       'wlowner' => array(
-                               ApiBase::PARAM_TYPE => 'user'
-                       ),
-                       'wltoken' => array(
-                               ApiBase::PARAM_TYPE => 'string'
-                       ),
-                       'wlexcludeuser' => array(
-                               ApiBase::PARAM_TYPE => 'user'
-                       ),
                        'linktodiffs' => false,
                );
+               if ( $flags ) {
+                       $wlparams = $this->getWatchlistModule()->getAllowedParams( $flags );
+                       $ret['allrev'] = $wlparams['allrev'];
+                       $ret['wlowner'] = $wlparams['owner'];
+                       $ret['wltoken'] = $wlparams['token'];
+                       $ret['wlshow'] = $wlparams['show'];
+                       $ret['wlexcludeuser'] = $wlparams['excludeuser'];
+               } else {
+                       $ret['allrev'] = null;
+                       $ret['wlowner'] = null;
+                       $ret['wltoken'] = null;
+                       $ret['wlshow'] = null;
+                       $ret['wlexcludeuser'] = null;
+               }
+               return $ret;
        }
 
        public function getParamDescription() {
+               $wldescr = $this->getWatchlistModule()->getParamDescription();
                return array(
                        'feedformat' => 'The format of the feed',
-                       'hours'      => 'List pages modified within this many hours from now',
-                       'allrev'     => 'Include multiple revisions of the same page within given timeframe',
-                       'wlowner'    => "The user whose watchlist you want (must be accompanied by {$this->getModulePrefix()}wltoken if it's not you)",
-                       'wltoken'    => 'Security token that requested user set in their preferences',
-                       'wlexcludeuser' => 'A user whose edits should not be shown in the watchlist',
+                       'hours' => 'List pages modified within this many hours from now',
                        'linktodiffs' => 'Link to change differences instead of article pages',
+                       'allrev' => $wldescr['allrev'],
+                       'wlowner' => $wldescr['owner'],
+                       'wltoken' => $wldescr['token'],
+                       'wlshow' => $wldescr['show'],
+                       'wlexcludeuser' => $wldescr['excludeuser'],
                );
        }