2 //This script is used to configure and execute the restore proccess.
4 require_once('../config.php');
5 require_once($CFG->dirroot
. '/backup/util/includes/restore_includes.php');
7 $contextid = required_param('contextid', PARAM_INT
);
8 $stage = optional_param('stage', restore_ui
::STAGE_CONFIRM
, PARAM_INT
);
10 list($context, $course, $cm) = get_context_info_array($contextid);
12 $PAGE->set_url(new moodle_url('/backup/restore.php', array('contextid'=>$contextid)));
13 navigation_node
::override_active_url(new moodle_url('/backup/restore.php', array('contextid'=>$contextid)));
14 $PAGE->set_context($context);
15 $PAGE->set_pagelayout('standard');
17 require_login($course, null, $cm);
18 require_capability('moodle/restore:restorecourse', $context);
20 $isfrontpage = ($course->id
== SITEID
);
22 if ($stage & restore_ui
::STAGE_CONFIRM + restore_ui
::STAGE_DESTINATION
) {
23 $restore = restore_ui
::engage_independent_stage($stage, $contextid);
25 $restoreid = optional_param('restore', false, PARAM_ALPHANUM
);
26 $rc = restore_ui
::load_controller($restoreid);
28 $restore = restore_ui
::engage_independent_stage($stage/2, $contextid);
29 if ($restore->process()) {
30 $rc = new restore_controller($restore->get_filepath(), $restore->get_course_id(), backup
::INTERACTIVE_YES
,
31 backup
::MODE_GENERAL
, $USER->id
, $restore->get_target());
35 $restore = new restore_ui($rc, array('contextid'=>$context->id
));
38 $outcome = $restore->process();
39 if (!$restore->is_independent()) {
40 if ($restore->get_stage() == restore_ui
::STAGE_PROCESS
&& !$restore->requires_substage()) {
43 $restore->save_controller();
46 $heading = $course->fullname
;
48 $PAGE->set_title($heading.': '.$restore->get_stage_name());
49 $PAGE->set_heading($heading);
50 $PAGE->navbar
->add($restore->get_stage_name());
52 $renderer = $PAGE->get_renderer('core','backup');
53 echo $OUTPUT->header();
54 if (!$restore->is_independent() && $restore->enforce_changed_dependencies()) {
55 echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
57 echo $renderer->progress_bar($restore->get_progress_bar());
58 echo $restore->display($renderer);
59 echo $OUTPUT->footer();