]> git.mjollnir.org Git - moodle.git/commitdiff
Solved small bug in delete discussion action, where the
authorstronk7 <stronk7>
Sun, 22 Feb 2004 11:40:44 +0000 (11:40 +0000)
committerstronk7 <stronk7>
Sun, 22 Feb 2004 11:40:44 +0000 (11:40 +0000)
info field was storing the post->id rather of the discussion->id field

mod/forum/post.php
mod/forum/restorelib.php

index 8c0bd6553baafdddc8d1e50696ba2f6a7f21fda5..437b11dfa89ddaee63e8681a00a4458276ae8b82 100644 (file)
                     forum_delete_discussion($discussion);
 
                     add_to_log($discussion->course, "forum", "delete discussion", 
-                               "view.php?id=$discussion->forum", "$post->id", $cm->id);
+                               "view.php?id=$discussion->forum", "$discussion->id", $cm->id);
 
                     redirect("view.php?f=$discussion->forum", 
                              get_string("deleteddiscussion", "forum"), 1);
index fc7dbe2902f25fc4c1a59960370a60b93c43ed5f..2fb6bc07ddf1e279776fde5663036d2b8279e2bf 100644 (file)
         return $status;
     }
 
+//This function returns a log record with all the necessay transformations
+    //done. It's used by restore_log_module() to restore modules log.
+    function chat_restore_logs($restore,$log) {
+                    
+        $status = false;
+                    
+        //Depending of the action, we recode different things
+        switch ($log->action) {
+        case "add":
+            if ($log->cmid) {
+                //Get the new_id of the module (to recode the info field)
+                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
+                if ($mod) {
+                    $log->url = "view.php?id=".$log->cmid;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "update":
+            if ($log->cmid) {
+                //Get the new_id of the module (to recode the info field)
+                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
+                if ($mod) {
+                    $log->url = "view.php?id=".$log->cmid;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "view forum":
+            if ($log->cmid) {
+                //Get the new_id of the module (to recode the info field)
+                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
+                if ($mod) {
+                    $log->url = "view.php?id=".$log->cmid;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "view forums":
+            $log->url = "index.php?id=".$log->course;
+            $status = true;
+            break;
+        case "subscribe":
+            if ($log->cmid) {
+                //Get the new_id of the module (to recode the info and url field)
+                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
+                if ($mod) {
+                    $log->url = "view.php?f=".$mod->new_id;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "view subscriber":
+            if ($log->cmid) {
+                //Get the new_id of the module (to recode the info and field)
+                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
+                if ($mod) {
+                    $log->url = "subscribers.php?id=".$mod->new_id;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "unsubscribe":
+            if ($log->cmid) {
+                //Get the new_id of the module (to recode the info and url field)
+                $mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
+                if ($mod) {
+                    $log->url = "view.php?f=".$mod->new_id;
+                    $log->info = $mod->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "add discussion":
+            if ($log->cmid) {
+                //Get the new_id of the discussion (to recode the info and url field)
+                $dis = backup_getid($restore->backup_unique_code,"forum_discussions",$log->info);
+                if ($dis) {
+                    $log->url = "discuss.php?d=".$dis->new_id;
+                    $log->info = $dis->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "view discussion":
+            if ($log->cmid) {
+                //Get the new_id of the discussion (to recode the info and url field)
+                $dis = backup_getid($restore->backup_unique_code,"forum_discussions",$log->info);
+                if ($dis) {
+                    $log->url = "discuss.php?d=".$dis->new_id;
+                    $log->info = $dis->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "move discussion":
+            if ($log->cmid) {
+                //Get the new_id of the discussion (to recode the info and url field)
+                $dis = backup_getid($restore->backup_unique_code,"forum_discussions",$log->info);
+                if ($dis) {
+                    $log->url = "discuss.php?d=".$dis->new_id;
+                    $log->info = $dis->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        default:
+            echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>";                 //Debug
+            break;
+        }
+
+        if ($status) {
+            $status = $log;
+        }
+        return $status;
+    }
 ?>