From: stronk7 Date: Wed, 18 Feb 2004 22:30:35 +0000 (+0000) Subject: Now journal logs are restored too :-) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=73993165186d630e2bb3aecca3b8461f6a789d2a;p=moodle.git Now journal logs are restored too :-) --- diff --git a/mod/journal/restorelib.php b/mod/journal/restorelib.php index 7c3dca7e97..e642d10721 100644 --- a/mod/journal/restorelib.php +++ b/mod/journal/restorelib.php @@ -155,4 +155,98 @@ 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 journal_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": + 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 entry": + 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 entry": + 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 responses": + 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 = "report.php?id=".$log->cmid; + $log->info = $mod->new_id; + $status = true; + } + } + break; + case "update feedback": + if ($log->cmid) { + $log->url = "report.php?id=".$log->cmid; + $status = true; + } + break; + case "view all": + $log->url = "index.php?id=".$log->course; + $status = true; + break; + default: + echo "action (".$log->module."-".$log->action.") unknow. Not restored
"; //Debug + break; + } + + if ($status) { + $status = $log; + } + return $status; + } ?>