Now the restore process is XHTMLised

This commit is contained in:
stronk7
2005-02-07 23:28:52 +00:00
parent d160861fdf
commit 1bbf415fe8
5 changed files with 87 additions and 83 deletions
+1 -1
View File
@@ -42,6 +42,6 @@ Now I show the specific detailed status of every item in the process:
25. TODO: Add support for forum_read table in backup and restore.
26. DONE: chat_users->course and chat_users->lang. No changes required!
27. PROG: Make the backup/restore/config/logs/index.php XHTML 1.0 Transitional.
Done in manual backups, config and logs
Done in manual backups, config, logs and restore.
Eloy (stronk7)
23-01-2004
+33 -33
View File
@@ -77,12 +77,12 @@
//Print course fullname and shortname and category
if ($status) {
echo "<ul>";
echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")";
echo "<li>".get_string("category").": ".$course_header->category->name;
echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")".'</li>';
echo "<li>".get_string("category").": ".$course_header->category->name.'</li>';
if (!empty($oldidnumber)) {
echo "<li>".get_string("nomoreidnumber","moodle",$oldidnumber)."</li>";
}
echo "</ul>";
echo "</ul></li>";
//Put the destination course_id
$restore->course_id = $course_header->course_id;
}
@@ -91,17 +91,17 @@
if ($course) {
echo "<li>".get_string("usingexistingcourse");
echo "<ul>";
echo "<li>".get_string("from").": ".$course_header->course_fullname." (".$course_header->course_shortname.")";
echo "<li>".get_string("to").": ".$course->fullname." (".$course->shortname.")";
echo "<li>".get_string("from").": ".$course_header->course_fullname." (".$course_header->course_shortname.")".'</li>';
echo "<li>".get_string("to").": ".$course->fullname." (".$course->shortname.")".'</li>';
if (($restore->deleting)) {
echo "<li>".get_string("deletingexistingcoursedata");
echo "<li>".get_string("deletingexistingcoursedata").'</li>';
} else {
echo "<li>".get_string("addingdatatoexisting");
echo "<li>".get_string("addingdatatoexisting").'</li>';
}
echo "</ul>";
echo "</ul></li>";
//If we have selected to restore deleting, we do it now.
if ($restore->deleting) {
echo "<li>".get_string("deletingolddata");
echo "<li>".get_string("deletingolddata").'</li>';
$status = remove_course_contents($restore->course_id,false) and
delete_dir_contents($CFG->dataroot."/".$restore->course_id,"backupdata");
if ($status) {
@@ -122,7 +122,7 @@
if($status) {
//If we are deleting and bringing into a course or making a new course, same situation
if($restore->restoreto == 0 || $restore->restoreto == 2) {
echo '<li>'.get_string('creatingblocks');
echo '<li>'.get_string('creatingblocks').'</li>';
if (!$status = restore_create_blocks($restore, $info->backup_block_format, $course_header->blockinfo, $xml_file)) {
notify('Error while creating the course blocks');
}
@@ -133,13 +133,13 @@
if ($status) {
//Into new course
if ($restore->restoreto == 2) {
echo "<li>".get_string("creatingsections");
echo "<li>".get_string("creatingsections").'</li>';
if (!$status = restore_create_sections($restore,$xml_file)) {
notify("Error creating sections in the existing course.");
}
//Into existing course
} else if ($restore->restoreto == 0 or $restore->restoreto == 1) {
echo "<li>".get_string("checkingsections");
echo "<li>".get_string("checkingsections").'</li>';
if (!$status = restore_create_sections($restore,$xml_file)) {
notify("Error creating sections in the existing course.");
}
@@ -196,8 +196,8 @@
//Now print information gathered
echo " (".get_string("new").": ".$new_count.", ".get_string("existing").": ".$exists_count.")";
echo "<ul>";
echo "<li>".get_string("students").": ".$student_count;
echo "<li>".get_string("teachers").": ".$teacher_count;
echo "<li>".get_string("students").": ".$student_count.'</li>';
echo "<li>".get_string("teachers").": ".$teacher_count.'</li>';
echo "</ul>";
} else {
notify("No users were found!");
@@ -209,7 +209,7 @@
if ($status and $restore->metacourse) {
//Only to new courses!
if ($restore->restoreto == 2) {
echo "<li>".get_string("creatingmetacoursedata");
echo "</li><li>".get_string("creatingmetacoursedata");
if (!$status = restore_create_metacourse($restore,$xml_file)) {
notify("Error creating metacourse in the course.");
}
@@ -219,15 +219,15 @@
//Now create categories and questions as needed (STEP1)
if ($status and ($restore->mods['quiz']->restore)) {
echo "<li>".get_string("creatingcategoriesandquestions")."<br />";
if (!$status = restore_create_questions($restore,$xml_file)) {
notify("Could not restore categories and questions!");
}
echo "</li><li>".get_string("creatingcategoriesandquestions")."</li>";
if (!$status = restore_create_questions($restore,$xml_file)) {
notify("Could not restore categories and questions!");
}
}
//Now create user_files as needed
if ($status and ($restore->user_files)) {
echo "<li>".get_string("copyinguserfiles")."<br />";
echo "<li>".get_string("copyinguserfiles");
if (!$status = restore_user_files($restore)) {
notify("Could not restore user files!");
}
@@ -236,13 +236,13 @@
//Inform about user dirs created from backup
echo "<ul>";
echo "<li>".get_string("userzones").": ".$status;
echo "</ul>";
echo "</li></ul>";
}
}
//Now create course files as needed
if ($status and ($restore->course_files)) {
echo "<li>".get_string("copyingcoursefiles")."<br />";
echo "</li><li>".get_string("copyingcoursefiles")."</li>";
if (!$status = restore_course_files($restore)) {
notify("Could not restore course files!");
}
@@ -257,7 +257,7 @@
//Now create scales as needed
if ($status) {
echo "<li>".get_string("creatingscales");
echo "<li>".get_string("creatingscales").'</li>';
if (!$status = restore_create_scales($restore,$xml_file)) {
notify("Could not restore custom scales!");
}
@@ -265,7 +265,7 @@
//Now create groups as needed
if ($status) {
echo "<li>".get_string("creatinggroups");
echo "<li>".get_string("creatinggroups").'</li>';
if (!$status = restore_create_groups($restore,$xml_file)) {
notify("Could not restore groups!");
}
@@ -273,7 +273,7 @@
//Now create events as needed
if ($status) {
echo "<li>".get_string("creatingevents");
echo "<li>".get_string("creatingevents").'</li>';
if (!$status = restore_create_events($restore,$xml_file)) {
notify("Could not restore course events!");
}
@@ -289,7 +289,7 @@
//Now create log entries as needed
if ($status and ($restore->logs)) {
echo "<li>".get_string("creatinglogentries");
echo "</li><li>".get_string("creatinglogentries");
if (!$status = restore_create_logs($restore,$xml_file)) {
notify("Could not restore logs!");
}
@@ -297,7 +297,7 @@
//Now, if all is OK, adjust the instance field in course_modules !!
if ($status) {
echo "<li>".get_string("checkinginstances");
echo "</li><li>".get_string("checkinginstances").'</li>';
if (!$status = restore_check_instances($restore)) {
notify("Could not adjust instances in course_modules!");
}
@@ -305,7 +305,7 @@
//Now, if all is OK, adjust activity events
if ($status) {
echo "<li>".get_string("refreshingevents");
echo "<li>".get_string("refreshingevents").'</li>';
if (!$status = restore_refresh_events($restore)) {
notify("Could not refresh events for activities!");
}
@@ -323,7 +323,7 @@
// - course modinfo field
// - categories table
if ($status) {
echo "<li>".get_string("checkingcourse");
echo "</li><li>".get_string("checkingcourse").'</li>';
//modinfo field
rebuild_course_cache($restore->course_id);
//categories table
@@ -333,7 +333,7 @@
//Cleanup temps (files and db)
if ($status) {
echo "<li>".get_string("cleaningtempdata");
echo "<li>".get_string("cleaningtempdata").'</li>';
if (!$status = clean_temp_data ($restore)) {
notify("Could not clean up temporary data from files and database");
}
@@ -344,7 +344,7 @@
//End the main table
echo "</tr></td>";
echo "</td></tr>";
echo "</table>";
if (!$status) {
@@ -354,9 +354,9 @@
if (!$restore->importing) {
echo $output;
//Print final message
print_simple_box(get_string("restorefinished"),"CENTER");
print_simple_box(get_string("restorefinished"),"center");
} else {
print_simple_box(get_string("importdatafinished"),"CENTER");
print_simple_box(get_string("importdatafinished"),"center");
unset($SESSION->restore);
}
print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
+35 -35
View File
@@ -102,7 +102,7 @@
?>
<script language="JavaScript">
<script language="JavaScript" type="text/javascript">
<!--
function selectItemInMenuByName(formId, menuName, selectIndex ) {
myForm = document.getElementById(formId)
@@ -124,7 +124,7 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
//First, course destination
//Print the full tr
echo "<tr>";
echo "<td align=\"right\"><p><b>";
echo "<td align=\"right\"><b>";
echo get_string("restoreto").":</b>";
echo "</td><td>";
if (isteacheredit($id) and !iscreator()) {
@@ -139,7 +139,7 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
echo "</td></tr>";
//Line
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
//Now, check modules and info and show posibilities
if ($allmods = get_records("modules") ) {
//Print option to select/deselect every "with user info" popup. For Gustav, lol, Eloy :-)
@@ -152,7 +152,7 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
get_string("none")."</a>";
echo "</font></td>";
echo "</tr>";
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
foreach ($allmods as $mod) {
$modname = $mod->name;
$modrestore = $modname."_restore_mods";
@@ -166,9 +166,9 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
if (isset($info->mods[$modname]) && $info->mods[$modname]->backup == "true") {
//Print the full tr
echo "<tr>";
echo "<td align=\"right\"><p><b>";
echo "<td align=\"right\"><b>";
echo get_string("include")." ". get_string("modulenameplural",$modname).":";
echo "</td><td>";
echo "</b></td><td>";
$restore_options[0] = get_string("no");
$restore_options[1] = get_string("yes");
choose_from_menu($restore_options, $restore_var, $$restore_var, "");
@@ -181,33 +181,33 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
} else {
//Module haven't userdata
echo get_string("withoutuserdata");
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
}
echo "</td></tr>";
} else {
//Module isn't restorable
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
}
} else {
//Module isn't restorable
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
}
} else {
//Module isn't restorable
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
}
}
//Line
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
//Now print the Metacourse tr
echo "<tr>";
echo "<td align=\"right\"><p><b>";
echo "<td align=\"right\"><b>";
echo get_string("metacourse").":";
echo "</td><td>";
echo "</b></td><td>";
//If metacourse are in the backup file, show menu, else fixed to no
if ($info->backup_metacourse == "true") {
$metacourse_options[0] = get_string("no");
@@ -215,14 +215,14 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
choose_from_menu($metacourse_options, "restore_metacourse", $restore_metacourse, "");
} else {
echo get_string("no");
echo "<input type=\"hidden\" name=\"restore_metacourse\" value=\"0\">";
echo "<input type=\"hidden\" name=\"restore_metacourse\" value=\"0\" />";
}
echo "</td></tr>";
//Now print the Users tr
echo "<tr>";
echo "<td align=\"right\"><p><b>";
echo "<td align=\"right\"><b>";
echo get_string("users").":";
echo "</td><td>";
echo "</b></td><td>";
//If some user is present in the backup file
if ($info->backup_users == "all" or $info->backup_users == "course") {
//If all users are in the backup file
@@ -234,16 +234,16 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
choose_from_menu($user_options, "restore_users", $restore_users, "");
} else {
echo get_string("none");
echo "<input type=\"hidden\" name=\"restore_users\" value=\"2\">";
echo "<input type=\"hidden\" name=\"restore_users\" value=\"2\" />";
}
echo "</td></tr>";
//Now print the Logs tr
echo "<tr>";
echo "<td align=\"right\"><p><b>";
echo "<td align=\"right\"><b>";
echo get_string("logs").":";
echo "</td><td>";
echo "</b></td><td>";
//If logs are in the backup file, show menu, else fixed to no
if ($info->backup_logs == "true") {
$log_options[0] = get_string("no");
@@ -251,15 +251,15 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
choose_from_menu($log_options, "restore_logs", $restore_logs, "");
} else {
echo get_string("no");
echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\">";
echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\" />";
}
echo "</td></tr>";
//Now print the User Files tr
echo "<tr>";
echo "<td align=\"right\"><p><b>";
echo "<td align=\"right\"><b>";
echo get_string ("userfiles").":";
echo "</td><td>";
echo "</b></td><td>";
//If user files are in the backup file, show menu, else fixed to no
if ($info->backup_user_files == "true") {
$user_file_options[0] = get_string("no");
@@ -267,15 +267,17 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
choose_from_menu($user_file_options, "restore_user_files", $restore_user_files, "");
} else {
echo get_string("no");
echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\">";
echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\" />";
}
echo "</td></tr>";
//Now print the Course Files tr
echo "<tr>";
echo "<td align=\"right\"><p><b>";
echo "<td align=\"right\"><b>";
echo get_string ("coursefiles").":";
echo "</td><td>";
echo "</b></td><td>";
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\" />";
echo "<input type=\"hidden\" name=\"file\" value=\"$file\" />";
//If course files are in the backup file, show menu, else fixed to no
if ($info->backup_course_files == "true") {
$course_file_options[0] = get_string("no");
@@ -283,19 +285,17 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
choose_from_menu($course_file_options, "restore_course_files", $restore_course_files, "");
} else {
echo get_string("no");
echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\">";
echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\" />";
}
echo "</td></tr>";
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\">";
echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
}
?>
</table>
<br />
<center>
<input type="hidden" name="id" value="<?php p($id) ?>">
<input type="hidden" name="launch" value="check">
<input type="submit" value="<?php print_string("continue") ?>">
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>">
<input type="hidden" name="id" value="<?php p($id) ?>" />
<input type="hidden" name="launch" value="check" />
<input type="submit" value="<?php print_string("continue") ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
</center>
</form>
+17 -13
View File
@@ -77,14 +77,16 @@
if (function_exists($function_name)) {
echo "<li>".get_string ("to")." ".get_string("modulenameplural",$name);
$status = $function_name($restore);
echo '</li>';
}
}
}
//Now I'm going to decode to their new location all the links in wiki texts
//having the syntax " modulename:moduleid".
echo "<li>wiki";
echo "<li>Wiki";
$status = restore_decode_wiki_texts($restore);
echo '</li>';
echo "</ul>";
@@ -110,7 +112,7 @@
//FORUM: Decode every POST (message) in the course
//Check we are restoring forums
if ($restore->mods['forum']->restore == 1) {
echo "<li>".get_string("from")." ".get_string("modulenameplural","forum");
echo "<li>".get_string("from")." ".get_string("modulenameplural","forum").'</li>';
//Get all course posts being restored
if ($posts = get_records_sql ("SELECT p.id, p.message
FROM {$CFG->prefix}forum_posts p,
@@ -155,7 +157,7 @@
//Check we are restoring resources
if ($restore->mods['resource']->restore == 1) {
echo "<li>".get_string("from")." ".get_string("modulenameplural","resource");
echo "<li>".get_string("from")." ".get_string("modulenameplural","resource").'</li>';
//Get all course resources of type='text' and options=FORMAT_WIKI being restored
if ($resources = get_records_sql ("SELECT r.id, r.alltext
FROM {$CFG->prefix}resource r,
@@ -355,9 +357,9 @@
$status = true;
if ($info) {
//This is tha align to every ingo table
$table->align = array ("RIGHT","LEFT");
$table->align = array ("right","left");
//This is the nowrap clause
$table->wrap = array ("","NOWRAP");
$table->wrap = array ("","nowrap");
//The width
$table->width = "70%";
//Put interesting info in table
@@ -450,7 +452,7 @@
$status = true;
if ($course_header) {
//This is tha align to every ingo table
$table->align = array ("RIGHT","LEFT");
$table->align = array ("right","left");
//The width
$table->width = "70%";
//Put interesting course header in table
@@ -1708,6 +1710,7 @@
//from backup_ids (calling every mod restore function)
if ($info) {
if ($info !== true) {
echo '<ul>';
//Iterate over each module
foreach ($info as $mod) {
$modrestore = $mod->modtype."_restore_mods";
@@ -1719,6 +1722,7 @@
$status = false;
}
}
echo '</ul>';
}
} else {
$status = false;
@@ -3486,7 +3490,7 @@
//Now check and create the backup dir (if it doesn't exist)
if (empty($silent)) {
echo "<li>".get_string("creatingtemporarystructures");
echo "<li>".get_string("creatingtemporarystructures").'</li>';
}
$status = check_and_create_backup_dir($backup_unique_code);
//Empty dir
@@ -3497,7 +3501,7 @@
//Now delete old data and directories under dataroot/temp/backup
if ($status) {
if (empty($silent)) {
echo "<li>".get_string("deletingolddata");
echo "<li>".get_string("deletingolddata").'</li>';
}
$status = backup_delete_old_data();
}
@@ -3505,7 +3509,7 @@
//Now copy he zip file to dataroot/temp/backup/backup_unique_code
if ($status) {
if (empty($silent)) {
echo "<li>".get_string("copyingzipfile");
echo "<li>".get_string("copyingzipfile").'</li>';
}
if (! $status = backup_copy_file($file,$CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) {
notify("Error copying backup file. Invalid name or bad perms.");
@@ -3515,7 +3519,7 @@
//Now unzip the file
if ($status) {
if (empty($silent)) {
echo "<li>".get_string("unzippingbackup");
echo "<li>".get_string("unzippingbackup").'</li>';
}
if (! $status = restore_unzip ($CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) {
notify("Error unzipping backup file. Invalid zip file.");
@@ -3526,7 +3530,7 @@
if ($status) {
$xml_file = $CFG->dataroot."/temp/backup/".$backup_unique_code."/moodle.xml";
if (empty($silent)) {
echo "<li>".get_string("checkingbackup");
echo "<li>".get_string("checkingbackup").'</li>';
}
if (! $status = restore_check_moodle_file ($xml_file)) {
notify("Error checking backup file. Invalid or corrupted.");
@@ -3539,7 +3543,7 @@
//Now read the info tag (all)
if ($status) {
if (empty($silent)) {
echo "<li>".get_string("readinginfofrombackup");
echo "<li>".get_string("readinginfofrombackup").'</li>';
}
//Reading info from file
$info = restore_read_xml_info ($xml_file);
@@ -3552,7 +3556,7 @@
echo "</ul>";
//End the main table
echo "</tr></td>";
echo "</td></tr>";
echo "</table>";
}
+1 -1
View File
@@ -5,6 +5,6 @@
// database (backup_version) to determine whether upgrades should
// be performed (see db/backup_*.php)
$backup_version = 2005020500; // The current version is a date (YYYYMMDDXX)
$backup_version = 2005020700; // The current version is a date (YYYYMMDDXX)
$backup_release = "1.5 development"; // User-friendly version number