2 //This page receives the required info and executes the restore
3 //with the parameters suplied. Whe finished, delete temporary
4 //data from backup_tables and temp directory
6 //Get objects from session
8 $info = $SESSION->info
;
9 $course_header = $SESSION->course_header
;
10 $restore = $SESSION->restore
;
13 //Add info->original_wwwroot to $restore to be able to use it in all the restore process
14 //(mainly when decoding internal links)
15 $restore->original_wwwroot
= $info->original_wwwroot
;
16 //Add info->backup_version to $restore to be able to detect versions in the restore process
17 //(to decide when to convert wiki texts to markdown...)
18 $restore->backup_version
= $info->backup_backup_version
;
25 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE
, $id))) {
27 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
29 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE
, $to))) {
30 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
35 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM
, SITEID
))) {
36 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
41 if (!$site = get_site()) {
42 error("Site not found!");
46 $status = restore_execute($restore,$info,$course_header,$errorstr);
49 error ("An error has occurred and the restore could not be completed!");
52 if (empty($restore->importing
)) {
54 print_simple_box(get_string("restorefinished"),"center");
56 print_simple_box(get_string("importdatafinished"),"center");
57 $file = $CFG->dataroot
. '/'
58 . $SESSION->import_preferences
->backup_course
59 . '/backupdata/' . $SESSION->import_preferences
->backup_name
;
60 if (is_readable($file)) {
64 error_log("import course data: couldn't unlink $file");
66 unset($SESSION->restore
);
68 print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id
);