diff --git a/admin/settings/subsystems.php b/admin/settings/subsystems.php
index ceccfe5..a7ea04a 100644
--- a/admin/settings/subsystems.php
+++ b/admin/settings/subsystems.php
@@ -24,6 +24,11 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
 
     $optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', get_string('enablerssfeeds', 'admin'), get_string('configenablerssfeeds', 'admin'), 0));
 
+    $countoptions = array(0=>get_string('none'))+
+        (array_combine(range(1, 50),//keys
+                       range(1, 50)));//values
+    $optionalsubsystems->add(new admin_setting_configselect('rsscomments', get_string('rsscomments', 'admin'), get_string('configrsscomments', 'admin'), 0, $countoptions));
+
     $optionalsubsystems->add(new admin_setting_bloglevel('bloglevel', get_string('bloglevel', 'admin'),
                                 get_string('configbloglevel', 'admin'), 4, array(5 => get_string('worldblogs','blog'),
                                                                                  4 => get_string('siteblogs','blog'),
diff --git a/comment/comment.js b/comment/comment.js
index 604a939..9dfe3b5 100644
--- a/comment/comment.js
+++ b/comment/comment.js
@@ -41,6 +41,7 @@ M.core_comment = {
                 this.courseid = args.courseid;
                 this.contextid = args.contextid;
                 this.env = args.env;
+		this.highlightcomment = args.highlightcomment;
                 // expand comments?
                 if (args.autostart) {
                     this.view(args.page);
@@ -188,7 +189,12 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
                     val = val.replace('___time___', list[i].time);
                     val = val.replace('___picture___', list[i].avatar);
                     val = val.replace('___content___', list[i].content);
-                    val = '<li id="'+htmlid+'">'+val+'</li>';
+		    var style = '';
+		    if (list[i].id == this.highlightcomment) {
+			style = ' style="background-color: #FFE390;" ';
+			this.highlightcomment = 0;
+		    }
+                    val = '<li id="'+htmlid+'"'+style+'>'+val+'</li>';
                     ret.ids.push(htmlid);
                     html = (val+html);
                 }
diff --git a/comment/lib.php b/comment/lib.php
index d8bbc49..4a44327 100644
--- a/comment/lib.php
+++ b/comment/lib.php
@@ -87,6 +87,9 @@ class comment {
     private static $comment_area = null;
     private static $comment_page = null;
     private static $comment_component = null;
+
+    // static variable to highlight a specific comment on a page
+    private static $showcomment = false;
     /**
      * Construct function of comment class, initialise
      * class members
@@ -221,6 +224,7 @@ EOD;
         self::$comment_context = optional_param('comment_context', '', PARAM_INT);
         self::$comment_page    = optional_param('comment_page',    '', PARAM_INT);
         self::$comment_area    = optional_param('comment_area',    '', PARAM_ALPHAEXT);
+        self::$showcomment     = optional_param('showcomment',  false, PARAM_INT);
 
         $PAGE->requires->string_for_js('addcomment', 'moodle');
         $PAGE->requires->string_for_js('deletecomment', 'moodle');
@@ -273,6 +277,17 @@ EOD;
         global $PAGE, $OUTPUT;
 		static $template_printed;
 
+        $showpage = -1;
+        if (self::$showcomment) {
+            $showpage = $this->get_comment_page(self::$showcomment);
+            if ($showpage >= 0) {
+                self::$comment_itemid = $this->itemid;
+                self::$comment_area = $this->commentarea;
+                self::$comment_context = $this->contextid;
+                self::$comment_page = $showpage;
+            }
+        }
+
         $this->link = $PAGE->url;
         $murl = new moodle_url($this->link);
         $murl->remove_params('nonjscomment');
@@ -295,6 +310,10 @@ EOD;
         if ($this->env == 'block_comments') {
             $options->notoggle = true;
             $options->autostart = true;
+        } else if ($showpage >= 0) {
+            $options->page = $showpage;
+            $options->autostart = true;
+            $options->highlightcomment = self::$showcomment;
         }
 
         $PAGE->requires->js_init_call('M.core_comment.init', array($options), true);
@@ -365,6 +384,11 @@ EOD;
                 $html .= <<<EOD
     </div>
 </div>
+<div id="comment-rssarea-{$this->cid}" class="comment-rssarea">
+EOD;
+                $html .= $this->get_rss_link();
+                $html .= <<<EOD
+</div>
 <div class="clearer"></div>
 EOD;
             }
@@ -608,6 +632,7 @@ EOD;
             $html .= '</ul>';
             $html .= $this->get_pagination($page);
         }
+
         $sesskey = sesskey();
         $returnurl = $PAGE->url;
         $strsubmit = get_string('submit');
@@ -626,7 +651,9 @@ EOD;
 <input type="submit" value="{$strsubmit}" />
 </form>
 EOD;
+        $html .= $this->get_rss_link();
         }
+        
         if ($return) {
             return $html;
         } else {
@@ -655,6 +682,38 @@ EOD;
         // use html template to format a single comment.
         return str_replace($patterns, $replacements, $this->template);
     }
+
+    public function get_rss_link() {
+        global $USER, $CFG, $OUTPUT;
+        if (!$CFG->enablerssfeeds || empty($CFG->rsscomments) || $CFG->rsscomments == 0) {
+            return '';
+        }
+
+        require_once("$CFG->libdir/rsslib.php");
+        $url = new moodle_url(rss_get_url($this->contextid, $USER->id, 'comment', $this->commentarea.'/'.$this->itemid));
+        return html_writer::link($url, '<img src="'.$OUTPUT->pix_url('i/rss').'" /> '.get_string('rsscomments','comment'));
+    }
+
+    public function get_comment_page($commentid) {
+        global $DB, $CFG;
+        
+        $sql = "SELECT c.id 
+                  FROM {comments} c
+                 WHERE c.contextid = :contextid AND c.commentarea = :commentarea AND c.itemid = :itemid
+              ORDER BY c.timecreated DESC";
+        $params = array();
+        $params['contextid'] = $this->contextid;
+        $params['commentarea'] = $this->commentarea;
+        $params['itemid'] = $this->itemid;
+        
+        $comments = array_keys($DB->get_records_sql($sql, $params));
+
+        $position = array_search($commentid, $comments);
+        if ($position === false) {
+            return -1;  // Comment not found in this list
+        }
+        return (int)($position/$CFG->commentsperpage);
+    }
 }
 
 class comment_exception extends moodle_exception {
diff --git a/comment/rsslib.php b/comment/rsslib.php
new file mode 100644
index 0000000..8e67048
--- /dev/null
+++ b/comment/rsslib.php
@@ -0,0 +1,175 @@
+<?php
+    // This file adds support to rss feeds generation
+
+    // This function is the main entry point to comment
+    // rss feeds generation.
+    function comment_rss_get_feed($context, $args) {
+        global $CFG, $DB;
+
+        if (empty($CFG->rsscomments) || $CFG->rsscomments == 0) {
+          debugging("DISABLED (site configuration)");
+          return null;
+        }
+
+        if (!has_capability('moodle/comment:view', $context)) {
+            return null;
+        }
+
+        $commentarea = clean_param($args[3], PARAM_TEXT);
+        $itemid = clean_param($args[4], PARAM_INT);
+
+        $sql = comment_rss_get_sql($context->id, $commentarea, $itemid);
+
+        //get the cache file info
+        $filename = rss_get_file_name($context, $sql);
+        $cachedfilepath = rss_get_file_full_name('comment', $filename);
+
+        //Is the cache out of date?
+        $cachedfilelastmodified = 0;
+        if (file_exists($cachedfilepath)) {
+            $cachedfilelastmodified = filemtime($cachedfilepath);
+        }
+        //if the cache is more than 60 seconds old and there's new stuff
+        $dontrecheckcutoff = time()-60;
+        $newstuff = comment_rss_newstuff($context->id, $commentarea, $itemid, $cachedfilelastmodified);
+
+        if ( ($dontrecheckcutoff > $cachedfilelastmodified && $newstuff) || $cachedfilelastmodified == 0 ) {
+            if ($context->depth == 4) {
+                // It is a course module
+                if (!$cm = $DB->get_record('course_modules', array('id'=>$context->instanceid))) {
+                    return null;
+                }
+            
+                if (!$module = $DB->get_record('modules', array('id'=>$cm->module))) {
+                    return null;
+                }
+
+                if (!$mod_instance = $DB->get_record($module->name, array('id'=>$cm->instance))) {
+                    return null;
+                }
+
+                $path = get_plugin_directory('mod',$module->name).'/lib.php';
+                if (!file_exists($path)) {
+                    return null;
+                }
+
+                require_once($path);
+                $functionname = $module->name.'_get_rss_comment_link';
+                if (!function_exists($functionname) || !($link = $functionname($cm, $commentarea, $itemid))) {
+                    $link = $CFG->wwwroot.'/mod/'.$module->name.'/view.php?id='.$cm->id;
+                }
+
+                $course = $DB->get_record('course', array('id'=>$mod_instance->course));
+
+                $header_name = $course->shortname.': '.format_string($mod_instance->name, true).' '.get_string('commentrss','comment');
+                $header_intro = format_string($mod_instance->intro, true);
+
+            } else if ($context->depth == 2) {
+                // Blogs - nothing else at present
+                $link = $CFG->wwwroot.'/blog/index.php?entryid='.$itemid;
+
+                $header_name = get_string('blog','blog').' '.get_string('commentrss','comment');
+                $header_intro = '';
+
+            } else {
+                // Not sure how to deal with any other levels of context
+                // Not currently needed anywhere
+                return null;
+            }
+
+            if ($newstuff) {
+                if (!$comments = $DB->get_records_sql($sql, array(), 0, $CFG->rsscomments)) {
+                    return null;
+                }
+
+                $items = array();
+                foreach ($comments as $comment) {
+                    $item = new stdClass;
+
+                    $item->title = get_string('commentby','comment').' '.$comment->firstname.' '.$comment->lastname;
+                    $item->description = format_text($comment->content, $comment->format);
+                    $item->pubdate = $comment->timecreated;
+                    $item->link = $link.'&showcomment='.$comment->id;
+
+                    array_push($items, $item);
+                }
+            } else {
+                $item = new stdClass;
+
+                $item->title = get_string('nocomments','comment');
+                $item->description = $item->title;
+                $item->pubdate = 0;
+                $item->link = $link;
+
+                $items = array($item);
+            }
+
+            // First all rss feeds common headers.
+            $header = rss_standard_header($header_name, $link, $header_intro); //TODO: fix format
+
+            if (!empty($header)) {
+                $articles = rss_add_items($items);
+            }
+
+            // Now all rss feeds common footers.
+            if (!empty($header) && !empty($articles)) {
+                $footer = rss_standard_footer();
+            }
+            // Now, if everything is ok, concatenate it.
+            if (!empty($header) && !empty($articles) && !empty($footer)) {
+                $rss = $header.$articles.$footer;
+
+                //Save the XML contents to file.
+                $status = rss_save_file('comment', $filename, $rss);
+            }
+        } else if ($cachedfilelastmodified == 0) {
+            // There are no comments - so return 'no comments' formatted as an RSS feed
+        }
+
+        return $cachedfilepath;
+    }
+
+
+    function comment_rss_get_sql($contextid, $commentarea, $itemid, $time=0) {
+        //do we only want new comments?
+        if ($time) {
+            $time = " AND c.timecreated > '$time'";
+        } else {
+            $time = '';
+        }
+
+        // Ideally I would like to use the proper $DB functions to do this
+        // but, I need the finished SQL statement as a string to pass onto
+        // the RSS lib in order to get a unique file path (so I can't wait
+        // until the query is run to insert this parameter)
+        $commentarea = addslashes($commentarea);
+
+        $sql = "SELECT c.*, u.firstname, u.lastname
+                  FROM {comments} c, {user} u
+                 WHERE c.contextid = {$contextid} 
+                       AND c.commentarea = '{$commentarea}'
+                       AND c.itemid = {$itemid}
+                       AND c.userid = u.id $time
+              ORDER BY c.timecreated DESC";
+
+        return $sql;
+    }
+
+    /**
+     * If there is new stuff in since $time this returns true
+     * Otherwise it returns false.
+     *
+     * @param object $data the data activity object
+     * @param int $time timestamp
+     * @return bool
+     */
+     function comment_rss_newstuff($contextid, $itemid, $time) {
+         global $DB;
+         
+         $sql = comment_rss_get_sql($contextid, $itemid, $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));
+    }
+
+?>
\ No newline at end of file
diff --git a/lang/en/admin.php b/lang/en/admin.php
index 4018bb8..9beb5eb 100755
--- a/lang/en/admin.php
+++ b/lang/en/admin.php
@@ -301,6 +301,7 @@ $string['configrequestedteachersname'] = 'Word for teachers used in requested co
 $string['configrequiremodintro'] = 'Disable this option if you do not want to force users to enter description of each activity.';
 $string['configrestrictbydefault'] = 'Should new courses that are created that fall into the above category have their modules restricted by default?';
 $string['configrestrictmodulesfor'] = 'Which courses should have <b>the setting</b> for disabling some activity modules?  Note that this setting only applies to teachers, administrators will still be able to add any activity to a course.';
+$string['configrsscomments'] = 'Number of comments to include in any comment RSS feed. Selecting \'None\' will disable the generation of RSS feeds for comments';
 $string['configrunclamavonupload'] = 'When enabled, clam AV will be used to scan all uploaded files.';
 $string['configrunclamonupload'] = 'Run clam AV on file upload? You will need a correct path in pathtoclam for this to work.  (Clam AV is a free virus scanner that you can get from http://www.clamav.net/)';
 $string['configuserquota'] = 'The maximum number of bytes that a user can store in their own private file area. {$a->bytes} bytes == {$a->displaysize}';
@@ -876,6 +877,7 @@ $string['riskxss'] = 'Users could add files and texts that allow cross-site scri
 $string['riskxssshort'] = 'XSS risk';
 $string['roleswithexceptions'] = '{$a->roles}, with {$a->exceptions}';
 $string['rowpreviewnum'] = 'Preview rows';
+$string['rsscomments'] = 'Number of comments in RSS feeds';
 $string['rssglobaldisabled'] = 'Disabled at server level';
 $string['runclamavonupload'] = 'Use clam AV on uploaded files';
 $string['save'] = 'Save';
diff --git a/lang/en/comment.php b/lang/en/comment.php
new file mode 100644
index 0000000..e3538ee
--- /dev/null
+++ b/lang/en/comment.php
@@ -0,0 +1,31 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for component 'completion', language 'en', branch 'MOODLE_20_STABLE'
+ *
+ * @package   completion
+ * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['commentby'] = 'Comment by';
+$string['commentrss'] = '(comments)';
+$string['nocomments'] = 'No comments';
+$string['rsscomments'] = 'RSS feed for these comments';
+
+?>
\ No newline at end of file
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index b4e5dcb..055f036 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -7127,6 +7127,7 @@ function get_core_subsystems() {
             'calendar'    => 'calendar',
             'cohort'      => 'cohort',
             'condition'   => NULL,
+            'comment'     => 'comment',
             'completion'  => NULL,
             'countries'   => NULL,
             'course'      => 'course',
diff --git a/mod/data/lib.php b/mod/data/lib.php
index a22aa6b..184c445 100755
--- a/mod/data/lib.php
+++ b/mod/data/lib.php
@@ -3093,3 +3093,13 @@ function data_presets_export($course, $cm, $data, $tostorage=false) {
     // Return the full path to the exported preset file:
     return $exportfile;
 }
+
+// Returns a link, suitable for inserting into the RSS feed, to the
+// page with these comments on it
+function data_get_rss_comment_link($cm, $commentarea, $itemid) {
+    if ($commentarea != 'database_entry') {
+        return false;
+    }
+    $url = new moodle_url('/mod/data/view.php', array('d'=>$cm->instance, 'rid'=>$itemid));
+    return $url->out(false);
+}
\ No newline at end of file
diff --git a/mod/data/view.php b/mod/data/view.php
index 818bceb..513b8df 100755
--- a/mod/data/view.php
+++ b/mod/data/view.php
@@ -257,7 +257,12 @@
 
 
 // Initialize $PAGE, compute blocks
-    $PAGE->set_url('/mod/data/view.php', array('id' => $cm->id));
+    $urlparams = array('d' => $data->id);
+    if ($record) { $urlparams['rid'] = $record->id; }
+    if ($page) { $urlparams['page'] = $page; }
+    if ($mode) { $urlparams['mode'] = $mode; }
+    if ($filter) { $urlparams['filter'] = $filter; }
+    $PAGE->set_url('/mod/data/view.php', $urlparams);
 
     if (($edit != -1) and $PAGE->user_allowed_editing()) {
         $USER->editing = $edit;
diff --git a/rss/file.php b/rss/file.php
index 7d2f9f5..a506673 100644
--- a/rss/file.php
+++ b/rss/file.php
@@ -28,7 +28,7 @@
 
 
 // Disable moodle specific debug messages and any errors in output
-define('NO_DEBUG_DISPLAY', true);//comment this out to see any error messages during RSS generation
+//define('NO_DEBUG_DISPLAY', true);//comment this out to see any error messages during RSS generation
 
 // Sessions not used here, we recreate $USER every time we are called
 define('NO_MOODLE_COOKIES', true);
