RSS 2.0

Jump to: navigation, search

Moodle 2.0

Objectives

The goals of RSS 2.0:

  • Provide the means to secure RSS feeds
  • Present users with different versions of the same feed depending on their permissions
  • Generate RSS feeds only when they are required
  • Ensure RSS feeds contain data that is as up to date as possible.

Overview

RSS feeds are currently available within the forum, data and glossary activities. Other areas of Moodle may make RSS feeds available in future. The RSS system must provide the capacity to present secure and user specific feeds to the user.

Tracker Issues

MDL-22413 Write documentation describing Moodle 2.0 RSS feeds

MDL-22204 Secure RSS feeds using web tokens

Interface

RSS feeds are detectable by the user in two ways:

  • The module can present an onscreen link to the RSS feed.

RSS1.gif

  • The browser should aut-detect the RSS feed. This is done by inserting a header into the html document.

<link href="http://www.example.com/some.rss" rel="alternate" type="application/rss+xml" title="TITLE OF YOUR RSS FEED" />

When an RSS feed is detected most browsers will insert an RSS icon in the browser address bar.

URL structure

The structure of the RSS feed URLs varies depending on whether the RSS is being provided by a blog or activity module.

Modules

The URL structure is rss/file.php/%contextid%/%usertoken%/%modulename%/%moduleinstanceid%/rss.xml

For example: example.com/rss/file.php/18/2001080bd2a70b148338e61ab60dc65e/forum/1/rss.xml

Note that any number of parameters can be supplied. For example: For example: example.com/rss/file.php/18/2001080bd2a70b148338e61ab60dc65e/forum/1/a/b/c/d/rss.xml

Blogs

Blog RSS feeds have several URL formats.

The URL structure is rss/file.php/%contextid%/%usertoken%/blog/%moduleinstanceid%/%groupid|courseid|userid%/rss.xml

For example: example.com/rss/file.php/24/2001080bd2a70b148338e61ab60dc65e/blog/2/12/rss.xml


To reference a specific tag the URL structure is rss/file.php/%contextid%/%usertoken%/blog/%moduleinstanceid%/%groupid|courseid|userid%/%tagid%/rss.xml

For example: example.com/rss/file.php/24/2001080bd2a70b148338e61ab60dc65e/blog/2/12/4/rss.xml

RSS Caching

RSS feeds are cached at $CFG->dataroot/rss/$modname/$filename.xml

For example "moodledata/moodle/rss/forum/1_515fc92d53039eabee0a44301ca23531.xml"

The filename format is the module instance id, an underscore then the hash of the SQL used to retrieve the data for the feed. The SQL should contain anything that leads to different users seeing different data in the feed. For example the SQL for the forum RSS feeds may contain groups conditions so that one file will be created in the cache for each group.

The SQL should NOT contain the user id as this would cause on file to be created for each user. The user id should be supplied as a parameter to the query but not appear within the query itself.

The cache file naming convention allows all cached feeds for a particular forum instance, for example, to be removed.

Module Support

When /rss/file.php receives a request for an RSS feed it will look for a function within the blog/module to produce the feed.

For blogs this function will be called.

blog_generate_rss_feed($instance, $blogid, $tagid);

For modules the file at "/mod/%modname%/rsslib.php" will be included and the function named %modname%_rss_get_feed will be called. For example:

forum_rss_get_feed($context, $cm, $instance, $args);

This function should return the path to the cached RSS feed. file.php will then read the file and return the contents to the client. The blog/module is responsible for creating the file in the cache.