$visiblesettings = false; foreach ($settings as $setting) { if ($setting->get_status() !== backup_setting::NOT_LOCKED) { $setting->set_visibility(backup_setting::HIDDEN); } else { $visiblesettings = true; } } 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