Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added some more error messages when restoring
  • Loading branch information
moodler committed Aug 22, 2003
1 parent 6c2adc0 commit ae5f8de
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions backup/restore_execute.html
Expand Up @@ -60,7 +60,9 @@
//Saving conversion id variables into backup_tables
if ($restore->restoreto == 2) {
echo "<li>".get_string("creatingnewcourse");
$status = restore_create_new_course($restore,$course_header);
if (!$status = restore_create_new_course($restore,$course_header)) {
notify("Error while creating the new empty course.");
}
//Print course fullname and shortname and category
if ($status) {
echo "<ul>";
Expand Down Expand Up @@ -97,6 +99,7 @@
}
}
} else {
notify("Error opening existing course.");
$status = false;
}
}
Expand All @@ -106,13 +109,18 @@
//Into new course
if ($restore->restoreto == 2) {
echo "<li>".get_string("creatingsections");
$status = restore_create_sections($restore,$xml_file);
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");
$status = restore_create_sections($restore,$xml_file);
if (!$status = restore_create_sections($restore,$xml_file)) {
notify("Error creating sections in the existing course.");
}
//Error
} else {
notify("Neither a new course or an existing one was specified.");
$status = false;
}
}
Expand All @@ -121,7 +129,9 @@
//Now create users as needed
if ($status and ($restore->users == 0 or $restore->users == 1)) {
echo "<li>".get_string("creatingusers")."<br>";
$status = restore_create_users($restore,$xml_file);
if (!$status = restore_create_users($restore,$xml_file)) {
notify("Could not restore users.");
}
//Now print info about the work done
if ($status) {
$recs = get_records_sql("select old_id, new_id from {$CFG->prefix}backup_ids
Expand Down Expand Up @@ -178,7 +188,7 @@
echo "<li>".get_string("other").": ".$other_count;
echo "</ul>";
} else {
//Something is wrong. There is no users !!
notify("Something is wrong - no users were found!");
$status = false;
}
}
Expand All @@ -187,13 +197,17 @@
//Now create categories and questions as needed (STEP1)
if ($status and ($restore->mods[quiz]->restore)) {
echo "<li>".get_string("creatingcategoriesandquestions")."<br>";
$status = restore_create_questions($restore,$xml_file);
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>";
$status = restore_user_files($restore);
if (!$status = restore_user_files($restore)) {
notify("Could not restore user files!");
}
//If all is ok (and we have a counter)
if ($status and ($status !== true)) {
//Inform about user dirs created from backup
Expand All @@ -206,7 +220,9 @@
//Now create course files as needed
if ($status and ($restore->course_files)) {
echo "<li>".get_string("copyingcoursefiles")."<br>";
$status = restore_course_files($restore);
if (!$status = restore_course_files($restore)) {
notify("Could not restore course files!");
}
//If all is ok (and we have a counter)
if ($status and ($status !== true)) {
//Inform about user dirs created from backup
Expand All @@ -219,13 +235,17 @@
//Now create scales as needed
if ($status) {
echo "<li>".get_string("creatingscales");
$status = restore_create_scales($restore,$xml_file);
if (!$status = restore_create_scales($restore,$xml_file)) {
notify("Could not restore custom scales!");
}
}

//Now create course modules as needed
if ($status) {
echo "<li>".get_string("creatingcoursemodules");
$status = restore_create_modules($restore,$xml_file);
if (!$status = restore_create_modules($restore,$xml_file)) {
notify("Could not restore custom scales!");
}
}

//Now create log entries as needed
Expand All @@ -236,7 +256,9 @@
//Now, if all is OK, adjust the instance field in course_modules !!
if ($status) {
echo "<li>".get_string("checkinginstances");
$status = restore_check_instances($restore);
if (!$status = restore_check_instances($restore)) {
notify("Could not adjust instances in course_modules!");
}
}

//Now if all is OK, update:
Expand All @@ -254,7 +276,9 @@
//Cleanup temps (files and db)
if ($status) {
echo "<li>".get_string("cleaningtempdata");
$status = clean_temp_data ($restore);
if (!$status = clean_temp_data ($restore)) {
notify("Could not clean up temporary data from files and database");
}
}

//End the main ul
Expand All @@ -266,7 +290,7 @@
echo "</table>";

if (!$status) {
error ("An error has ocurred");
error ("An error has occurred and the restore could not be completed!");
}

//Print final message
Expand Down

0 comments on commit ae5f8de

Please sign in to comment.