]> git.mjollnir.org Git - moodle.git/commitdiff
Included log generation to XML
authorstronk7 <stronk7>
Fri, 9 May 2003 20:05:15 +0000 (20:05 +0000)
committerstronk7 <stronk7>
Fri, 9 May 2003 20:05:15 +0000 (20:05 +0000)
backup/STATUS.txt
backup/backup_execute.html
backup/lib.php

index 158522b13d55f940cd618df546007eb683354d29..4e505c0d20c03a73528bc906a74f18e22ffb0e7f 100644 (file)
@@ -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
index 8941c9ab43a5efb4e470b61e6b404e3b7c6597e9..cf0d25e22f31254d75991ec0162be0c9ddf6c738 100644 (file)
         if ($status) {
             $status = backup_user_info($backup_file,$preferences);
         }
-   
+        
+        //Print logs if selected
+        if ($preferences->backup_logs) {  
+            echo "<li>Writing logs info";
+            //User info
+            if ($status) {
+                $status = backup_log_info($backup_file,$preferences);
+            }
+        }
 
         //Module info
 
index 5e12a8e2c813cd3b3e5973f16ec8548ad22ab25d..9e483265b379df5b3b77106009bc0d6f924f2193 100644 (file)
         }
 
         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;
     }
 ?>