From 96d6fc8f14cfda9c4fa64630f40c5e1bf185a5a8 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 22 Feb 2004 11:40:44 +0000 Subject: [PATCH] Solved small bug in delete discussion action, where the info field was storing the post->id rather of the discussion->id field --- mod/forum/post.php | 2 +- mod/forum/restorelib.php | 121 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-) diff --git a/mod/forum/post.php b/mod/forum/post.php index 8c0bd6553b..437b11dfa8 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -277,7 +277,7 @@ 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); diff --git a/mod/forum/restorelib.php b/mod/forum/restorelib.php index fc7dbe2902..2fb6bc07dd 100644 --- a/mod/forum/restorelib.php +++ b/mod/forum/restorelib.php @@ -481,4 +481,125 @@ 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
"; //Debug + break; + } + + if ($status) { + $status = $log; + } + return $status; + } ?> -- 2.39.5