]> git.mjollnir.org Git - moodle.git/commitdiff
Merged fix from 1.6 for Bug #5131 - RSS Feeds and Moving Discussions.
authorvyshane <vyshane>
Wed, 7 Jun 2006 08:19:34 +0000 (08:19 +0000)
committervyshane <vyshane>
Wed, 7 Jun 2006 08:19:34 +0000 (08:19 +0000)
mod/forum/discuss.php
mod/forum/rsslib.php

index d0b83b259a4b37b08cff7f5b8053b6b914341e54..5287edd0fd8a0062cab27e6f0351ed6ab5ab87b2 100644 (file)
             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);
index 3328e7d47a1f05dea02e25e5c9f717658ecddd7d..fa3b26fd9770944a11e647ce86f650773ef7add9 100644 (file)
         }
         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
         $items = array();
 
         if ($newsince) {
-            $newsince = " AND p.modified > '$newsince'";
+            $newsince = " AND (p.modified > '$newsince' OR d.timemodified > '$newsince')";
         } else {
             $newsince = "";
         }
         $items = array();
 
         if ($newsince) {
-            $newsince = " AND p.modified > '$newsince'";
+            $newsince = " AND (p.modified > '$newsince' OR d.timemodified > '$newsince')";
         } else {
             $newsince = "";
         }