Merge branch 'MDL-57638_rss_skip' of git://github.com/davosmith/moodle
This commit is contained in:
@@ -33,6 +33,9 @@
|
||||
/** The maximum time in seconds that cron will wait between attempts to retry failing RSS feeds. */
|
||||
const CLIENT_MAX_SKIPTIME = 43200; // 60 * 60 * 12 seconds.
|
||||
|
||||
/** @var bool track whether any of the output feeds have recorded failures */
|
||||
private $hasfailedfeeds = false;
|
||||
|
||||
function init() {
|
||||
$this->title = get_string('pluginname', 'block_rss_client');
|
||||
}
|
||||
@@ -59,6 +62,7 @@
|
||||
* @return block_rss_client\output\footer|null The renderable footer or null if none should be displayed.
|
||||
*/
|
||||
protected function get_footer($feedrecords) {
|
||||
global $PAGE;
|
||||
$footer = null;
|
||||
|
||||
if ($this->config->block_rss_client_show_channel_link) {
|
||||
@@ -74,6 +78,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->hasfailedfeeds) {
|
||||
if (has_any_capability(['block/rss_client:manageownfeeds', 'block/rss_client:manageanyfeeds'], $this->context)) {
|
||||
if ($footer === null) {
|
||||
$footer = new block_rss_client\output\footer();
|
||||
}
|
||||
$manageurl = new moodle_url('/blocks/rss_client/managefeeds.php', ['courseid' => $PAGE->course->id]);
|
||||
$footer->set_failed($manageurl);
|
||||
}
|
||||
}
|
||||
|
||||
return $footer;
|
||||
}
|
||||
|
||||
@@ -173,6 +187,12 @@
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/simplepie/moodle_simplepie.php');
|
||||
|
||||
if ($feedrecord->skipuntil) {
|
||||
// Last attempt to gather this feed via cron failed - do not try to fetch it now.
|
||||
$this->hasfailedfeeds = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
$simplepiefeed = new moodle_simplepie($feedrecord->url);
|
||||
|
||||
if(isset($CFG->block_rss_client_timeout)){
|
||||
|
||||
@@ -40,16 +40,23 @@ class footer implements \renderable, \templatable {
|
||||
/**
|
||||
* The link provided in the RSS channel
|
||||
*
|
||||
* @var \moodle_url
|
||||
* @var \moodle_url|null
|
||||
*/
|
||||
protected $channelurl;
|
||||
|
||||
/**
|
||||
* Link to manage feeds, only provided if a feed has failed.
|
||||
*
|
||||
* @var \moodle_url|null
|
||||
*/
|
||||
protected $manageurl = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \moodle_url $channelurl The link provided in the RSS channel
|
||||
* @param \moodle_url $channelurl (optional) The link provided in the RSS channel
|
||||
*/
|
||||
public function __construct(\moodle_url $channelurl) {
|
||||
public function __construct($channelurl = null) {
|
||||
$this->channelurl = $channelurl;
|
||||
}
|
||||
|
||||
@@ -65,6 +72,16 @@ class footer implements \renderable, \templatable {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record the fact that there is at least one failed feed (and the URL for viewing
|
||||
* these failed feeds).
|
||||
*
|
||||
* @param \moodle_url $manageurl the URL to link to for more information
|
||||
*/
|
||||
public function set_failed(\moodle_url $manageurl) {
|
||||
$this->manageurl = $manageurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channel url
|
||||
*
|
||||
@@ -84,6 +101,10 @@ class footer implements \renderable, \templatable {
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
$data = new \stdClass();
|
||||
$data->channellink = clean_param($this->channelurl, PARAM_URL);
|
||||
if ($this->manageurl) {
|
||||
$data->hasfailedfeeds = true;
|
||||
$data->manageurl = clean_param($this->manageurl, PARAM_URL);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ $string['editnewsfeeds'] = 'Edit news feeds';
|
||||
$string['editrssblock'] = 'Edit RSS headline block';
|
||||
$string['enableautodiscovery'] = 'Enable auto-discovery of feeds?';
|
||||
$string['enableautodiscovery_help'] = 'If enabled, feeds on web pages are found automatically. For example, if http://docs.moodle.org is entered, then http://docs.moodle.org/en/index.php?title=Special:RecentChanges&feed=rss would be found.';
|
||||
$string['failedfeed'] = 'Feed failed to download - will retry after {$a}';
|
||||
$string['failedfeeds'] = 'One or more RSS feeds have failed';
|
||||
$string['feed'] = 'Feed';
|
||||
$string['feedadded'] = 'News feed added';
|
||||
$string['feeddeleted'] = 'News feed deleted';
|
||||
|
||||
@@ -114,6 +114,13 @@ foreach($feeds as $feed) {
|
||||
$feedinfo = '<div class="title">' . $viewlink . '</div>' .
|
||||
'<div class="url">' . html_writer::link($feed->url, $feed->url) .'</div>' .
|
||||
'<div class="description">' . $feed->description . '</div>';
|
||||
if ($feed->skipuntil) {
|
||||
$skipuntil = userdate($feed->skipuntil, get_string('strftimedatetime', 'langconfig'));
|
||||
$skipmsg = get_string('failedfeed', 'block_rss_client', $skipuntil);
|
||||
$notification = new \core\output\notification($skipmsg, 'error');
|
||||
$notification->set_show_closebutton(false);
|
||||
$feedinfo .= $OUTPUT->render($notification);
|
||||
}
|
||||
|
||||
$editurl = new moodle_url('/blocks/rss_client/editfeed.php?rssid=' . $feed->id . $extraparams);
|
||||
$editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')));
|
||||
|
||||
@@ -33,4 +33,10 @@
|
||||
"channellink": "https://www.example.com/feeds/rss"
|
||||
}
|
||||
}}
|
||||
<a href="{{{channellink}}}">{{#str}} clientchannellink, block_rss_client {{/str}}</a>
|
||||
{{#channellink}}
|
||||
<a href="{{{channellink}}}">{{#str}} clientchannellink, block_rss_client {{/str}}</a>
|
||||
{{#hasfailedfeeds}}<br>{{/hasfailedfeeds}}
|
||||
{{/channellink}}
|
||||
{{#hasfailedfeeds}}
|
||||
<a href="{{{manageurl}}}">{{#str}} failedfeeds, block_rss_client {{/str}}</a>
|
||||
{{/hasfailedfeeds}}
|
||||
Reference in New Issue
Block a user