Polished.
[moodle.git] / backup / backup.php
blobe310ab0bc4e0b28714463161dae9024721b15891
1 <?PHP //$Id$
2 //This script is used to configure and execute the backup proccess.
4 //Define some globals for all the script
6 //MUST CHANGE WITH FINAL BACKUP LOCATION !! WITHOUT TRAILING SLASH !!
7 //ALL RELATIVE FROM THE LOCATION OF THE backup.php SCRIPT !!!
9 $moodle_home = "../../..";
10 $mods_home = "mod";
12 //END MUST CHANGE
14 //Units used
15 require_once ("$moodle_home/config.php");
16 require_once ("$moodle_home/version.php");
17 require_once ("backup_version.php");
18 require_once ("db/backup_$CFG->dbtype.php");
19 require_once ("lib.php");
20 require_once ("backuplib.php");
22 //Optional variables
23 optional_variable($id); // course id
25 //Check login
26 require_login();
28 //Check admin
29 if (!isadmin()) {
30 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
33 //Check site
34 if (!$site = get_site()) {
35 error("Site not found!");
38 //Check backup_version
39 upgrade_backup_db($backup_version,$backup_release,"backup.php");
41 //Get strings
42 $strcoursebackup = get_string("coursebackup");
43 $stradministration = get_string("administration");
45 //If no course has been selected or cancel button pressed
46 if (!$id or $cancel) {
47 print_header("$site->shortname: $strcoursebackup", $site->fullname,
48 "<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcoursebackup");
50 if ($courses = get_courses()) {
51 print_heading(get_string("choosecourse"));
52 print_simple_box_start("CENTER");
53 foreach ($courses as $course) {
54 echo "<A HREF=\"backup.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
56 print_simple_box_end();
57 } else {
58 print_heading(get_string("nocoursesyet"));
59 print_continue("$moodle_home/$CFG->admin/index.php");
61 print_footer();
62 exit;
65 //Get and check course
66 if (! $course = get_record("course", "id", $id)) {
67 error("Course ID was incorrect (can't find it)");
69 //Print header
70 print_header("$site->shortname: $strcoursebackup", $site->fullname,
71 "<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> ->
72 <A HREF=\"backup.php\">$strcoursebackup</A> -> $course->fullname ($course->shortname)");
74 //Print form
75 print_heading("$strcoursebackup: $course->fullname ($course->shortname)");
76 print_simple_box_start("center", "", "$THEME->cellheading");
77 //Call the form, depending the step we are
78 if (!$launch) {
79 include_once("backup_form.html");
80 } else if ($launch == "check") {
81 include_once("backup_check.html");
82 } else if ($launch == "execute") {
83 include_once("backup_execute.html");
85 print_simple_box_end();
87 //Print footer
88 print_footer();