Skip to content

Commit

Permalink
rss MDL-23391 alter the rss urls to be component names ie mod_forum i…
Browse files Browse the repository at this point in the history
…nstead of just module name ie forum
  • Loading branch information
Andrew Davis committed Jul 19, 2010
1 parent 44c0751 commit aa60291
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 62 deletions.
2 changes: 1 addition & 1 deletion blocks/news_items/block_news_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function get_content() {
} 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);
}

}
Expand Down
2 changes: 1 addition & 1 deletion blog/rsslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion mod/data/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

/// 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');
}
Expand Down
2 changes: 1 addition & 1 deletion mod/data/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

$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) {
Expand Down
2 changes: 1 addition & 1 deletion mod/data/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''));
}
}
2 changes: 1 addition & 1 deletion mod/data/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
}*/
Expand Down
4 changes: 2 additions & 2 deletions mod/forum/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
$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[] = '&nbsp;';
}
Expand Down Expand Up @@ -388,7 +388,7 @@
$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[] = '&nbsp;';
}
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''));
}
}
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
$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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 37 additions & 51 deletions rss/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

$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);
Expand All @@ -71,64 +71,50 @@
$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
Expand Down

0 comments on commit aa60291

Please sign in to comment.