]> git.mjollnir.org Git - moodle.git/commitdiff
forum: notification of a moved dicussion (bug#4874)
authormartinlanghoff <martinlanghoff>
Mon, 31 Jul 2006 04:54:44 +0000 (04:54 +0000)
committermartinlanghoff <martinlanghoff>
Mon, 31 Jul 2006 04:54:44 +0000 (04:54 +0000)
Moving a discussion now leaves a notification message in the
original location with a link to the new location.

Author: Luke Hudson <luke@catalyst.net.nz>

lang/en_utf8/forum.php
mod/forum/discuss.php

index 9b6184c366edba38d619cb10ca506b1f0721bf63..cafab5a37fd11d42f2f56de218be6e7f701500cd 100644 (file)
@@ -49,6 +49,7 @@ $string['disallowsubscribe'] = 'Subscriptions not allowed';
 $string['disallowsubscribeteacher'] = 'Subscriptions not allowed (except for teachers)';
 $string['discussion'] = 'Discussion';
 $string['discussionmoved'] = 'This discussion has been moved to \'$a\'.';
+$string['discussionmovedpost'] = 'This discussion has been moved to <a href=\"$a->discusshref\">here</a> in the forum <a href=\"$a->forumhref\">$a->forumname</a>';
 $string['discussionname'] = 'Discussion name';
 $string['discussions'] = 'Discussions';
 $string['discussionsstartedby'] = 'Discussions started by $a';
@@ -103,6 +104,7 @@ $string['modethreaded'] = 'Display replies in threaded form';
 $string['modulename'] = 'Forum';
 $string['modulenameplural'] = 'Forums';
 $string['more'] = 'more';
+$string['movedmarker'] = '(Moved)';
 $string['movethisdiscussionto'] = 'Move this discussion to ... ';
 $string['namenews'] = 'News forum';
 $string['namesocial'] = 'Social forum';
index a422361eb700aeec47e7c3d21c7047c69eb1f7b3..7073eb47e5ba53c5ef16dec327a4c5756057743a 100644 (file)
             $discussion->forum = $forum->id;
             $discussion->timemodified = time();
             
+            // Leave behind a skeleton discussion containing only a post which 
+            // notifies that the discussion has been moved.            
+            $skeleton = clone($discussion);
+            $skeleton->forum = $fromforum->id;
+            $skeleton->name = addslashes( $skeleton->name . ' ' . get_string('movedmarker', 'forum') );
+
+            // Prepare replacement parameters for message content string 
+            // - these create the link to the new discussion location
+            $link = new stdClass;        
+            $me = strip_querystring(me());
+            $link->discusshref = $me . '?d=' . $discussion->id;
+            $link->forumhref = dirname($me) . '/view.php?f=' . $forum->id;
+            $link->forumname = $forum->name;
+
+            // retrieve translateable message content                    
+            $skeleton->intro = addslashes( get_string('discussionmovedpost', 'forum', $link) );
+            $skeleton->format = 1;
+            $skeleton->mailnow = 0;
+
+                       // add the skeleton discussion to the database
+            if (!($skeleton->id = forum_add_discussion($skeleton, $msg))) {
+                notify('Failed to add discussion-moved notification : '. $msg);
+            }
+
             if (update_record('forum_discussions', $discussion)) {
                 // Update RSS feeds for both from and to forums.
                 require_once('rsslib.php');