MDL-27595 backup: allow course import with warnings
Proceed with import if warnings are found, but display the warnings afterwards
This commit is contained in:
+29
-14
@@ -113,31 +113,46 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||
// Mark the UI finished.
|
||||
$rc->finish_ui();
|
||||
// Execute prechecks
|
||||
$warnings = false;
|
||||
if (!$rc->execute_precheck()) {
|
||||
$precheckresults = $rc->get_precheck_results();
|
||||
if (is_array($precheckresults) && !empty($precheckresults['errors'])) {
|
||||
fulldelete($tempdestination);
|
||||
if (is_array($precheckresults)) {
|
||||
if (!empty($precheckresults['errors'])) { // If errors are found, terminate the import.
|
||||
fulldelete($tempdestination);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $renderer->precheck_notices($precheckresults);
|
||||
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
echo $OUTPUT->header();
|
||||
echo $renderer->precheck_notices($precheckresults);
|
||||
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
if (!empty($precheckresults['warnings'])) { // If warnings are found, go ahead but display warnings later.
|
||||
$warnings = $precheckresults['warnings'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($restoretarget == backup::TARGET_CURRENT_DELETING || $restoretarget == backup::TARGET_EXISTING_DELETING) {
|
||||
restore_dbops::delete_course_content($course->id);
|
||||
}
|
||||
// Execute the restore
|
||||
$rc->execute_plan();
|
||||
}
|
||||
if ($restoretarget == backup::TARGET_CURRENT_DELETING || $restoretarget == backup::TARGET_EXISTING_DELETING) {
|
||||
restore_dbops::delete_course_content($course->id);
|
||||
}
|
||||
// Execute the restore.
|
||||
$rc->execute_plan();
|
||||
|
||||
// Delete the temp directory now
|
||||
fulldelete($tempdestination);
|
||||
|
||||
// Display a notification and a continue button
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->notification(get_string('importsuccess', 'backup'),'notifysuccess');
|
||||
if ($warnings) {
|
||||
echo $OUTPUT->box_start();
|
||||
echo $OUTPUT->notification(get_string('warning'), 'notifywarning');
|
||||
echo html_writer::start_tag('ul', array('class'=>'list'));
|
||||
foreach ($warnings as $warning) {
|
||||
echo html_writer::tag('li', $warning);
|
||||
}
|
||||
echo html_writer::end_tag('ul');
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->notification(get_string('importsuccess', 'backup'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user