Ejemplo n.º 1
0
// Backup of large courses requires extra memory. Use the amount configured
// in admin settings.
raise_memory_limit(MEMORY_EXTRA);
if (!($bc = backup_ui::load_controller($backupid))) {
    $bc = new backup_controller($type, $id, backup::FORMAT_MOODLE, backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id);
}
$backup = new backup_ui($bc);
$PAGE->set_title($heading);
$PAGE->set_heading($heading);
$renderer = $PAGE->get_renderer('core', 'backup');
echo $OUTPUT->header();
// Prepare a progress bar which can display optionally during long-running
// operations while setting up the UI.
$slowprogress = new \core\progress\display_if_slow(get_string('preparingui', 'backup'));
$previous = optional_param('previous', false, PARAM_BOOL);
if ($backup->get_stage() == backup_ui::STAGE_SCHEMA && !$previous) {
    // After schema stage, we are probably going to get to the confirmation stage,
    // The confirmation stage has 2 sets of progress, so this is needed to prevent
    // it showing 2 progress bars.
    $twobars = true;
    $slowprogress->start_progress('', 2);
} else {
    $twobars = false;
}
$backup->get_controller()->set_progress($slowprogress);
$backup->process();
if ($backup->enforce_changed_dependencies()) {
    debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
}
$loghtml = '';
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
Ejemplo n.º 2
0
if (!has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, $id)) or !confirm_sesskey()) {
    throw new moodle_exception('nopermission');
}
//page settings
$PAGE->set_url('/course/publish/backup.php');
$PAGE->set_pagelayout('course');
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
//BEGIN backup processing
$backupid = optional_param('backup', false, PARAM_ALPHANUM);
if (!($bc = backup_ui::load_controller($backupid))) {
    $bc = new backup_controller(backup::TYPE_1COURSE, $id, backup::FORMAT_MOODLE, backup::INTERACTIVE_YES, backup::MODE_HUB, $USER->id);
}
$backup = new backup_ui($bc, array('id' => $id, 'hubcourseid' => $hubcourseid, 'huburl' => $huburl, 'hubname' => $hubname));
$backup->process();
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
    $backup->execute();
} else {
    $backup->save_controller();
}
if ($backup->get_stage() !== backup_ui::STAGE_COMPLETE) {
    $renderer = $PAGE->get_renderer('core', 'backup');
    echo $OUTPUT->header();
    echo $OUTPUT->heading(get_string('publishcourseon', 'hub', !empty($hubname) ? $hubname : $huburl), 3, 'main');
    if ($backup->enforce_changed_dependencies()) {
        echo $renderer->dependency_notification(get_string('dependenciesenforced', 'backup'));
    }
    echo $renderer->progress_bar($backup->get_progress_bar());
    echo $backup->display();
    echo $OUTPUT->footer();
    die;
Ejemplo n.º 3
0
            $PAGE->navbar->add(get_string('section') . ' ' . $section->section);
        }
        break;
    case backup::TYPE_1ACTIVITY:
        require_capability('moodle/backup:backupactivity', get_context_instance(CONTEXT_MODULE, $cm->id));
        $heading = get_string('backupactivity', 'backup', $cm->name);
        break;
    default:
        print_error('unknownbackuptype');
}
if (!($bc = backup_ui::load_controller($backupid))) {
    $bc = new backup_controller($type, $id, backup::FORMAT_MOODLE, backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id);
}
$backup = new backup_ui($bc);
$backup->process();
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
    $backup->execute();
} else {
    $backup->save_controller();
}
$PAGE->set_title($heading . ': ' . $backup->get_stage_name());
$PAGE->set_heading($heading);
$PAGE->navbar->add($backup->get_stage_name());
$renderer = $PAGE->get_renderer('core', 'backup');
echo $OUTPUT->header();
if ($backup->enforce_changed_dependencies()) {
    debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display($renderer);
$backup->destroy();