MDL-22449 help string update
[moodle.git] / backup / restore_execute.html
blob4f051c141f77136c48b76ee3ec0a5df7bc8e0360
1 <?php
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
7 if ($SESSION) {
8 $info = $SESSION->info;
9 $course_header = $SESSION->course_header;
10 $restore = $SESSION->restore;
12 // Validate objects from session by checking their checksums
13 $status = false;
14 if (isset($SESSION->restore_checksums)) {
15 $checksums = $SESSION->restore_checksums;
16 if (isset($checksums['info']) && $checksums['info'] == md5(serialize($info)) &&
17 isset($checksums['course_header']) && $checksums['course_header'] == md5(serialize($course_header)) &&
18 isset($checksums['restore']) && $checksums['restore'] == md5(serialize($restore))) {
20 $status = true; // All session checksums were or, we can rely on that to continue restoring
23 if(!$status) { // Something was wrong checking objects from session, abort with error
24 print_error('restorechecksumfailed');
28 //Add info->original_wwwroot to $restore to be able to use it in all the restore process
29 //(mainly when decoding internal links)
30 $restore->original_wwwroot = $info->original_wwwroot;
31 // Copy $info->original_siteidentifier, is present, so backup_is_same_site can work.
32 if (isset($info->original_siteidentifier)) {
33 $restore->original_siteidentifier = $info->original_siteidentifier;
35 //Add info->backup_version to $restore to be able to detect versions in the restore process
36 //(to decide when to convert wiki texts to markdown...)
37 $restore->backup_version = $info->backup_backup_version;
39 //Check login
40 require_login();
42 $loginurl = get_login_url();
44 //Check admin
45 if (!empty($id)) {
46 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
47 if (empty($to)) {
48 print_error("cannotuseadminadminorteacher", '', $loginurl);
49 } else {
50 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $to))
51 && !has_capability('moodle/restore:restoretargetimport', get_context_instance(CONTEXT_COURSE, $to))) {
52 print_error("cannotuseadminadminorteacher", '', $loginurl);
56 } else {
57 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
58 print_error("cannotuseadmin", '', $loginurl);
62 //Check site
63 $site = get_site();
64 $errorstr = '';
66 $status = restore_execute($restore,$info,$course_header,$errorstr);
68 if (!$status) {
69 print_error ("cannotrestore");
72 if (empty($restore->importing)) {
73 //Print final message
74 echo $OUTPUT->box(get_string("restorefinished"));
75 } else {
76 echo $OUTPUT->box(get_string("importdatafinished"));
77 $file = $CFG->dataroot . '/'
78 . $SESSION->import_preferences->backup_course
79 . '/backupdata/' . $SESSION->import_preferences->backup_name;
80 if (is_readable($file)) {
81 unlink($file);
83 else {
84 error_log("import course data: couldn't unlink $file");
86 unset($SESSION->restore);
88 echo $OUTPUT->continue_button("$CFG->wwwroot/course/view.php?id=".$restore->course_id);