From 537718f85a706184e89aabe0a55a5e5413679fc8 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 9 May 2003 20:05:15 +0000 Subject: [PATCH] Included log generation to XML --- backup/STATUS.txt | 3 ++- backup/backup_execute.html | 10 ++++++++- backup/lib.php | 42 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/backup/STATUS.txt b/backup/STATUS.txt index 158522b13d..4e505c0d20 100644 --- a/backup/STATUS.txt +++ b/backup/STATUS.txt @@ -4,7 +4,7 @@ STATUS $Id$ This documment shows the current status of the backup/restore option. Backup: WORKING. Only xml generation into temp dir. Header, info, - course data, sections and user data. + course data, sections, user data and logs. Restore: NOT WORKING. No comments. @@ -47,6 +47,7 @@ Backup Details: x students........................................DONE - Course.......................................DONE - All..........................................DONE + - Logs...............................................DONE - Mods Info..........................................IN PROGRESS x assignments.....................................IN PROGRESS + course data..................................NO EXISTS diff --git a/backup/backup_execute.html b/backup/backup_execute.html index 8941c9ab43..cf0d25e22f 100644 --- a/backup/backup_execute.html +++ b/backup/backup_execute.html @@ -156,7 +156,15 @@ if ($status) { $status = backup_user_info($backup_file,$preferences); } - + + //Print logs if selected + if ($preferences->backup_logs) { + echo "
  • Writing logs info"; + //User info + if ($status) { + $status = backup_log_info($backup_file,$preferences); + } + } //Module info diff --git a/backup/lib.php b/backup/lib.php index 5e12a8e2c8..9e483265b3 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -771,6 +771,48 @@ } return $status; + } + + //Backup log info (time ordered) + function backup_log_info($bf,$preferences) { + global $CFG; + + $status = true; + + $logs = get_records ("log","course",$preferences->backup_course); + + //We have logs + if ($logs) { + //Pring logs header + fwrite ($bf,start_tag("LOGS",2,true)); + //Iterate + foreach ($logs as $log) { + //See if it is a valid module to backup + if ($log->module == "course" or + $log->module == "user") { + //Begin log tag + fwrite ($bf,start_tag("LOG",3,true)); + + //Output log data + fwrite ($bf,full_tag("ID",4,false,$log->id)); + fwrite ($bf,full_tag("TIME",4,false,$log->time)); + fwrite ($bf,full_tag("USERID",4,false,$log->userid)); + fwrite ($bf,full_tag("IP",4,false,$log->ip)); + fwrite ($bf,full_tag("MODULE",4,false,$log->module)); + fwrite ($bf,full_tag("ACTION",4,false,$log->action)); + fwrite ($bf,full_tag("URL",4,false,$log->url)); + fwrite ($bf,full_tag("INFO",4,false,$log->info)); + + //End log data + fwrite ($bf,end_tag("LOG",3,true)); + } + } + $status = fwrite ($bf,end_tag("LOGS",2,true)); + } + + + + return $status; } ?> -- 2.39.5