Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged fix from 1.6 for Bug #5131 - RSS Feeds and Moving Discussions.

  • Loading branch information...
commit b134f6a71e276cd892ab532d91960e77c7be1e4e 1 parent b6640a7
vyshane authored
Showing with 31 additions and 3 deletions.
  1. +19 −1 mod/forum/discuss.php
  2. +12 −2 mod/forum/rsslib.php
View
20 mod/forum/discuss.php
@@ -57,8 +57,26 @@
if (!forum_move_attachments($discussion, $move)) {
notify("Errors occurred while moving attachment directories - check your file permissions");
}
- set_field("forum_discussions", "forum", $forum->id, "id", $discussion->id);
+
+ if (!$fromforum = get_record("forum", "id", $discussion->forum)) {
+ notify('Bad forum ID stored in this discussion');
+ }
$discussion->forum = $forum->id;
+ $discussion->timemodified = time();
+
+ if (update_record('forum_discussions', $discussion)) {
+ // Update RSS feeds for both from and to forums.
+ require_once('rsslib.php');
+ require_once($CFG->libdir.'/rsslib.php');
+
+ // Delete the RSS files for the 2 forums because we want to force
+ // the regeneration of the feeds since the discussions have been
+ // moved.
+ if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($fromforum)) {
+ error('Could not purge the cached RSS feeds for the source and/or destination forums');
+ }
+ }
+
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
add_to_log($course->id, "forum", "move discussion", "discuss.php?d=$discussion->id", "$discussion->id",
$cm->id);
View
14 mod/forum/rsslib.php
@@ -78,6 +78,16 @@ function forum_rss_feeds() {
}
return $status;
}
+
+
+ // Given a forum object, deletes the RSS file
+ function forum_rss_delete_file($forum) {
+ global $CFG;
+ //return unlink("{$CFG->dataroot}/rss/{$modname}/{$forum->id}.xml");
+ $rssfile = rss_file_name('forum', $forum);
+ return unlink($rssfile);
+ }
+
function forum_rss_newstuff($forum, $time) {
// If there is new stuff in the forum since $time then this returns
@@ -158,7 +168,7 @@ function forum_rss_feed_discussions($forum, $newsince=0) {
$items = array();
if ($newsince) {
- $newsince = " AND p.modified > '$newsince'";
+ $newsince = " AND (p.modified > '$newsince' OR d.timemodified > '$newsince')";
} else {
$newsince = "";
}
@@ -218,7 +228,7 @@ function forum_rss_feed_posts($forum, $newsince=0) {
$items = array();
if ($newsince) {
- $newsince = " AND p.modified > '$newsince'";
+ $newsince = " AND (p.modified > '$newsince' OR d.timemodified > '$newsince')";
} else {
$newsince = "";
}
Please sign in to comment.
Something went wrong with that request. Please try again.