コード例 #1
0
ファイル: restore.php プロジェクト: alanaipe2015/moodle
    $restore = restore_ui::engage_independent_stage($stage, $contextid);
} else {
    $restoreid = optional_param('restore', false, PARAM_ALPHANUM);
    $rc = restore_ui::load_controller($restoreid);
    if (!$rc) {
        $restore = restore_ui::engage_independent_stage($stage / 2, $contextid);
        if ($restore->process()) {
            $rc = new restore_controller($restore->get_filepath(), $restore->get_course_id(), backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id, $restore->get_target());
        }
    }
    if ($rc) {
        // check if the format conversion must happen first
        if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
            $rc->convert();
        }
        $restore = new restore_ui($rc, array('contextid' => $context->id));
    }
}
// End progress section for loading restore controller.
$slowprogress->end_progress();
// This progress section is for the 'process' function below.
$slowprogress->start_progress('', 1, 9);
// Depending on the code branch above, $restore may be a restore_ui or it may
// be a restore_ui_independent_stage. Either way, this function exists.
$restore->set_progress_reporter($slowprogress);
$outcome = $restore->process();
if (!$restore->is_independent() && $restore->enforce_changed_dependencies()) {
    debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
}
$loghtml = '';
// Finish the 'process' progress reporting section, and the overall count.
コード例 #2
0
ファイル: restore.php プロジェクト: Burick/moodle
    $restore = restore_ui::engage_independent_stage($stage, $contextid);
} else {
    $restoreid = optional_param('restore', false, PARAM_ALPHANUM);
    $rc = restore_ui::load_controller($restoreid);
    if (!$rc) {
        $restore = restore_ui::engage_independent_stage($stage / 2, $contextid);
        if ($restore->process()) {
            $rc = new restore_controller($restore->get_filepath(), $restore->get_course_id(), backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id, $restore->get_target());
        }
    }
    if ($rc) {
        // check if the format conversion must happen first
        if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
            $rc->convert();
        }
        $restore = new restore_ui($rc, array('contextid' => $context->id));
    }
}
$outcome = $restore->process();
if (!$restore->is_independent()) {
    if ($restore->get_stage() == restore_ui::STAGE_PROCESS && !$restore->requires_substage()) {
        try {
            $restore->execute();
        } catch (Exception $e) {
            $restore->cleanup();
            throw $e;
        }
    } else {
        $restore->save_controller();
    }
}
コード例 #3
0
require_once $CFG->dirroot . '/backup/util/includes/restore_includes.php';
$contextid = required_param('contextid', PARAM_INT);
$stage = optional_param('stage', restore_ui::STAGE_CONFIRM, PARAM_INT);
list($context, $course, $cm) = get_context_info_array($contextid);
navigation_node::override_active_url(new moodle_url('/backup/restorefile.php', array('contextid' => $contextid)));
$PAGE->set_url(new moodle_url('/backup/restore.php', array('contextid' => $contextid)));
$PAGE->set_context($context);
$PAGE->set_pagelayout('standard');
require_login($course, null, $cm);
require_capability('moodle/restore:restorecourse', $context);
if ($stage & restore_ui::STAGE_CONFIRM + restore_ui::STAGE_DESTINATION) {
    $restore = restore_ui::engage_independent_stage($stage, $contextid);
} else {
    if ($_POST['searchcourses'] || !$_POST['targetid']) {
        // $restore = restore_ui::engage_independent_stage($stage, $contextid);
        $restore = restore_ui::engage_independent_stage(restore_ui::STAGE_DESTINATION, $contextid);
        $restore->process();
    } else {
        $target = required_param('target', PARAM_INT);
        $filepath = $_SESSION['filepath'];
        if ($target == backup::TARGET_NEW_COURSE) {
            $transaction = $DB->start_delegated_transaction();
            $targetid = required_param('targetid', PARAM_INT);
            list($fullname, $shortname) = restore_dbops::calculate_course_names($course->id, get_string('restoringcourse', 'backup'), get_string('restoringcourseshortname', 'backup'));
            $courseid = restore_dbops::create_new_course($fullname, $shortname, $targetid);
            $controller = new restore_controller($filepath, $courseid, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id, $target);
            $controller->execute_precheck();
            $controller->execute_plan();
            $transaction->allow_commit();
        } elseif ($target == backup::TARGET_CURRENT_DELETING || $target == backup::TARGET_CURRENT_ADDING) {
            $transaction = $DB->start_delegated_transaction();