replacing fieldsets with divs for small forms
[moodle.git] / backup / restore_execute.html
CommitLineData
7ef0797d 1<?php //$Id$
a2c7397c 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
5
6 //Get objects from session
7 if ($SESSION) {
8 $info = $SESSION->info;
9 $course_header = $SESSION->course_header;
10 $restore = $SESSION->restore;
11 }
12
c9c89845 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;
80578821 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;
c9c89845 19
a2c7397c 20 //Check login
21 require_login();
22
23 //Check admin
be2a6fc6 24 if (!empty($id)) {
0fd332a8 25 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
873bf875 26 if (empty($to)) {
27 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
28 } else {
cfd6b505 29 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))) {
873bf875 30 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
31 }
32 }
be2a6fc6 33 }
34 } else {
ec7a8b79 35 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
be2a6fc6 36 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
37 }
a2c7397c 38 }
39
40 //Check site
41 if (!$site = get_site()) {
42 error("Site not found!");
43 }
f90666aa 44 $errorstr = '';
3f1c7233 45
f90666aa 46 $status = restore_execute($restore,$info,$course_header,$errorstr);
a2c7397c 47
48 if (!$status) {
ae5f8de6 49 error ("An error has occurred and the restore could not be completed!");
a2c7397c 50 }
51
410c459d 52 if (empty($restore->importing)) {
873bf875 53 //Print final message
1bbf415f 54 print_simple_box(get_string("restorefinished"),"center");
873bf875 55 } else {
1bbf415f 56 print_simple_box(get_string("importdatafinished"),"center");
873bf875 57 unset($SESSION->restore);
58 }
9c1ae5ae 59 print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
11c1d525 60
a2c7397c 61?>