]> git.mjollnir.org Git - moodle.git/commitdiff
Finished the check phase. Ready to begin the execute phase.
authorstronk7 <stronk7>
Sun, 4 May 2003 21:01:47 +0000 (21:01 +0000)
committerstronk7 <stronk7>
Sun, 4 May 2003 21:01:47 +0000 (21:01 +0000)
backup/STATUS.txt
backup/backup.php
backup/backup_version.php
backup/check.html
backup/db/backup_mysql.php
backup/lib.php

index ab085888569df3e3fb0785bbee670f93b820439e..fcfa6acac5e7a541e554b40da25c98ea4ff0df16 100644 (file)
@@ -16,10 +16,12 @@ Backup Details:
    - Backup FrontEnd............................................IN PROGRESS
         - Check Security........................................DONE
         - Select Info to Backup.(from mods).....................DONE
-        - Check (summary info)..................................IN PROGRESS
+        - Check (summary info)..................................DONE
              - Check mods.......................................DONE
-             - Check logs.......................................IN PROGRESS
+             - Check logs.......................................DONE
              - Check users......................................DONE
+             - Check User Files.................................DONE
+             - Check Course Files...............................DONE
         - Launch Backup.........................................NO EXISTS
         - Show progress.........................................NO EXISTS
         - Determine Backup location.............................NO EXISTS
