2009-11-01 15:39:15 +00:00
|
|
|
<?php
|
2003-05-16 21:52:49 +00:00
|
|
|
//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
|
2009-11-01 15:39:15 +00:00
|
|
|
if (!isset($file)) {
|
2008-12-12 05:45:43 +00:00
|
|
|
print_error('nofile');
|
2003-05-16 21:52:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-01 15:39:15 +00:00
|
|
|
//Check login
|
2003-05-18 17:15:05 +00:00
|
|
|
require_login();
|
2009-01-02 22:56:48 +00:00
|
|
|
|
|
|
|
$loginurl = get_login_url();
|
|
|
|
|
2003-05-18 17:15:05 +00:00
|
|
|
//Check admin
|
2003-08-02 16:06:33 +00:00
|
|
|
if (!empty($id)) {
|
2010-02-19 17:50:14 +00:00
|
|
|
if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
2009-01-02 22:56:48 +00:00
|
|
|
print_error("cannotuseadminadminorteacher", '', $loginurl);
|
2005-01-27 02:35:10 +00:00
|
|
|
} else {
|
2010-02-19 17:50:14 +00:00
|
|
|
if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $to))
|
2010-02-19 19:11:06 +00:00
|
|
|
&& !has_capability('moodle/restore:restoretargetimport', get_context_instance(CONTEXT_COURSE, $to))) {
|
2009-01-02 22:56:48 +00:00
|
|
|
print_error("cannotuseadminadminorteacher", '', $loginurl);
|
2005-01-27 02:35:10 +00:00
|
|
|
}
|
|
|
|
}
|
2003-08-02 16:06:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
2010-02-19 17:50:14 +00:00
|
|
|
if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
|
2009-01-02 22:56:48 +00:00
|
|
|
print_error("cannotuseadmin", '', $loginurl);
|
2003-08-02 16:06:33 +00:00
|
|
|
}
|
2003-05-18 17:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Check site
|
2009-11-01 09:10:09 +00:00
|
|
|
$site = get_site();
|
2003-05-18 17:15:05 +00:00
|
|
|
|
2006-01-15 21:09:13 +00:00
|
|
|
$errorstr = '';
|
|
|
|
if (!empty($SESSION->restore->importing)) {
|
|
|
|
define('RESTORE_SILENTLY',true);
|
|
|
|
}
|
|
|
|
$status = restore_precheck($id,$file,$errorstr);
|
2009-11-01 15:39:15 +00:00
|
|
|
|
2003-05-18 15:51:20 +00:00
|
|
|
if (!$status) {
|
2008-05-08 08:43:17 +00:00
|
|
|
print_error("pleasereport");
|
2003-05-17 17:34:30 +00:00
|
|
|
}
|