mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
51 lines
1.5 KiB
HTML
51 lines
1.5 KiB
HTML
<?php // $Id$
|
|
//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/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
|
|
if (empty($to)) {
|
|
print_error("cannotuseadminadminorteacher", '', $loginurl);
|
|
} else {
|
|
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
|
|
&& !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) {
|
|
print_error("cannotuseadminadminorteacher", '', $loginurl);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
|
|
print_error("cannotuseadmin", '', $loginurl);
|
|
}
|
|
}
|
|
|
|
//Check site
|
|
if (!$site = get_site()) {
|
|
print_error("siteisnotdefined", 'debug');
|
|
}
|
|
|
|
$errorstr = '';
|
|
if (!empty($SESSION->restore->importing)) {
|
|
define('RESTORE_SILENTLY',true);
|
|
}
|
|
$status = restore_precheck($id,$file,$errorstr);
|
|
|
|
if (!$status) {
|
|
print_error("pleasereport");
|
|
}
|
|
|
|
?>
|