} } import_ui::skip_current_stage(!$visiblesettings); } // Prepare the import UI $backup = new import_ui($bc, array('importid' => $importcourse->id, 'target' => $restoretarget)); // Process the current stage $backup->process(); // If this is the confirmation stage remove the filename setting if ($backup->get_stage() == backup_ui::STAGE_CONFIRMATION) { $backup->get_setting('filename')->set_visibility(backup_setting::HIDDEN); } // If it's the final stage process the import if ($backup->get_stage() == backup_ui::STAGE_FINAL) { // First execute the backup $backup->execute(); $backup->destroy(); unset($backup); // Check whether the backup directory still exists. If missing, something // went really wrong in backup, throw error. Note that backup::MODE_IMPORT // backups don't store resulting files ever $tempdestination = $CFG->tempdir . '/backup/' . $backupid; if (!file_exists($tempdestination) || !is_dir($tempdestination)) { print_error('unknownbackupexporterror'); // shouldn't happen ever } // Prepare the restore controller. We don't need a UI here as we will just use what // ever the restore has (the user has just chosen). $rc = new restore_controller($backupid, $course->id, backup::INTERACTIVE_YES, backup::MODE_IMPORT, $USER->id, $restoretarget); // Convert the backup if required.... it should NEVER happed if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {