moodle/backup/restore_execute.html

62 lines
2.2 KiB
HTML
Raw Normal View History

2004-09-12 01:34:24 +00:00
<?php //$Id$
//This page receives the required info and executes the restore
//with the parameters suplied. Whe finished, delete temporary
//data from backup_tables and temp directory
//Get objects from session
if ($SESSION) {
$info = $SESSION->info;
$course_header = $SESSION->course_header;
$restore = $SESSION->restore;
}
//Add info->original_wwwroot to $restore to be able to use it in all the restore process
//(mainly when decoding internal links)
$restore->original_wwwroot = $info->original_wwwroot;
//Add info->backup_version to $restore to be able to detect versions in the restore process
//(to decide when to convert wiki texts to markdown...)
$restore->backup_version = $info->backup_backup_version;
//Check login
require_login();
//Check admin
if (!empty($id)) {
2006-09-19 07:16:04 +00:00
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
} else {
2006-09-26 01:11:53 +00:00
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))) {
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
}
}
} else {
2006-09-07 08:57:56 +00:00
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
error("Site not found!");
}
$errorstr = '';
$status = restore_execute($restore,$info,$course_header,$errorstr);
if (!$status) {
error ("An error has occurred and the restore could not be completed!");
}
if (empty($restore->importing)) {
//Print final message
2005-02-07 23:28:52 +00:00
print_simple_box(get_string("restorefinished"),"center");
} else {
2005-02-07 23:28:52 +00:00
print_simple_box(get_string("importdatafinished"),"center");
unset($SESSION->restore);
}
print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
2003-07-07 18:46:36 +00:00
?>