]> git.mjollnir.org Git - moodle.git/commitdiff
Now forum logs are restored.
authorstronk7 <stronk7>
Sun, 22 Feb 2004 12:34:07 +0000 (12:34 +0000)
committerstronk7 <stronk7>
Sun, 22 Feb 2004 12:34:07 +0000 (12:34 +0000)
mod/forum/restorelib.php

index 2fb6bc07ddf1e279776fde5663036d2b8279e2bf..e1c9086c1bff4c5bdbbd2844be9b7ff8649621d4 100644 (file)
         return $status;
     }
 
-//This function returns a log record with all the necessay transformations
+    //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) {
+    function forum_restore_logs($restore,$log) {
                     
         $status = false;
                     
                 }
             }
             break;
+        case "delete discussi":
+            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 "add post":
+            if ($log->cmid) {
+                //Get the new_id of the post (to recode the url and info field)
+                $pos = backup_getid($restore->backup_unique_code,"forum_posts",$log->info);
+                if ($pos) {
+                    //Get the post record from database
+                    $dbpos = get_record("forum_posts","id","$pos->new_id");
+                    if ($dbpos) {
+                        $log->url = "discuss.php?d=".$dbpos->discussion."&parent=".$pos->new_id;
+                        $log->info = $pos->new_id;
+                        $status = true;
+                    }
+                }
+            }
+            break;
+        case "update post":
+            if ($log->cmid) {
+                //Get the new_id of the post (to recode the url and info field)
+                $pos = backup_getid($restore->backup_unique_code,"forum_posts",$log->info);
+                if ($pos) {
+                    //Get the post record from database
+                    $dbpos = get_record("forum_posts","id","$pos->new_id");
+                    if ($dbpos) {
+                        $log->url = "discuss.php?d=".$dbpos->discussion."&parent=".$pos->new_id;
+                        $log->info = $pos->new_id;
+                        $status = true;
+                    }
+                }
+            }   
+            break;
+        case "delete post":
+            if ($log->cmid) {
+                //Extract the discussion id from the url field
+                $disid = substr(strrchr($log->url,"="),1);
+                //Get the new_id of the discussion (to recode the url field)
+                $dis = backup_getid($restore->backup_unique_code,"quiz_discussions",$disid);
+                if ($dis) {
+                    $log->url = "discuss.php?d=".$dis->new_id;
+                    $status = true;
+                }
+            }
+            break;
+        case "search":
+            $log->url = "search.php?id=".$log->course."&search=".urlencode($log->info);
+            $status = true;
+            break;
         default:
             echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>";                 //Debug
             break;