moodle/backup/backup_execute.html

107 lines
2.8 KiB
HTML

<?PHP //$Id$
//This page prints the backup todo list to see everything
//Checks for the required files/functions to backup every mod
//And check if there is data about it
$count = 0;
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$mods_home/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
include_once($modfile);
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
$var = "exists_".$modname;
$$var = true;
$count++;
}
}
//Check data
//Check module info
$var = "backup_".$modname;
if (!isset($$var)) {
$$var = 1;
}
//Check include user info
$var = "backup_user_info_".$modname;
if (!isset($$var)) {
$$var = 1;
}
}
}
//Check other parameters
if (!isset($backup_users)) {
$backup_users = 1;
}
if (!isset($backup_logs)) {
$backup_logs = 1;
}
if (!isset($backup_user_files)) {
$backup_user_files = 1;
}
if (!isset($backup_course_files)) {
$backup_course_files = 2;
}
if (!isset($id)) {
error ("Course not specified");
}
if (!isset($backup_name)) {
error ("Backup name not specified");
}
if (!isset($backup_unique_code)) {
error ("Backup unique code not specified");
}
if ($count == 0) {
notice("No backupable modules are installed!");
}
//Start the main table
echo "<table cellpadding=5>";
//Now print the Backup Name tr
echo "<tr>";
echo "<td align=\"right\"><P><B>";
echo get_string("name").":";
echo "</B></td><td>";
echo $backup_name;
echo "</td></tr>";
//Start the main tr, where all the backup progress is done
echo "<tr>";
echo "<td colspan=\"2\">";
//Delete old_entries from backup tables
echo "<li>Deteting old data";
$status = backup_delete_old_data();
if (!$status) {
error ("An error has ocurred");
}
//Check for temp and backup and backup_unique_code directory
//Create them as needed
echo "<li>Creating temporary structures";
$status = check_and_create_backup_dir($backup_unique_code);
//Empty dir
if ($status) {
$status = clear_backup_dir($backup_unique_code);
}
if (!$status) {
error ("An error has ocurred");
}
//End the main tr, where all the backup is done
//End the main table
echo "</table>";
?>