Added new string for duplicate emails in lost password recovery.
[moodle-linuxchix.git] / backup / backup.php
blob1e2a36682d76789505803f49be83857f901a9d53
1 <?php //$Id$
2 //This script is used to configure and execute the backup proccess.
4 //Define some globals for all the script
6 require_once ("../config.php");
7 require_once ("lib.php");
8 require_once ("backuplib.php");
9 require_once ("$CFG->libdir/blocklib.php");
11 $id = optional_param( 'id' ); // course id
12 $to = optional_param( 'to' ); // id of course to import into afterwards.
13 $cancel = optional_param( 'cancel' );
14 $launch = optional_param( 'launch' );
16 require_login();
18 if (!empty($id)) {
19 if (!isteacheredit($id)) {
20 if (empty($to)) {
21 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
22 } else {
23 if (!isteacheredit($to)) {
24 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
28 } else {
29 if (!isadmin()) {
30 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
34 //Check site
35 if (!$site = get_site()) {
36 error("Site not found!");
39 //Check necessary functions exists. Thanks to gregb@crowncollege.edu
40 backup_required_functions();
42 //Check backup_version
43 if ($id) {
44 $linkto = "backup.php?id=".$id.((!empty($to)) ? '&to='.$to : '');
45 } else {
46 $linkto = "backup.php";
48 upgrade_backup_db($linkto);
50 //Get strings
51 if (empty($to)) {
52 $strcoursebackup = get_string("coursebackup");
54 else {
55 $strcoursebackup = get_string('importdata');
57 $stradministration = get_string("administration");
59 //If cancel has been selected, go back to course main page (bug 2817)
60 if ($cancel) {
61 if ($id) {
62 $redirecto = $CFG->wwwroot . '/course/view.php?id=' . $id; //Course page
63 } else {
64 $redirecto = $CFG->wwwroot;
66 redirect ($redirecto, get_string('backupcancelled')); //Site page
67 exit;
70 //If no course has been selected, show a list of available courses
72 if (!$id) {
73 print_header("$site->shortname: $strcoursebackup", $site->fullname,
74 "<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> $strcoursebackup");
76 if ($courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname')) {
77 print_heading(get_string("choosecourse"));
78 print_simple_box_start("center");
79 foreach ($courses as $course) {
80 echo "<a href=\"backup.php?id=$course->id\">$course->fullname ($course->shortname)</a><br />";
82 print_simple_box_end();
83 } else {
84 print_heading(get_string("nocoursesyet"));
85 print_continue("$CFG->wwwroot/$CFG->admin/index.php");
87 print_footer();
88 exit;
91 //Get and check course
92 if (! $course = get_record("course", "id", $id)) {
93 error("Course ID was incorrect (can't find it)");
96 check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
98 //Print header
99 if (isadmin()) {
100 print_header("$site->shortname: $strcoursebackup", $site->fullname,
101 "<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
102 <a href=\"backup.php\">$strcoursebackup</a> -> $course->fullname ($course->shortname)");
103 } else {
104 print_header("$course->shortname: $strcoursebackup", $course->fullname,
105 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
106 $strcoursebackup");
109 //Print form
110 print_heading("$strcoursebackup: $course->fullname ($course->shortname)");
111 print_simple_box_start("center");
113 //Adjust some php variables to the execution of this script
114 @ini_set("max_execution_time","3000");
115 raise_memory_limit("128M");
117 //Call the form, depending the step we are
118 if (!$launch) {
119 include_once("backup_form.html");
120 } else if ($launch == "check") {
121 include_once("backup_check.html");
122 } else if ($launch == "execute") {
123 include_once("backup_execute.html");
125 print_simple_box_end();
127 //Print footer
128 print_footer();