From: stronk7 Date: Sun, 4 May 2003 21:01:47 +0000 (+0000) Subject: Finished the check phase. Ready to begin the execute phase. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3868b9c6660154273056507294e822c792ad10b2;p=moodle.git Finished the check phase. Ready to begin the execute phase. --- diff --git a/backup/STATUS.txt b/backup/STATUS.txt index ab08588856..fcfa6acac5 100644 --- a/backup/STATUS.txt +++ b/backup/STATUS.txt @@ -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 diff --git a/backup/backup.php b/backup/backup.php index e03c7fa24d..a14b71a7ae 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -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 { diff --git a/backup/backup_version.php b/backup/backup_version.php index 2ad2e9fc8e..0f9906e27e 100644 --- a/backup/backup_version.php +++ b/backup/backup_version.php @@ -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 diff --git a/backup/check.html b/backup/check.html index f1e4ea9ea6..a2660ed674 100644 --- a/backup/check.html +++ b/backup/check.html @@ -97,6 +97,9 @@ echo get_string("backupdetails").":"; echo ""; + //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; @@ -152,7 +155,10 @@ if ($backup_logs) { echo ""; echo "

"; - echo "

  • ".get_string("includelogentries");; + echo "
  • ".get_string("includelogentries")."

    "; + //Print info + $table->data = log_check_backup($id); + print_table($table); echo ""; } //Add as hidden name @@ -162,7 +168,10 @@ if ($backup_user_files) { echo ""; echo "

    "; - echo "

  • ".get_string("includeuserfiles");; + echo "
  • ".get_string("includeuserfiles")."

    "; + //Print info + $table->data = user_files_check_backup($id,$backup_unique_code); + print_table($table); echo ""; } //Add as hidden name @@ -172,7 +181,10 @@ if ($backup_course_files) { echo ""; echo "

    "; - echo "

  • ".get_string("includecoursefiles");; + echo "
  • ".get_string("includecoursefiles")."

    "; + //Print info + $table->data = course_files_check_backup($id,$backup_unique_code); + print_table($table); echo ""; } //Add as hidden name diff --git a/backup/db/backup_mysql.php b/backup/db/backup_mysql.php index 69d29b1dbf..a967f9af3b 100644 --- a/backup/db/backup_mysql.php +++ b/backup/db/backup_mysql.php @@ -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; diff --git a/backup/lib.php b/backup/lib.php index 22250ce42a..ce9f3a43e2 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -75,4 +75,104 @@ 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; + } + + ?>