diff options
Diffstat (limited to 'includes/api/ApiFeedContributions.php')
-rw-r--r-- | includes/api/ApiFeedContributions.php | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index 374203eb..edda6723 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -95,7 +95,10 @@ class ApiFeedContributions extends ApiBase { if ( ++$count > $limit ) { break; } - $feedItems[] = $this->feedItem( $row ); + $item = $this->feedItem( $row ); + if ( $item !== null ) { + $feedItems[] = $item; + } } } @@ -103,6 +106,23 @@ class ApiFeedContributions extends ApiBase { } protected function feedItem( $row ) { + // This hook is the api contributions equivalent to the + // ContributionsLineEnding hook. Hook implementers may cancel + // the hook to signal the user is not allowed to read this item. + $feedItem = null; + $hookResult = Hooks::run( + 'ApiFeedContributions::feedItem', + array( $row, $this->getContext(), &$feedItem ) + ); + // Hook returned a valid feed item + if ( $feedItem instanceof FeedItem ) { + return $feedItem; + // Hook was canceled and did not return a valid feed item + } elseif ( !$hookResult ) { + return null; + } + + // Hook completed and did not return a valid feed item $title = Title::makeTitle( intval( $row->page_namespace ), $row->page_title ); if ( $title && $title->userCan( 'read', $this->getUser() ) ) { $date = $row->rev_timestamp; @@ -161,7 +181,7 @@ class ApiFeedContributions extends ApiBase { public function getAllowedParams() { $feedFormatNames = array_keys( $this->getConfig()->get( 'FeedClasses' ) ); - return array( + $ret = array( 'feedformat' => array( ApiBase::PARAM_DFLT => 'rss', ApiBase::PARAM_TYPE => $feedFormatNames @@ -187,32 +207,22 @@ class ApiFeedContributions extends ApiBase { 'deletedonly' => false, 'toponly' => false, 'newonly' => false, - 'showsizediff' => false, + 'showsizediff' => array( + ApiBase::PARAM_DFLT => false, + ), ); - } - public function getParamDescription() { - return array( - 'feedformat' => 'The format of the feed', - 'user' => 'What users to get the contributions for', - 'namespace' => 'What namespace to filter the contributions by', - 'year' => 'From year (and earlier)', - 'month' => 'From month (and earlier)', - 'tagfilter' => 'Filter contributions that have these tags', - 'deletedonly' => 'Show only deleted contributions', - 'toponly' => 'Only show edits that are latest revisions', - 'newonly' => 'Only show edits that are page creations', - 'showsizediff' => 'Show the size difference between revisions. Disabled in Miser Mode', - ); - } + if ( $this->getConfig()->get( 'MiserMode' ) ) { + $ret['showsizediff'][ApiBase::PARAM_HELP_MSG] = 'api-help-param-disabled-in-miser-mode'; + } - public function getDescription() { - return 'Returns a user contributions feed.'; + return $ret; } - public function getExamples() { + protected function getExamplesMessages() { return array( - 'api.php?action=feedcontributions&user=Reedy', + 'action=feedcontributions&user=Example' + => 'apihelp-feedcontributions-example-simple', ); } } |