mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
rss MDL-23391 alter the rss urls to be component names ie mod_forum instead of just module name ie forum
This commit is contained in:
parent
44c0751bbf
commit
aa60291e12
@ -106,7 +106,7 @@ class block_news_items extends block_base {
|
||||
} 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ function blog_rss_print_link($filtertype, $filterselect, $tagid=0, $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)) {
|
||||
|
@ -106,7 +106,7 @@ if ($cancel) {
|
||||
|
||||
/// 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');
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ foreach ($datas as $data) {
|
||||
|
||||
$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) {
|
||||
|
@ -2874,7 +2874,7 @@ function data_extend_settings_navigation(settings_navigation $settings, navigati
|
||||
|
||||
$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', ''));
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +317,7 @@
|
||||
//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>';
|
||||
}*/
|
||||
|
@ -258,7 +258,7 @@ if ($generalforums) {
|
||||
$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[] = ' ';
|
||||
}
|
||||
@ -388,7 +388,7 @@ if ($course->id != SITEID) { // Only real courses have learning forums
|
||||
$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[] = ' ';
|
||||
}
|
||||
|
@ -7520,7 +7520,7 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
|
||||
} 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', ''));
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ foreach ($glossarys as $glossary) {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2603,7 +2603,7 @@ function glossary_extend_settings_navigation(settings_navigation $settings, navi
|
||||
|
||||
$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', ''));
|
||||
}
|
||||
}
|
||||
|
88
rss/file.php
88
rss/file.php
@ -48,7 +48,7 @@ if (count($args) < 5) {
|
||||
|
||||
$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);
|
||||
@ -71,64 +71,50 @@ $PAGE->set_context($context);
|
||||
$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();
|
||||
}
|
||||
$instance = (int)$instance;
|
||||
|
||||
//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;
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
//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
|
||||
|
Loading…
x
Reference in New Issue
Block a user