MDL-24203 unused string removed
[moodle.git] / backup / restore_precheck.html
CommitLineData
795b6945 1<?php
b9846a9b 2 //This page copies th zip to the temp directory,
3 //unzip it, check that it is a valid backup file
4 //inform about its contents and fill all the necesary
5 //variables to continue with the restore.
6
7 //Checks we have the file variable
795b6945 8 if (!isset($file)) {
771dc7b2 9 print_error('nofile');
b9846a9b 10 }
11
795b6945 12 //Check login
c563a9a0 13 require_login();
93f66983 14
15 $loginurl = get_login_url();
16
c563a9a0 17 //Check admin
9e426d54 18 if (!empty($id)) {
d2940003 19 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
873bf875 20 if (empty($to)) {
93f66983 21 print_error("cannotuseadminadminorteacher", '', $loginurl);
873bf875 22 } else {
d2940003 23 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $to))
157aa3a2 24 && !has_capability('moodle/restore:restoretargetimport', get_context_instance(CONTEXT_COURSE, $to))) {
93f66983 25 print_error("cannotuseadminadminorteacher", '', $loginurl);
873bf875 26 }
27 }
9e426d54 28 }
29 } else {
d2940003 30 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
93f66983 31 print_error("cannotuseadmin", '', $loginurl);
9e426d54 32 }
c563a9a0 33 }
34
35 //Check site
3f77c158 36 $site = get_site();
c563a9a0 37
f90666aa 38 $errorstr = '';
39 if (!empty($SESSION->restore->importing)) {
40 define('RESTORE_SILENTLY',true);
41 }
42 $status = restore_precheck($id,$file,$errorstr);
795b6945 43
76bf541d 44 if (!$status) {
d3b7ea93 45 print_error("pleasereport");
fd43f7d0 46 }