2003-05-01 00:45:40 +00:00
|
|
|
<?PHP //$Id$
|
|
|
|
//This script is used to configure and execute the backup proccess.
|
|
|
|
|
|
|
|
//Define some globals for all the script
|
|
|
|
|
2003-08-01 14:34:11 +00:00
|
|
|
require_once ("../config.php");
|
2003-05-03 23:15:43 +00:00
|
|
|
require_once ("lib.php");
|
2003-05-14 22:09:30 +00:00
|
|
|
require_once ("backuplib.php");
|
2003-05-01 00:45:40 +00:00
|
|
|
|
|
|
|
optional_variable($id); // course id
|
|
|
|
|
|
|
|
require_login();
|
|
|
|
|
2003-08-01 14:34:11 +00:00
|
|
|
if (!empty($id)) {
|
2003-08-16 06:37:06 +00:00
|
|
|
if (!isteacheredit($id)) {
|
2003-08-01 14:34:11 +00:00
|
|
|
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!isadmin()) {
|
|
|
|
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
}
|
2003-05-01 00:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Check site
|
|
|
|
if (!$site = get_site()) {
|
2003-05-16 21:51:07 +00:00
|
|
|
error("Site not found!");
|
2003-05-01 00:45:40 +00:00
|
|
|
}
|
2003-06-12 15:35:37 +00:00
|
|
|
|
|
|
|
//Check necessary functions exists. Thanks to gregb@crowncollege.edu
|
|
|
|
backup_required_functions();
|
2003-05-03 23:15:43 +00:00
|
|
|
|
|
|
|
//Check backup_version
|
2003-08-02 10:32:57 +00:00
|
|
|
if ($id) {
|
|
|
|
$linkto = "backup.php?id=".$id;
|
|
|
|
} else {
|
|
|
|
$linkto = "backup.php";
|
|
|
|
}
|
|
|
|
upgrade_backup_db($linkto);
|
2003-05-01 00:45:40 +00:00
|
|
|
|
|
|
|
//Get strings
|
|
|
|
$strcoursebackup = get_string("coursebackup");
|
|
|
|
$stradministration = get_string("administration");
|
|
|
|
|
2003-05-01 17:42:08 +00:00
|
|
|
//If no course has been selected or cancel button pressed
|
|
|
|
if (!$id or $cancel) {
|
2003-05-01 00:45:40 +00:00
|
|
|
print_header("$site->shortname: $strcoursebackup", $site->fullname,
|
2003-08-01 14:34:11 +00:00
|
|
|
"<A HREF=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</A> -> $strcoursebackup");
|
2003-05-01 00:45:40 +00:00
|
|
|
|
|
|
|
if ($courses = get_courses()) {
|
|
|
|
print_heading(get_string("choosecourse"));
|
|
|
|
print_simple_box_start("CENTER");
|
|
|
|
foreach ($courses as $course) {
|
|
|
|
echo "<A HREF=\"backup.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
|
|
|
|
}
|
|
|
|
print_simple_box_end();
|
|
|
|
} else {
|
|
|
|
print_heading(get_string("nocoursesyet"));
|
2003-08-01 14:34:11 +00:00
|
|
|
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
|
2003-05-01 00:45:40 +00:00
|
|
|
}
|
|
|
|
print_footer();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get and check course
|
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
|
|
error("Course ID was incorrect (can't find it)");
|
|
|
|
}
|
2003-08-01 14:34:11 +00:00
|
|
|
|
2003-05-01 00:45:40 +00:00
|
|
|
//Print header
|
2003-08-01 14:34:11 +00:00
|
|
|
if (isadmin()) {
|
|
|
|
print_header("$site->shortname: $strcoursebackup", $site->fullname,
|
|
|
|
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
|
|
|
|
<a href=\"backup.php\">$strcoursebackup</a> -> $course->fullname ($course->shortname)");
|
|
|
|
} else {
|
2003-08-01 14:42:14 +00:00
|
|
|
print_header("$course->shortname: $strcoursebackup", $course->fullname,
|
|
|
|
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
|
|
$strcoursebackup");
|
2003-08-01 14:34:11 +00:00
|
|
|
}
|
2003-05-01 00:45:40 +00:00
|
|
|
|
|
|
|
//Print form
|
|
|
|
print_heading("$strcoursebackup: $course->fullname ($course->shortname)");
|
|
|
|
print_simple_box_start("center", "", "$THEME->cellheading");
|
2003-06-11 19:13:07 +00:00
|
|
|
|
|
|
|
//Adjust some php variables to the execution of this script
|
2003-06-12 15:35:37 +00:00
|
|
|
ini_set("max_execution_time","3000");
|
2003-06-11 19:13:07 +00:00
|
|
|
ini_set("memory_limit","56M");
|
|
|
|
|
2003-05-01 17:42:08 +00:00
|
|
|
//Call the form, depending the step we are
|
|
|
|
if (!$launch) {
|
2003-05-04 21:32:11 +00:00
|
|
|
include_once("backup_form.html");
|
2003-05-04 23:24:48 +00:00
|
|
|
} else if ($launch == "check") {
|
|
|
|
include_once("backup_check.html");
|
|
|
|
} else if ($launch == "execute") {
|
|
|
|
include_once("backup_execute.html");
|
2003-05-01 17:42:08 +00:00
|
|
|
}
|
2003-05-01 00:45:40 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
|
|
|
|
//Print footer
|
|
|
|
print_footer();
|
2003-05-01 17:42:08 +00:00
|
|
|
|
2003-05-01 00:45:40 +00:00
|
|
|
?>
|