forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restore_precheck.html
46 lines (39 loc) · 1.45 KB
/
restore_precheck.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
//This page copies th zip to the temp directory,
//unzip it, check that it is a valid backup file
//inform about its contents and fill all the necesary
//variables to continue with the restore.
//Checks we have the file variable
if (!isset($file)) {
print_error('nofile');
}
//Check login
require_login();
$loginurl = get_login_url();
//Check admin
if (!empty($id)) {
if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
print_error("cannotuseadminadminorteacher", '', $loginurl);
} else {
if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $to))
&& !has_capability('moodle/restore:restoretargetimport', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("cannotuseadminadminorteacher", '', $loginurl);
}
}
}
} else {
if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
print_error("cannotuseadmin", '', $loginurl);
}
}
//Check site
$site = get_site();
$errorstr = '';
if (!empty($SESSION->restore->importing)) {
define('RESTORE_SILENTLY',true);
}
$status = restore_precheck($id,$file,$errorstr);
if (!$status) {
print_error("pleasereport");
}