Beispiel #1
0
    $bc->get_plan()->get_setting('users')->set_status(backup_setting::LOCKED_BY_CONFIG);
    $settings = $bc->get_plan()->get_settings();
    // For the initial stage we want to hide all locked settings and if there are
    // no visible settings move to the next stage
    $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
Beispiel #2
0
    $bc->get_plan()->get_setting('users')->set_status(backup_setting::LOCKED_BY_CONFIG);
    $settings = $bc->get_plan()->get_settings();
    // For the initial stage we want to hide all locked settings and if there are
    // no visible settings move to the next stage
    $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) {
    echo $OUTPUT->header();
    // Display an extra progress bar so that we can show the current stage.
    echo html_writer::start_div('', array('id' => 'executionprogress'));
    echo $renderer->progress_bar($backup->get_progress_bar());
    // Start the progress display - we split into 2 chunks for backup and restore.
    $progress = new core_backup_display_progress();
    $progress->start_progress('', 2);