index e03c7fa24d832287d7568d95aadaed3a848f29b6..a14b71a7ae27cce781f249a3c1b7748da6e50f85 100644 (file)
@@ -47,6 +47,7 @@
                 $db->debug=false;
                 if (set_config("backup_version", $a->newversion)) {
                     notify($strdatabasesuccess, "green");
+                    notify("You are running Backup/Recovery version ".$backup_release,"black");
                     print_continue("backup.php");
                     die;
                 } else {
index 2ad2e9fc8edafa249e1680d279aa4a20a08833be..0f9906e27e4ff0663a02410f34d1bb9edc38b86c 100644 (file)
@@ -5,6 +5,6 @@
 // database (backup_version) to determine whether upgrades should
 // be performed (see db/backup_*.php)
 
-$backup_version = 2003050301;   // The current version is a date (YYYYMMDDXX)
+$backup_version = 2003050401;   // The current version is a date (YYYYMMDDXX)
 
 $backup_release = "0.1.0 beta";  // User-friendly version number
index f1e4ea9ea6b0cb88441ef973763a22e5e64959de..a2660ed674dc0fac95ab7fb16052acdaecc5818b 100644 (file)
@@ -97,6 +97,9 @@
     echo get_string("backupdetails").":";
     echo "</td></tr>";
 
+    //This is tha align to every ingo table                
+    $table->align = array ("LEFT","RIGHT");
+
     if ($allmods = get_records("modules") ) {
         foreach ($allmods as $mod) {
             $modname = $mod->name;
         if ($backup_logs) {
             echo "<tr>";
             echo "<td colspan=\"2\"><P><B>";
-            echo "<li>".get_string("includelogentries");; 
+            echo "<li>".get_string("includelogentries")."<P>";
+            //Print info
+            $table->data = log_check_backup($id);
+            print_table($table);
             echo "</td></tr>";
         }
         //Add as hidden name
         if ($backup_user_files) {
             echo "<tr>";
             echo "<td colspan=\"2\"><P><B>";
-            echo "<li>".get_string("includeuserfiles");;
+            echo "<li>".get_string("includeuserfiles")."<P>";
+            //Print info
+            $table->data = user_files_check_backup($id,$backup_unique_code);
+            print_table($table);
             echo "</td></tr>";
         }
         //Add as hidden name
        if ($backup_course_files) {
             echo "<tr>";
             echo "<td colspan=\"2\"><P><B>";
-            echo "<li>".get_string("includecoursefiles");; 
+            echo "<li>".get_string("includecoursefiles")."<P>";
+            //Print info
+            $table->data = course_files_check_backup($id,$backup_unique_code);
+            print_table($table);
             echo "</td></tr>";
         }
         //Add as hidden name
index 69d29b1dbf4025b9e16e3da3501a4219ef86d5b7..a967f9af3b77297d5efc6006a62c50074bf29fa8 100644 (file)
@@ -38,8 +38,23 @@ function backup_upgrade($oldversion=0) {
     if ($oldversion < 2003050301 and $result) {
         $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
                          ADD `info` VARCHAR(30)");
+    }
+
+    if ($oldversion < 2003050400 and $result) {
+        $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
+                         MODIFY `info` VARCHAR(255)");
     } 
 
+    if ($oldversion < 2003050401 and $result) {
+        $result = execute_sql("CREATE  TABLE  `{$CFG->prefix}backup_files` (
+                                  `backup_code` INT( 10  ) UNSIGNED NOT  NULL ,
+                                  `file_type` VARCHAR( 10  )  NOT  NULL ,
+                                  `path` VARCHAR( 255  )  NOT  NULL ,
+                                  `old_id` INT( 10  ) UNSIGNED,
+                                  `new_id` INT( 10  ) UNSIGNED,
+                               PRIMARY  KEY (  `backup_code` ,  `file_type` ,  `path`  ) 
+                               ) COMMENT  =  'To store and recode ids to user & course files.'");
+    }
 
     //Finally, return result
     return $result;
index 22250ce42ae717064bccb5853501634f1a3433e8..ce9f3a43e250a6696a37266d6338b0b22d978355 100644 (file)
         return $info;
     }
 
+    //Calculate the number of log entries to backup
+    //Return an array of info (name,value)
+    function log_check_backup($course) {
+
+        global $CFG;
+
+        //Execute the insert
+        $status = execute_sql($sql_insert,false);
+
+        //Now execute the select
+        $ids = get_records_sql("SELECT DISTINCT l.id,l.course
+                                FROM {$CFG->prefix}log l
+                                WHERE l.course = '$course'");
+        //Gets the user data
+        $info[0][0] = get_string("logs");
+        if ($ids) {
+            $info[0][1] = count($ids);
+        } else {
+            $info[0][1] = 0;
+        }
+
+        return $info;
+    }
+
+    //Calculate the number of user files to backup
+    //Under $CFG->dataroot/users
+    //and put them (their path) in backup_ids
+    //Return an array of info (name,value)
+    function user_files_check_backup($course,$backup_unique_code) {
+
+        global $CFG;
+
+        $rootdir = $CFG->dataroot."/users";
+        $coursedirs = get_directory_list($rootdir);
+        foreach ($coursedirs as $dir) {
+            //Extracts user id from file path
+            $tok = strtok($dir,"/");
+            if ($tok) {
+               $userid = $tok;
+            } else {
+               $tok = "";
+            }
+            //Insert them into backup_files
+           $status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
+                                      (backup_code, file_type, path, old_id)
+                                  VALUES
+                                      ('$backup_unique_code','user','$dir','$userid')",false);
+        }
+
+        //Now execute the select
+        $ids = get_records_sql("SELECT DISTINCT b.path, b.old_id
+                                FROM {$CFG->prefix}backup_files b
+                                WHERE backup_code = '$backup_unique_code' AND
+                                      file_type = 'user'");
+        //Gets the user data
+        $info[0][0] = get_string("files");
+        if ($ids) {
+            $info[0][1] = count($ids);
+        } else {
+            $info[0][1] = 0;
+        }
+
+        return $info;  
+    }
+
+    //Calculate the number of course files to backup
+    //under $CFG->dataroot/$course, except $CFG->moddata
+    //and put them (their path) in backup_ids
+    //Return an array of info (name,value)
+    function course_files_check_backup($course,$backup_unique_code) {
+
+        global $CFG;
+
+        $rootdir = $CFG->dataroot."/$course";
+        $coursedirs = get_directory_list($rootdir,$CFG->moddata);
+        foreach ($coursedirs as $dir) {
+            //Insert them into backup_files
+           $status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
+                                      (backup_code, file_type, path)
+                                  VALUES
+                                      ('$backup_unique_code','course','$dir')",false);
+        }
+
+        //Now execute the select
+        $ids = get_records_sql("SELECT DISTINCT b.path, b.old_id
+                                FROM {$CFG->prefix}backup_files b
+                                WHERE backup_code = '$backup_unique_code' AND
+                                      file_type = 'course'");
+        //Gets the user data
+        $info[0][0] = get_string("files");
+        if ($ids) {
+            $info[0][1] = count($ids);
+        } else {
+            $info[0][1] = 0;
+        }
+
+        return $info; 
+    }
+
+
 ?>