diff --git a/blocks/recent_activity/block_recent_activity.php b/blocks/recent_activity/block_recent_activity.php
index 4e326ff..5a73b64 100644
--- a/blocks/recent_activity/block_recent_activity.php
+++ b/blocks/recent_activity/block_recent_activity.php
@@ -1,4 +1,5 @@
 <?PHP //$Id$
+require_once($CFG->libdir."/rsslib.php");
 
 class block_recent_activity extends block_base {
     function init() {
@@ -6,8 +7,12 @@ class block_recent_activity extends block_base {
         $this->version = 2007101509;
     }
 
+    function instance_allow_config() {
+        return true;
+    }
+
     function get_content() {
-        global $COURSE;
+        global $COURSE, $CFG, $USER;
 
         if ($this->content !== NULL) {
             return $this->content;
@@ -22,6 +27,11 @@ class block_recent_activity extends block_base {
         $this->content->text = '';
         $this->content->footer = '';
 
+        /// If rss are activated at site and this recent activity has rss defined, show link
+        if (isset($this->config->enablerssfeeds) && isset($CFG->enablerssfeeds) && $this->config->enablerssfeeds && $CFG->enablerssfeeds) {
+            $tooltiptext = get_string("rssfeedtooltip", "block_recent_activity");
+            $this->content->footer = "<span class='wrap rsslink'>" . rss_get_link($COURSE->id, $USER->id, "recent_activity", $this->instance->id, $tooltiptext) . "</span>";
+        }
         // Slightly hacky way to do it but...
         ob_start();
         print_recent_activity($COURSE);
diff --git a/blocks/recent_activity/config_instance.html b/blocks/recent_activity/config_instance.html
new file mode 100644
index 0000000..cb7131f
--- /dev/null
+++ b/blocks/recent_activity/config_instance.html
@@ -0,0 +1,13 @@
+<table cellpadding="9" cellspacing="0">
+<tr valign="top">
+<td align="center"><?php print_string("enablerssfeeds","block_recent_activity") ?>:</td>
+<td>
+<input type="hidden" name="enablerssfeeds" value="0" />
+<input type="checkbox" name="enablerssfeeds" value="1" <?php if(!empty($this->config->enablerssfeeds)) echo 'checked="checked"'; ?> />
+</td>
+</tr> 
+<tr>
+    <td colspan="3" align="center">
+    <input type="submit" value="<?php print_string('savechanges') ?>" /></td>
+</tr>
+</table>
diff --git a/blocks/recent_activity/lang/en_utf8/block_recent_activity.php b/blocks/recent_activity/lang/en_utf8/block_recent_activity.php
new file mode 100644
index 0000000..ac45aae
--- /dev/null
+++ b/blocks/recent_activity/lang/en_utf8/block_recent_activity.php
@@ -0,0 +1,9 @@
+<?php // $Id$ 
+      // block_recent_activity.php
+
+
+$string['enablerssfeeds'] = 'enablerssfeeds';
+$string['configenablerssfeeds'] = 'configenablerssfeeds';
+$string['blockname'] = 'Recent Activity';
+$string['rssfeedtooltip'] = 'Subscribe to Recent Activity RSS feed for this course';
+?>
diff --git a/blocks/recent_activity/rsslib.php b/blocks/recent_activity/rsslib.php
new file mode 100644
index 0000000..d5076fa
--- /dev/null
+++ b/blocks/recent_activity/rsslib.php
@@ -0,0 +1,91 @@
+<?php
+
+    require_once($CFG->libdir.'/rsslib.php');
+
+    function recent_activity_generate_rss_feed($instance, $courseid, $userid) {
+        global $CFG, $SITE;
+
+        if (empty($CFG->enablerssfeeds)) {
+            debugging('Sorry, RSS feeds are disabled on this site');
+            return '';
+        }
+
+        if ($instance) {
+            if ($block = get_record('block','id',$instance->blockid)) {
+                $filename = recent_activity_rss_file_name($instance->id,$userid,$courseid);
+            }
+        }
+        
+        if (!$course = get_record('course', 'id', $courseid)) {
+            debugging("couldn't find course with id $courseid");
+            return '';
+        }
+
+        if (!$user = get_record('user', 'id', $userid)) {
+            debugging("invalid user id");
+            return  '';
+        }
+
+        $filename = recent_activity_rss_file_name($instance->id,$userid,$courseid);
+
+        // check the file hasn't recently been created
+        if (file_exists($filename)) {
+            if (filemtime($filename) + 300 > time()) { // 5 minutes
+                return $filename;   /// It's already done so we return cached version
+            }
+        }
+
+        $user->lastcourseaccess = array();
+         if ($lastaccesses = get_records('user_lastaccess', 'userid', $user->id)) {
+            foreach ($lastaccesses as $lastaccess) {
+                $user->lastcourseaccess[$lastaccess->courseid] = $lastaccess->timeaccess;
+            }
+        }
+
+        if ($content = rss_recent_activity($course, $user)) {
+            $articles = rss_add_items($content);   /// Change structure to XML
+        } else {
+            $articles = '';
+        }
+
+        $header = rss_standard_header();
+        $footer = rss_standard_footer();
+
+    /// Save the XML contents to file.
+
+        $rssdata = $header.$articles.$footer;
+
+        if (recent_activity_rss_save_file($instance->id,$userid,$courseid,$rssdata)) {
+            return $filename;
+        } else {
+            return false;   // Couldn't find it or make it
+        }
+    }
+
+    function recent_activity_rss_file_name($id, $userid, $courseid) {
+        global $CFG;
+
+        return "$CFG->dataroot/rss/$courseid/$userid/recent_activity/$id/rss.xml";
+    }
+
+    //This function saves to file the rss feed specified in the parameters
+    function recent_activity_rss_save_file($id, $userid, $courseid, $contents='') {
+        global $CFG;
+
+        if (! $basedir = make_upload_directory("/rss/$courseid/$userid/recent_activity/$id")) {
+            return false;
+        }
+
+        $file = recent_activity_rss_file_name($id, $userid, $courseid);
+        $rss_file = fopen($file, 'w');
+        if ($rss_file) {
+            $status = fwrite ($rss_file, $contents);
+            fclose($rss_file);
+        } else {
+            $status = false;
+        }
+
+        return $status;
+    }
+
+?>
diff --git a/course/lib.php b/course/lib.php
index 46a945d..19b2221 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -839,7 +839,7 @@ function print_recent_activity($course) {
 
     $timestart = round(time() - COURSE_MAX_RECENT_PERIOD, -2); // better db caching for guests - 100 seconds
 
-    if (!has_capability('moodle/legacy:guest', $context, NULL, false)) {
+    if (!has_capability('moodle/legacy:guest', $context, $USER->id, false)) {
         if (!empty($USER->lastcourseaccess[$course->id])) {
             if ($USER->lastcourseaccess[$course->id] > $timestart) {
                 $timestart = $USER->lastcourseaccess[$course->id];
@@ -858,21 +858,85 @@ function print_recent_activity($course) {
 
     $content = false;
 
+    // get the recent activity, parse and display it
+    if ($activity = get_recent_activity($course, $timestart)) {
+        $content = true;
+
+        if ($newusers = $activity['newusers']) {
+            echo '<div class="newusers">';
+                print_headline(get_string("newusers").':', 3);
+                $content = true;
+                echo "<ol class=\"list\">\n";
+                foreach ($users as $usr) {
+                    $fullname = fullname($usr, $viewfullnames);
+                    echo '<li class="name"><a href="'."$CFG->wwwroot/user/view.php?id=$usr->id&amp;course=$course->id\">$fullname</a></li>\n";
+                }
+            echo "</ol>\n</div>\n";
+        }
+
+        if ($courseupdates = $activity['courseupdates']) {
+            print_headline(get_string('courseupdates').':',3);
+            $content = true;
+            foreach ($courseupdates as $update) {
+            echo '<p class="activity">'.$update->title.'<br /><a href=\''.$update->link.'\'>'.$update->description.'</a></p>';
+            }
+        }
+    }
+
+/// Now display new things from each module
+
+    $modinfo =& get_fast_modinfo($course);
+    $usedmodules = array();
+    foreach($modinfo->cms as $cm) {
+        if (isset($usedmodules[$cm->modname])) {
+            continue;
+        }
+        if (!$cm->uservisible) {
+            continue;
+        }
+        $usedmodules[$cm->modname] = $cm->modname;
+    }
+
+    foreach ($usedmodules as $modname) {      // Each module gets it's own logs and prints them
+        if (file_exists($CFG->dirroot.'/mod/'.$modname.'/lib.php')) {
+            include_once($CFG->dirroot.'/mod/'.$modname.'/lib.php');
+            $print_recent_activity = $modname.'_print_recent_activity';
+            if (function_exists($print_recent_activity)) {
+                // NOTE: original $isteacher (second parameter below) was replaced with $viewfullnames!
+                $content = $print_recent_activity($course, $viewfullnames, $timestart) || $content;
+            }
+        } else {
+            debugging("Missing lib.php in lib/{$modname} - please reinstall files or uninstall the module");
+        }
+    }
+
+    if (! $content) {
+        echo '<p class="message">'.get_string('nothingnew').'</p>';
+    }
+}
+
+/*
+ * This function returns an array of items for the recent_activity that can be parsed into html or xml format in either
+ * rss_recent_activity or print_recent_activity
+ *
+ * @param $course
+ * @param $timestart
+ * @return array
+ */
+function get_recent_activity($course, $timestart) {
+    global $CFG;
+
+    $activity = array();
+
 /// Firstly, have there been any new enrolments?
 
     $users = get_recent_enrolments($course->id, $timestart);
 
-    //Accessibility: new users now appear in an <OL> list.
     if ($users) {
-        echo '<div class="newusers">';
-        print_headline(get_string("newusers").':', 3);
-        $content = true;
-        echo "<ol class=\"list\">\n";
-        foreach ($users as $user) {
-            $fullname = fullname($user, $viewfullnames);
-            echo '<li class="name"><a href="'."$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">$fullname</a></li>\n";
+        $activity['newusers'] = array();
+        foreach ($users as $usr) {
+            $activity['newusers'][] = $usr;
         }
-        echo "</ol>\n</div>\n";
     }
 
 /// Next, have there been any modifications to the course structure?
@@ -926,54 +990,106 @@ function print_recent_activity($course) {
                     continue;
                 }
 
-                if ($log->action == 'add mod') {
-                    $stradded = get_string('added', 'moodle', get_string('modulename', $modname));
-                    $changelist[$log->info] = array('operation' => 'add', 'text' => "$stradded:<br /><a href=\"$CFG->wwwroot/mod/$cm->modname/view.php?id={$cm->id}\">".format_string($cm->name, true)."</a>");
+               if ($log->action == 'add mod') {
+                    $changelist[$log->info]->operation = 'add';
+                    $changelist[$log->info]->category = get_string('courseupdates');
+                    $changelist[$log->info]->title = get_string('added', 'moodle', get_string('modulename', $modname));
+                    $changelist[$log->info]->link = $CFG->wwwroot.'/mod/'.$cm->modname.'/view.php?id='.$cm->id;
+                    $changelist[$log->info]->description = format_string($cm->name, true);
+                    $changelist[$log->info]->pubdate = $log->time;
 
                 } else if ($log->action == 'update mod' and empty($changelist[$log->info])) {
-                    $strupdated = get_string('updated', 'moodle', get_string('modulename', $modname));
-                    $changelist[$log->info] = array('operation' => 'update', 'text' => "$strupdated:<br /><a href=\"$CFG->wwwroot/mod/$cm->modname/view.php?id={$cm->id}\">".format_string($cm->name, true)."</a>");
+                    $changelist[$log->info]->operation = 'update';
+                    $changelist[$log->info]->category = get_string('courseupdates');
+                    $changelist[$log->info]->title = get_string('updated', 'moodle', get_string('modulename', $modname));
+                    $changelist[$log->info]->link = $CFG->wwwroot.'/mod/'.$cm->modname.'/view.php?id='.$cm->id;
+                    $changelist[$log->info]->description = format_string($cm->name, true);
+                    $changelist[$log->info]->pubdate = $log->time;
                 }
             }
         }
     }
 
     if (!empty($changelist)) {
-        print_headline(get_string('courseupdates').':', 3);
-        $content = true;
-        foreach ($changelist as $changeinfo => $change) {
-            echo '<p class="activity">'.$change['text'].'</p>';
+        $activity['courseupdates'] = array();
+        foreach ($changelist as $change) {
+            $activity['courseupdates'][] = $change;
         }
     }
 
-/// Now display new things from each module
+    if (!empty($activity)) {
+        return $activity;
+    } else {
+        return array();
+    }
+}
 
-    $usedmodules = array();
-    foreach($modinfo->cms as $cm) {
-        if (isset($usedmodules[$cm->modname])) {
-            continue;
-        }
-        if (!$cm->uservisible) {
-            continue;
-        }
-        $usedmodules[$cm->modname] = $cm->modname;
+/*
+ * get the recent activity in appropriate format to generate an rss feed
+ * @param $course
+ * @param $user
+ * @return array
+*/
+function rss_recent_activity($course, $user) {
+    global $CFG;
+
+    if (!$user) {
+        debugging("Error: no user supplied");
+        return;
     }
 
-    foreach ($usedmodules as $modname) {      // Each module gets it's own logs and prints them
-        if (file_exists($CFG->dirroot.'/mod/'.$modname.'/lib.php')) {
-            include_once($CFG->dirroot.'/mod/'.$modname.'/lib.php');
-            $print_recent_activity = $modname.'_print_recent_activity';
-            if (function_exists($print_recent_activity)) {
-                // NOTE: original $isteacher (second parameter below) was replaced with $viewfullnames!
-                $content = $print_recent_activity($course, $viewfullnames, $timestart) || $content;
+    $context = get_context_instance(CONTEXT_COURSE, $course->id);
+
+    $viewfullnames = has_capability('moodle/site:viewfullnames', $context);
+
+    $timestart = round(time() - COURSE_MAX_RECENT_PERIOD, -2); // better db caching for guests - 100 seconds
+
+    if (!has_capability('moodle/legacy:guest', $context, $user->id, false)) {
+        if (!empty($user->lastcourseaccess[$course->id])) {
+            if ($user->lastcourseaccess[$course->id] > $timestart) {
+                $timestart = $user->lastcourseaccess[$course->id];
             }
-        } else {
-            debugging("Missing lib.php in lib/{$modname} - please reinstall files or uninstall the module");
         }
     }
 
-    if (! $content) {
-        echo '<p class="message">'.get_string('nothingnew').'</p>';
+    $courseshortname = '';
+    $coursefullname = '';
+    if ($course = get_record('course','id', $course->id)) {
+        $courseshortname = $course->shortname.": ";
+        $coursefullname = $course->fullname."<br /><br />";
+    }
+
+    // get the recent activity
+    $activity = get_recent_activity($course, $timestart);
+    if (!empty($activity)) {
+        if ($courseupdates = $activity['courseupdates']) {
+            foreach ($courseupdates as $value) {
+                $item = NULL;
+                $item->category = $value->category;
+                $item->author = NULL;
+                $item->title = $courseshortname . $value->title;
+                $item->pubdate = $value->pubdate;
+                $item->link = $value->link;
+                $item->description = $coursefullname . $value->description;
+                $items[] = $item;
+            }
+        }
+
+        if ($newusers = $activity['newusers']) {
+            foreach ($newusers as $usr) {
+                $item = NULL;
+                $item->category = get_string('newusers');
+                $item->author = NULL;
+                $item->title = get_string('newusers');
+                $item->pubdate = NULL;
+                $item->link = $CFG->wwwroot.'/user/view.php?id='.$usr->id.'&amp;course='.$course->id;
+                $item->description = fullname($usr, $viewfullnames);
+                $items[] = $item;
+            }
+        }
+        return $items;
+    } else {
+        return '';
     }
 }
 
diff --git a/rss/file.php b/rss/file.php
index 330f53b..0a0b519 100644
--- a/rss/file.php
+++ b/rss/file.php
@@ -18,6 +18,7 @@
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
     require_once($CFG->libdir.'/rsslib.php');
+    require_once($CFG->libdir.'/blocklib.php');
 
     $lifetime = 3600;  // Seconds for files to remain in caches - 1 hour
 
@@ -68,14 +69,21 @@
     //Check name of module
     if (!$isblog) {
         $mods = get_list_of_plugins('mod');
-        if (!in_array(strtolower($modulename), $mods)) {
+        $blocks = get_list_of_plugins('blocks');
+        if (!in_array(strtolower($modulename), $mods) and !in_array(strtolower($modulename), $blocks)) {
             rss_not_found();
         }
+        $blockinstance = get_record('block_instance','pageid',$course->id,'id',$instance);
+        $cm = get_coursemodule_from_instance($modulename,$instance,$courseid);
         //Get course_module to check it's visible
-        if (!$cm = get_coursemodule_from_instance($modulename,$instance,$courseid)) {
+        if (!$cm and !$blockinstance) {
             rss_not_found();
         }
-        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+        if ($cm) {
+            $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+        } else if ($blockinstance) {
+            $context = get_context_instance(CONTEXT_BLOCK, $blockinstance->id);
+        }
         $isuser = has_capability('moodle/course:view', $context, $userid);   // Not ideal, this should be module-specific, but deferring until RSS gets a revamp with codes in the URLs
     } else {
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -90,7 +98,7 @@
     }
 
     //Do not allow acesss to hidden courses or activities because we can not trust user id - this will be improved in 2.0
-    if (!$isblog and (!$course->visible || !$cm->visible)) {
+    if (!$isblog and (!$course->visible || !$cm->visible) and (!$course->visible || !$blockinstance->visible)) {
         rss_not_found();
     }
 
@@ -98,6 +106,12 @@
     if ($isblog) {
         require_once($CFG->dirroot.'/blog/rsslib.php');
         $pathname = blog_generate_rss_feed($instance, $blogid, $tagid);
+    } else if (!empty($blockinstance) and $blockinstance->visible) {
+        require_once("$CFG->dirroot/blocks/$modulename/rsslib.php");
+        $functionname = $modulename.'_generate_rss_feed';
+        if (function_exists($functionname)) {
+            $pathname = $functionname($blockinstance, $course->id, $userid);
+        }
     } else {
         $pathname = $CFG->dataroot.'/rss/'.$modulename.'/'.$instance.'.xml';
     }

