X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedContributions.php;h=edda67231f5adaab45579104e2887d151fdc3f94;hb=524d92b61f2a951200b00326cfac6b25a830acb6;hp=3392a5c2ed44c7cf9c7a26a24c23a25c39af7acb;hpb=4fbd12e43e6ef0757388c5ee43e65c4cc1be609e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index 3392a5c2ed..edda67231f 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,40 +207,22 @@ class ApiFeedContributions extends ApiBase { 'deletedonly' => false, 'toponly' => false, 'newonly' => false, - 'showsizediff' => 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', + 'showsizediff' => array( + ApiBase::PARAM_DFLT => false, + ), ); - } - public function getDescription() { - return 'Returns a user contributions feed.'; - } + if ( $this->getConfig()->get( 'MiserMode' ) ) { + $ret['showsizediff'][ApiBase::PARAM_HELP_MSG] = 'api-help-param-disabled-in-miser-mode'; + } - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'feed-unavailable', 'info' => 'Syndication feeds are not available' ), - array( 'code' => 'feed-invalid', 'info' => 'Invalid subscription feed type' ), - array( 'code' => 'sizediffdisabled', 'info' => 'Size difference is disabled in Miser Mode' ), - ) ); + return $ret; } - public function getExamples() { + protected function getExamplesMessages() { return array( - 'api.php?action=feedcontributions&user=Reedy', + 'action=feedcontributions&user=Example' + => 'apihelp-feedcontributions-example-simple', ); } }