Now chat logs are included in restore. I've decided to start with this
simple module to be ready for the difficults... :-)
This commit is contained in:
+26
-1
@@ -1154,6 +1154,8 @@
|
||||
if ($cm) {
|
||||
//echo "Module ".$dblog->cmid." to module ".$cm->new_id."<br>"; //Debug
|
||||
$dblog->cmid = $cm->new_id;
|
||||
} else {
|
||||
$dblog->cmid = 0;
|
||||
}
|
||||
}
|
||||
//print_object ($dblog); //Debug
|
||||
@@ -1304,7 +1306,7 @@
|
||||
$toinsert = true;
|
||||
break;
|
||||
default:
|
||||
//echo "action (".$log->action.") unknow. Not restored<br>"; //Debug
|
||||
echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>"; //Debug
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1375,7 +1377,30 @@
|
||||
function restore_log_module($restore,$log) {
|
||||
|
||||
$status = true;
|
||||
$toinsert = false;
|
||||
|
||||
//echo "<hr>Before transformations<br>"; //Debug
|
||||
//print_object($log); //Debug
|
||||
|
||||
//Now we see if the required function in the module exists
|
||||
$function = $log->module."_restore_logs";
|
||||
if (function_exists($function)) {
|
||||
//Call the function
|
||||
$log = $function($restore,$log);
|
||||
//If everything is ok, mark the insert flag
|
||||
if ($log) {
|
||||
$toinsert = true;
|
||||
}
|
||||
}
|
||||
|
||||
//echo "After transformations<br>"; //Debug
|
||||
//print_object($log); //Debug
|
||||
|
||||
//Now if $toinsert is set, insert the record
|
||||
if ($toinsert) {
|
||||
//echo "Inserting record<br>"; //Debug
|
||||
$status = insert_record("log",$log);
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,4 +126,60 @@
|
||||
}
|
||||
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":
|
||||
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 all":
|
||||
$log->url = "index.php?id=".$log->course;
|
||||
$status = true;
|
||||
break;
|
||||
default:
|
||||
echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>"; //Debug
|
||||
break;
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
$status = $log;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user