Removed $moodle_home and $mods_home references.
[moodle.git] / backup / backup_form.html
CommitLineData
a615cc7b 1<?PHP //$Id$
2 //This page prints the backup form to select everything
3
c563a9a0 4 //Check login
5 require_login();
6
7 //Check admin
8 if (!isadmin()) {
9 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
10 }
11
12 //Check site
13 if (!$site = get_site()) {
14 error("Site not found!");
15 }
16
a615cc7b 17 //Checks for the required files/functions to backup every mod
18 //And check if there is data about it
19 $count = 0;
20 if ($allmods = get_records("modules") ) {
21 foreach ($allmods as $mod) {
22 $modname = $mod->name;
9c1ae5ae 23 $modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
a615cc7b 24 $modbackup = $modname."_backup_mods";
25 $modcheckbackup = $modname."_check_backup_mods";
26 if (file_exists($modfile)) {
27 include_once($modfile);
28 if (function_exists($modbackup) and function_exists($modcheckbackup)) {
29 $var = "exists_".$modname;
30 $$var = true;
31 $count++;
32 }
33 }
34 //Check data
35 //Check module info
36 $var = "backup_".$modname;
37 if (!isset($$var)) {
38 $$var = 1;
39 }
40 //Check include user info
41 $var = "backup_user_info_".$modname;
42 if (!isset($$var)) {
43 $$var = 1;
44 }
45 }
46 }
47
48 //Check other parameters
49 if (!isset($backup_users)) {
50 $backup_users = 1;
51 }
52
53 if (!isset($backup_logs)) {
042c19f5 54 $backup_logs = 0;
a615cc7b 55 }
56
57 if (!isset($backup_user_files)) {
58 $backup_user_files = 1;
59 }
60
61 if (!isset($backup_course_files)) {
62 $backup_course_files = 1;
63 }
64
65 if ($count == 0) {
66 notice("No backupable modules are installed!");
67 }
68
69?>
70
71<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
72<table cellpadding=5>
73<?
74 if ($allmods = get_records("modules") ) {
75 foreach ($allmods as $mod) {
76 $modname = $mod->name;
77 $modbackup = $modname."_backup_mods";
78 //If exists the lib & function
79 $var = "exists_".$modname;
80 if ($$var) {
81 //Print the full tr
82 echo "<tr>";
83 echo "<td align=\"right\"><P><B>";
84 echo get_string("include")." ". get_string("modulenameplural",$modname).":";
85 echo "</td><td>";
86 $backup_options[0] = get_string("no");
87 $backup_options[1] = get_string("yes");
88 $var = "backup_".$modname;
89 choose_from_menu($backup_options, $var, $$var, "");
90 $backup_user_options[0] = get_string("withoutuserdata");
91 $backup_user_options[1] = get_string("withuserdata");
92 $var = "backup_user_info_".$modname;
93 choose_from_menu($backup_user_options, $var, $$var, "");
94 echo "</td></tr>";
95 }
96 }
97 //Line
98 echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
99
100 //Now print the Users tr
101 echo "<tr>";
102 echo "<td align=\"right\"><P><B>";
103 echo get_string("users").":";
104 echo "</td><td>";
105 $user_options[0] = get_string("all");
106 $user_options[1] = get_string("course");
107 //$user_options[2] = get_string("needed");-->NOT IMPLEMENTED
108 choose_from_menu($user_options, "backup_users", $backup_users, "");
109 echo "</td></tr>";
110
111 //Now print the Logs tr
112 echo "<tr>";
113 echo "<td align=\"right\"><P><B>";
114 echo get_string("logs").":";
115 echo "</td><td>";
116 $log_options[0] = get_string("no");
117 $log_options[1] = get_string("yes");
118 choose_from_menu($log_options, "backup_logs", $backup_logs, "");
119 echo "</td></tr>";
120
121 //Now print the User Files tr
122 echo "<tr>";
123 echo "<td align=\"right\"><P><B>";
124 echo get_string ("userfiles").":";
125 echo "</td><td>";
126 $user_file_options[0] = get_string("no");
127 $user_file_options[1] = get_string("yes");
128 choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, "");
129 echo "</td></tr>";
130
131 //Now print the Course Files tr
132 echo "<tr>";
133 echo "<td align=\"right\"><P><B>";
134 echo get_string ("coursefiles").":";
135 echo "</td><td>";
136 $course_file_options[0] = get_string("no");
137 $course_file_options[1] = get_string("yes");
138 choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, "");
139 echo "</td></tr>";
140 }
141?>
142</table>
143<BR>
144<CENTER>
145<input type="hidden" name=id value="<? p($id) ?>">
146<input type="hidden" name=launch value="check">
147<input type="submit" value="<? print_string("continue") ?>">
148<input type="submit" name=cancel value="<? print_string("cancel") ?>">
149</CENTER>
150</FORM>