|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 //This script is used to configure and execute the restore proccess. 00003 00004 require_once('../config.php'); 00005 require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); 00006 00007 $contextid = required_param('contextid', PARAM_INT); 00008 $stage = optional_param('stage', restore_ui::STAGE_CONFIRM, PARAM_INT); 00009 00010 list($context, $course, $cm) = get_context_info_array($contextid); 00011 00012 navigation_node::override_active_url(new moodle_url('/backup/restorefile.php', array('contextid'=>$contextid))); 00013 $PAGE->set_url(new moodle_url('/backup/restore.php', array('contextid'=>$contextid))); 00014 $PAGE->set_context($context); 00015 $PAGE->set_pagelayout('standard'); 00016 00017 require_login($course, null, $cm); 00018 require_capability('moodle/restore:restorecourse', $context); 00019 00020 if ($stage & restore_ui::STAGE_CONFIRM + restore_ui::STAGE_DESTINATION) { 00021 $restore = restore_ui::engage_independent_stage($stage, $contextid); 00022 } else { 00023 $restoreid = optional_param('restore', false, PARAM_ALPHANUM); 00024 $rc = restore_ui::load_controller($restoreid); 00025 if (!$rc) { 00026 $restore = restore_ui::engage_independent_stage($stage/2, $contextid); 00027 if ($restore->process()) { 00028 $rc = new restore_controller($restore->get_filepath(), $restore->get_course_id(), backup::INTERACTIVE_YES, 00029 backup::MODE_GENERAL, $USER->id, $restore->get_target()); 00030 } 00031 } 00032 if ($rc) { 00033 // check if the format conversion must happen first 00034 if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) { 00035 $rc->convert(); 00036 } 00037 00038 $restore = new restore_ui($rc, array('contextid'=>$context->id)); 00039 } 00040 } 00041 00042 $outcome = $restore->process(); 00043 if (!$restore->is_independent()) { 00044 if ($restore->get_stage() == restore_ui::STAGE_PROCESS && !$restore->requires_substage()) { 00045 try { 00046 $restore->execute(); 00047 } catch(Exception $e) { 00048 $restore->cleanup(); 00049 throw $e; 00050 } 00051 } else { 00052 $restore->save_controller(); 00053 } 00054 } 00055 $heading = $course->fullname; 00056 00057 $PAGE->set_title($heading.': '.$restore->get_stage_name()); 00058 $PAGE->set_heading($heading); 00059 $PAGE->navbar->add($restore->get_stage_name()); 00060 00061 $renderer = $PAGE->get_renderer('core','backup'); 00062 echo $OUTPUT->header(); 00063 if (!$restore->is_independent() && $restore->enforce_changed_dependencies()) { 00064 echo $renderer->dependency_notification(get_string('dependenciesenforced','backup')); 00065 } 00066 echo $renderer->progress_bar($restore->get_progress_bar()); 00067 echo $restore->display($renderer); 00068 $restore->destroy(); 00069 unset($restore); 00070 echo $OUTPUT->footer();