2004-09-12 01:34:24 +00:00
|
|
|
<?php //$Id$
|
2003-05-17 08:56:53 +00:00
|
|
|
//This script is used to configure and execute the restore proccess.
|
2003-05-14 23:25:00 +00:00
|
|
|
|
|
|
|
//Define some globals for all the script
|
|
|
|
|
|
|
|
//Units used
|
2003-08-01 14:34:11 +00:00
|
|
|
require_once ("../config.php");
|
|
|
|
require_once ("../lib/xmlize.php");
|
|
|
|
require_once ("../course/lib.php");
|
2003-05-14 23:25:00 +00:00
|
|
|
require_once ("lib.php");
|
|
|
|
require_once ("restorelib.php");
|
2005-02-08 07:19:49 +00:00
|
|
|
require_once ("bb/restore_bb.php");
|
2004-04-18 23:20:53 +00:00
|
|
|
require_once("$CFG->libdir/blocklib.php");
|
2005-04-12 23:40:40 +00:00
|
|
|
require_once("$CFG->libdir/wiki_to_markdown.php" );
|
2003-05-14 23:25:00 +00:00
|
|
|
|
2003-05-16 21:52:49 +00:00
|
|
|
//Optional
|
2003-08-02 16:06:33 +00:00
|
|
|
optional_variable($id);
|
2003-05-16 21:52:49 +00:00
|
|
|
optional_variable($file);
|
2003-08-24 14:46:52 +00:00
|
|
|
optional_variable($cancel);
|
|
|
|
optional_variable($launch);
|
2005-01-27 02:35:10 +00:00
|
|
|
optional_variable($to);
|
2003-05-14 23:25:00 +00:00
|
|
|
|
|
|
|
//Check login
|
|
|
|
require_login();
|
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
if (!$to && isset($SESSION->restore->restoreto) && isset($SESSION->restore->importing) && isset($SESSION->restore->course_id)) {
|
|
|
|
$to = $SESSION->restore->course_id;
|
|
|
|
}
|
|
|
|
|
2003-08-02 16:06:33 +00:00
|
|
|
if (!empty($id)) {
|
2003-08-16 06:37:06 +00:00
|
|
|
if (!isteacheredit($id)) {
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
} else {
|
|
|
|
if (!isteacheredit($to)) {
|
|
|
|
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
}
|
|
|
|
}
|
2003-08-02 16:06:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!isadmin()) {
|
|
|
|
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
}
|
2003-05-14 23:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Check site
|
|
|
|
if (!$site = get_site()) {
|
2003-05-16 21:52:49 +00:00
|
|
|
error("Site not found!");
|
2003-05-14 23:25:00 +00:00
|
|
|
}
|
2003-06-12 15:35:37 +00:00
|
|
|
|
|
|
|
//Check necessary functions exists. Thanks to gregb@crowncollege.edu
|
|
|
|
backup_required_functions();
|
2003-05-14 23:25:00 +00:00
|
|
|
|
|
|
|
//Check backup_version
|
2003-06-11 19:13:07 +00:00
|
|
|
if ($file) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$linkto = "restore.php?id=".$id."&file=".$file;
|
2003-06-11 19:13:07 +00:00
|
|
|
} else {
|
|
|
|
$linkto = "restore.php";
|
|
|
|
}
|
2003-08-01 13:59:17 +00:00
|
|
|
upgrade_backup_db($linkto);
|
2003-05-14 23:25:00 +00:00
|
|
|
|
|
|
|
//Get strings
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
$strcourserestore = get_string("courserestore");
|
|
|
|
} else {
|
|
|
|
$strcourserestore = get_string("importdata");
|
|
|
|
}
|
2003-05-14 23:25:00 +00:00
|
|
|
$stradministration = get_string("administration");
|
|
|
|
|
2003-05-16 21:52:49 +00:00
|
|
|
//If no file has been selected from the FileManager, inform and end
|
|
|
|
if (!$file) {
|
2003-05-14 23:25:00 +00:00
|
|
|
print_header("$site->shortname: $strcourserestore", $site->fullname,
|
2004-09-12 01:34:24 +00:00
|
|
|
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> $strcourserestore");
|
2003-05-16 21:52:49 +00:00
|
|
|
print_heading(get_string("nofilesselected"));
|
2003-08-01 14:34:11 +00:00
|
|
|
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
|
2003-05-14 23:25:00 +00:00
|
|
|
print_footer();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2003-05-18 22:53:11 +00:00
|
|
|
//If cancel has been selected, inform and end
|
|
|
|
if ($cancel) {
|
|
|
|
print_header("$site->shortname: $strcourserestore", $site->fullname,
|
2004-09-12 01:34:24 +00:00
|
|
|
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> $strcourserestore");
|
2003-05-18 22:53:11 +00:00
|
|
|
print_heading(get_string("restorecancelled"));
|
2003-08-01 14:34:11 +00:00
|
|
|
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
|
2003-05-18 22:53:11 +00:00
|
|
|
print_footer();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2003-05-16 21:52:49 +00:00
|
|
|
//We are here, so me have a file.
|
2003-08-02 16:06:33 +00:00
|
|
|
|
|
|
|
//Get and check course
|
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
|
|
error("Course ID was incorrect (can't find it)");
|
|
|
|
}
|
|
|
|
|
2004-02-04 12:44:06 +00:00
|
|
|
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
|
|
|
|
|
2003-05-14 23:25:00 +00:00
|
|
|
//Print header
|
2003-08-02 16:06:33 +00:00
|
|
|
if (isadmin()) {
|
|
|
|
print_header("$site->shortname: $strcourserestore", $site->fullname,
|
|
|
|
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
|
|
|
|
$strcourserestore -> ".basename($file));
|
|
|
|
} else {
|
|
|
|
print_header("$course->shortname: $strcourserestore", $course->fullname,
|
|
|
|
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
|
|
$strcourserestore");
|
|
|
|
}
|
2003-05-16 21:52:49 +00:00
|
|
|
//Print form
|
2005-01-27 02:35:10 +00:00
|
|
|
print_heading("$strcourserestore".((empty($to) ? ': '.basename($file) : '')));
|
2005-01-28 00:01:20 +00:00
|
|
|
print_simple_box_start('center');
|
2003-06-11 19:13:07 +00:00
|
|
|
|
|
|
|
//Adjust some php variables to the execution of this script
|
2004-09-08 22:47:19 +00:00
|
|
|
@ini_set("max_execution_time","3000");
|
2004-11-18 02:55:06 +00:00
|
|
|
raise_memory_limit("memory_limit","128M");
|
2003-05-16 21:52:49 +00:00
|
|
|
|
2003-05-14 23:25:00 +00:00
|
|
|
//Call the form, depending the step we are
|
2005-01-27 02:35:10 +00:00
|
|
|
|
|
|
|
|
2003-05-14 23:25:00 +00:00
|
|
|
if (!$launch) {
|
2003-05-16 21:52:49 +00:00
|
|
|
include_once("restore_precheck.html");
|
2003-05-18 17:15:05 +00:00
|
|
|
} else if ($launch == "form") {
|
2005-01-27 02:35:10 +00:00
|
|
|
if ($SESSION->restore->importing) {
|
|
|
|
// set up all the config stuff and skip asking the user about it.
|
|
|
|
restore_setup_for_check($SESSION->restore,$backup_unique_code);
|
|
|
|
include_once("restore_execute.html");
|
|
|
|
} else {
|
|
|
|
include_once("restore_form.html");
|
|
|
|
}
|
2003-05-19 22:28:39 +00:00
|
|
|
} else if ($launch == "check") {
|
|
|
|
include_once("restore_check.html");
|
2003-05-14 23:25:00 +00:00
|
|
|
} else if ($launch == "execute") {
|
2003-05-24 00:27:45 +00:00
|
|
|
include_once("restore_execute.html");
|
2003-05-14 23:25:00 +00:00
|
|
|
}
|
|
|
|
print_simple_box_end();
|
|
|
|
|
|
|
|
//Print footer
|
|
|
|
print_footer();
|
|
|
|
|
|
|
|
?>
|