} else {
$userid = $USER->id;
}
- $this->content->footer .= '<br />'.rss_get_link($this->page->context->id, $userid, 'forum', $forum->id, $tooltiptext);
+ $this->content->footer .= '<br />'.rss_get_link($this->page->context->id, $userid, 'mod_forum', $forum->id, $tooltiptext);
}
}
// Generate any blog RSS feed via one function (called by ../rss/file.php)
-function blog_generate_rss_feed($type, $id, $tagid=0) {
+function blog_rss_get_feed($type, $id, $tagid=0) {
global $CFG, $SITE, $DB;
if (empty($CFG->enablerssfeeds)) {
/// RSS and CSS and JS meta
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
- $rsspath = rss_get_url($context->id, $USER->id, 'data', $data->id);
+ $rsspath = rss_get_url($context->id, $USER->id, 'mod_data', $data->id);
$PAGE->add_alternate_version(format_string($course->shortname) . ': %fullname%',
$rsspath, 'application/rss+xml');
}
$rsslink = '';
if ($rss && $data->rssarticles > 0) {
- $rsslink = rss_get_link($context->id, $USER->id, 'data', $data->id, 'RSS');
+ $rsslink = rss_get_link($context->id, $USER->id, 'mod_data', $data->id, 'RSS');
}
if ($usesections) {
$string = get_string('rsstype','forum');
- $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'data', $data->id));
+ $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_data', $data->id));
$datanode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
}
}
//this links has been Settings (database activity administration) block
/*if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
echo '<div style="float:right;">';
- rss_print_link($context->id, $USER->id, 'data', $data->id, get_string('rsstype'));
+ rss_print_link($context->id, $USER->id, 'mod_data', $data->id, get_string('rsstype'));
echo '</div>';
echo '<div style="clear:both;"></div>';
}*/
$tooltiptext = get_string('rsssubscriberssposts', 'forum');
}
//Get html code for RSS link
- $row[] = rss_get_link($context->id, $USER->id, 'forum', $forum->id, $tooltiptext);
+ $row[] = rss_get_link($context->id, $USER->id, 'mod_forum', $forum->id, $tooltiptext);
} else {
$row[] = ' ';
}
$tooltiptext = get_string('rsssubscriberssposts', 'forum');
}
//Get html code for RSS link
- $row[] = rss_get_link($context->id, $USER->id, 'forum', $forum->id, $tooltiptext);
+ $row[] = rss_get_link($context->id, $USER->id, 'mod_forum', $forum->id, $tooltiptext);
} else {
$row[] = ' ';
}
} else {
$userid = $USER->id;
}
- $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $userid, "forum", $forumobject->id));
+ $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $userid, "mod_forum", $forumobject->id));
$forumnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
}
}
$userid = $USER->id;
}
//Get html code for RSS link
- $rsslink = rss_get_link($context->id, $userid, "glossary", $glossary->id, $tooltiptext);
+ $rsslink = rss_get_link($context->id, $userid, 'mod_glossary', $glossary->id, $tooltiptext);
}
}
$string = get_string('rsstype','forum');
- $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'glossary', $glossary->id));
+ $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_glossary', $glossary->id));
$glossarynode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
}
}
$contextid = (int)$args[0];
$token = $args[1];
-$modulename = clean_param($args[2], PARAM_FILE);
+$componentname = clean_param($args[2], PARAM_FILE);
$instance = $args[3];
$userid = rss_get_userid_from_token($token);
$coursecontext = get_course_context($context);
$course = $DB->get_record('course', array('id' => $coursecontext->instanceid), '*', MUST_EXIST);
+//this will store the path to the cached rss feed contents
$pathname = null;
-switch ($modulename) {
- case 'blog':
- $blogid = (int) $args[4]; // could be groupid / courseid / userid depending on $instance
- if ($args[5] != 'rss.xml') {
- $tagid = (int) $args[5];
+$componentdir = get_component_directory($componentname);
+list($type, $plugin) = normalize_component($componentname);
+
+if (file_exists($componentdir)) {
+ require_once("$componentdir/rsslib.php");
+ $functionname = $plugin.'_rss_get_feed';
+
+ if (function_exists($functionname)) {
+
+ if ($componentname=='blog') {
+
+ $blogid = (int) $args[4]; // could be groupid / courseid / userid depending on $instance
+ if ($args[5] != 'rss.xml') {
+ $tagid = (int) $args[5];
+ } else {
+ $tagid = 0;
+ }
+
+ try {
+ require_login($course, false, NULL, false, true);
+ } catch (Exception $e) {
+ rss_not_found();
+ }
+ $pathname = $functionname($instance, $blogid, $tagid);
+ } else if ($componentname=='local_hub') {
+
+ $pathname = $functionname($args);
} else {
- $tagid = 0;
- }
-
- try {
- require_login($course, false, NULL, false, true);
- } catch (Exception $e) {
- rss_not_found();
- }
- //Work out the filename of the cached RSS file
- require_once($CFG->dirroot . '/blog/rsslib.php');
- $pathname = blog_generate_rss_feed($instance, $blogid, $tagid);
- break;
-
- case 'local_hub': //Note: I made this case generic for a probable futur refactor.
- // rss/file.php should not handle individual cases.
- //Here $modulename contain the folder path with '_' instead of '/'
-
- //Work out the filename of the cached RSS file
- $functionname = $modulename . '_rss_get_feed';
- $modulepath = str_replace('_', '/', $modulename);
- require_once($CFG->dirroot . '/' . $modulepath . '/rsslib.php');
- if (function_exists($functionname)) {
- $pathname = $functionname($args); //All the xxx_rss_get_feed() could manage
- // eveything with only $args parameter.
- }
- break;
+ $instance = (int)$instance;
- default:
- $instance = (int) $instance;
-
- $mods = get_plugin_list('mod');
- $mods = array_keys($mods);
- if (!in_array(strtolower($modulename), $mods)) {
- rss_not_found();
- }
- try {
- $cm = get_coursemodule_from_instance($modulename, $instance, 0, false, MUST_EXIST);
- require_login($course, false, $cm, false, true);
- } catch (Exception $e) {
- rss_not_found();
- }
+ try {
+ $cm = get_coursemodule_from_instance($plugin, $instance, 0, false, MUST_EXIST);
+ require_login($course, false, $cm, false, true);
+ } catch (Exception $e) {
+ rss_not_found();
+ }
- //Work out the filename of the cached RSS file
- $functionname = $cm->modname . '_rss_get_feed';
- require_once($CFG->dirroot . "/mod/{$cm->modname}/rsslib.php");
- if (function_exists($functionname)) {
$pathname = $functionname($context, $cm, $instance, $args);
}
- break;
+ }
}
//Check that file exists