moodle/backup/restore_precheck.html

47 lines
1.5 KiB
HTML

<?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");
}