// Generate any blog RSS feed via one function (called by ../rss/file.php)
-function blog_rss_get_feed($context, $cm, $instance, $args) {
+function blog_rss_get_feed($context, $args) {
global $CFG, $SITE, $DB;
- $type = $instance;
+ if (empty($CFG->enablerssfeeds)) {
+ debugging('Sorry, RSS feeds are disabled on this site');
+ return '';
+ }
+
+ $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+ if (!has_capability('moodle/blog:view', $sitecontext)) {
+ return null;
+ }
+ $type = $args[3];
$id = (int) $args[4]; // could be groupid / courseid / userid depending on $instance
$tagid=0;
$tagid = 0;
}
- if (empty($CFG->enablerssfeeds)) {
- debugging('Sorry, RSS feeds are disabled on this site');
- return '';
- }
-
$filename = blog_rss_file_name($type, $id, $tagid);
if (file_exists($filename)) {
// This function is the main entry point to database module
// rss feeds generation.
- function data_rss_get_feed($context, $cm, $instance, $args) {
+ function data_rss_get_feed($context, $args) {
global $CFG, $DB;
// Check CFG->data_enablerssfeeds.
return null;
}
- //check capabilities
- if (!has_capability('mod/data:managetemplates', $context)) {
+ if (!is_enrolled($context, null, 'mod/data:managetemplates')) {
return null;
}
- $data = $DB->get_record('data', array('id' => $instance), '*', MUST_EXIST);
+ $dataid = $args[3];
+ $data = $DB->get_record('data', array('id' => $dataid), '*', MUST_EXIST);
if (!rss_enabled('data', $data, false, true)) {
return null;
}
- $sql = data_rss_get_sql($data, $cm);
+ $sql = data_rss_get_sql($data);
//get the cache file info
$filename = rss_get_file_name($data, $sql);
$cachedfilelastmodified = filemtime($cachedfilepath);
}
- if (data_rss_newstuff($data, $cm, $cachedfilelastmodified)) {
+ if (data_rss_newstuff($data, $cachedfilelastmodified)) {
require_once($CFG->dirroot . '/mod/data/lib.php');
// Get the first field in the list (a hack for now until we have a selector)
return $cachedfilepath;
}
- function data_rss_get_sql($data, $cm, $time=0) {
+ function data_rss_get_sql($data, $time=0) {
//do we only want new posts?
if ($time) {
$time = " AND dr.timemodified > '$time'";
* Otherwise it returns false.
*
* @param object $data the data activity object
- * @param object $cm
* @param int $time timestamp
* @return bool
*/
- function data_rss_newstuff($data, $cm, $time) {
+ function data_rss_newstuff($data, $time) {
global $DB;
- $sql = data_rss_get_sql($data, $cm, $time);
+ $sql = data_rss_get_sql($data, $time);
$recs = $DB->get_records_sql($sql, null, 0, 1);//limit of 1. If we get even 1 back we have new stuff
return ($recs && !empty($recs));
* @param array $args the arguments received in the url
* @return string the full path to the cached RSS feed directory. Null if there is a problem.
*/
-function forum_rss_get_feed($context, $cm, $forumid, $args) {
+function forum_rss_get_feed($context, $args) {
global $CFG, $DB;
$status = true;
return null;
}
- //check capabilities
- if (!has_capability('mod/forum:viewdiscussion', $context)) {
+ if (!is_enrolled($context, null, 'mod/forum:viewdiscussion')) {
return null;
}
+ $forumid = $args[3];
$forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST);
if (!rss_enabled('forum', $forum)) {
return null;
}
+ $cm = get_coursemodule_from_instance('forum', $forumid, 0, false, MUST_EXIST);
+
//the sql that will retreive the data for the feed and be hashed to get the cache filename
$sql = forum_rss_get_sql($forum, $cm);
$glossary = $DB->get_record('glossary', array("id" => $PAGE->cm->instance));
- if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds)
- && $glossary->rsstype && $glossary->rssarticles) {
+ if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype && $glossary->rssarticles) {
require_once("$CFG->libdir/rsslib.php");
$string = get_string('rsstype','forum');
//This function is the main entry point to glossary
//rss feeds generation.
- function glossary_rss_get_feed($context, $cm, $instance, $args) {
+ function glossary_rss_get_feed($context, $args) {
global $CFG, $DB;
if (empty($CFG->glossary_enablerssfeeds)) {
//check capabilities
//glossary module doesn't require any capabilities to view glossary entries (aside from being logged in)
+ if (!is_enrolled($context)) {
+ return null;
+ }
- $glossary = $DB->get_record('glossary', array('id' => $instance), '*', MUST_EXIST);
+ $glossaryid = $args[3];
+ $glossary = $DB->get_record('glossary', array('id' => $glossaryid), '*', MUST_EXIST);
if (!rss_enabled('glossary', $glossary)) {
return null;
}
- $sql = glossary_rss_get_sql($glossary, $cm);
+ $sql = glossary_rss_get_sql($glossary);
//get the cache file info
$filename = rss_get_file_name($glossary, $sql);
$cachedfilelastmodified = filemtime($cachedfilepath);
}
- if (glossary_rss_newstuff($glossary, $cm, $cachedfilelastmodified)) {
+ if (glossary_rss_newstuff($glossary, $cachedfilelastmodified)) {
if (!$recs = $DB->get_records_sql($sql, array(), 0, $glossary->rssarticles)) {
return null;
}
return $cachedfilepath;
}
- function glossary_rss_get_sql($glossary, $cm, $time=0) {
+ function glossary_rss_get_sql($glossary, $time=0) {
//do we only want new items?
if ($time) {
$time = "AND e.timecreated > $time";
* Otherwise it returns false.
*
* @param object $glossary the glossary activity object
- * @param object $cm
* @param int $time timestamp
* @return bool
*/
- function glossary_rss_newstuff($glossary, $cm, $time) {
+ function glossary_rss_newstuff($glossary, $time) {
global $DB;
- $sql = glossary_rss_get_sql($glossary, $cm, $time);
+ $sql = glossary_rss_get_sql($glossary, $time);
$recs = $DB->get_records_sql($sql, null, 0, 1);//limit of 1. If we get even 1 back we have new stuff
return ($recs && !empty($recs));
$contextid = (int)$args[0];
$token = $args[1];
$componentname = clean_param($args[2], PARAM_FILE);
-$instance = $args[3];
+//$instance = $args[3];
$userid = rss_get_userid_from_token($token);
if (!$userid) {
//this will store the path to the cached rss feed contents
$pathname = null;
-//check user's psuedo login created by session_set_user()
-//NOTE the component providing the feed should do its own capability checks
-try {
- $cm = null;
- if (!empty($plugin) && !empty($instance)) {
- $cm = get_coursemodule_from_instance($plugin, $instance, 0, false, MUST_EXIST);
- }
-
- //Get course from context
- //TODO: note that in the case of the hub rss feed, the feed is not related to a course context,
- //it is more a "site" context. The Hub RSS bypass the following line using context id = 2
- $coursecontext = get_course_context($context);
-
- $course = null;
- if ($coursecontext) {
- $course = $DB->get_record('course', array('id' => $coursecontext->instanceid), '*', MUST_EXIST);
- }
-
- require_login($course, false, $cm, false, true);
-} catch (Exception $e) {
- rss_not_found();
-}
-
if (file_exists($componentdir)) {
require_once("$componentdir/rsslib.php");
$functionname = $plugin.'_rss_get_feed';
if (function_exists($functionname)) {
//$pathname will be null if there was a problem or the user doesn't have the necessary capabilities
- $pathname = $functionname($context, $cm, $instance, $args);
+ //NOTE the component providing the feed should do its own capability checks
+ $pathname = $functionname($context, $args);
}
}