FIXED: at End of Lesson with review on produced two warnings. Now they are gone
[moodle.git] / backup / backup_form.html
CommitLineData
7ef0797d 1<?php //$Id$
a615cc7b 2 //This page prints the backup form to select everything
3
c563a9a0 4 //Check login
5 require_login();
6
bd38123e 7 if (!empty($course->id)) {
63bcc9b5 8 if (!isteacheredit($course->id)) {
873bf875 9 if (empty($to)) {
10 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
11 } else {
12 if (!isteacheredit($to)) {
13 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
14 }
15 }
bd38123e 16 }
17 } else {
18 if (!isadmin()) {
19 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
20 }
c563a9a0 21 }
22
23 //Check site
24 if (!$site = get_site()) {
25 error("Site not found!");
26 }
27
a615cc7b 28 //Checks for the required files/functions to backup every mod
29 //And check if there is data about it
30 $count = 0;
31 if ($allmods = get_records("modules") ) {
32 foreach ($allmods as $mod) {
33 $modname = $mod->name;
9c1ae5ae 34 $modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
a615cc7b 35 $modbackup = $modname."_backup_mods";
36 $modcheckbackup = $modname."_check_backup_mods";
37 if (file_exists($modfile)) {
38 include_once($modfile);
39 if (function_exists($modbackup) and function_exists($modcheckbackup)) {
40 $var = "exists_".$modname;
41 $$var = true;
42 $count++;
43 }
44 }
45 //Check data
46 //Check module info
47 $var = "backup_".$modname;
48 if (!isset($$var)) {
49 $$var = 1;
50 }
51 //Check include user info
52 $var = "backup_user_info_".$modname;
53 if (!isset($$var)) {
54 $$var = 1;
55 }
56 }
57 }
58
59 //Check other parameters
57224893 60 if (!isset($backup_metacourse)) {
61 $backup_metacourse = 1;
62 }
63
a615cc7b 64 if (!isset($backup_users)) {
65 $backup_users = 1;
66 }
67
68 if (!isset($backup_logs)) {
042c19f5 69 $backup_logs = 0;
a615cc7b 70 }
71
72 if (!isset($backup_user_files)) {
73 $backup_user_files = 1;
74 }
75
76 if (!isset($backup_course_files)) {
77 $backup_course_files = 1;
78 }
79
70641539 80 if (!isset($backup_messages)) {
81 $backup_messages = 1;
82 }
83
a615cc7b 84 if ($count == 0) {
85 notice("No backupable modules are installed!");
86 }
87
88?>
89
d0b95287 90<form name="form" method="post" action="backup.php">
7ef0797d 91<table cellpadding="5">
145cb8f9 92<?php
a615cc7b 93 if ($allmods = get_records("modules") ) {
94 foreach ($allmods as $mod) {
95 $modname = $mod->name;
96 $modbackup = $modname."_backup_mods";
97 //If exists the lib & function
98 $var = "exists_".$modname;
142a6a46 99 if (isset($$var) && $$var) {
a615cc7b 100 //Print the full tr
101 echo "<tr>";
35a4a791 102 echo " <td align=\"right\"><b>";
a615cc7b 103 echo get_string("include")." ". get_string("modulenameplural",$modname).":";
35a4a791 104 echo "</b></td><td>\n";
a615cc7b 105 $backup_options[0] = get_string("no");
106 $backup_options[1] = get_string("yes");
107 $var = "backup_".$modname;
108 choose_from_menu($backup_options, $var, $$var, "");
a615cc7b 109 $var = "backup_user_info_".$modname;
873bf875 110 if (empty($to)) {
111 $backup_user_options[0] = get_string("withoutuserdata");
112 $backup_user_options[1] = get_string("withuserdata");
113 choose_from_menu($backup_user_options, $var, $$var, "");
114 }
115 else {
116 echo '<input type="hidden" name="'.$var.'" value="0" />';
117 }
35a4a791 118 echo "</td></tr>\n";
a615cc7b 119 }
120 }
121 //Line
35a4a791 122 echo "<tr><td colspan=\"2\"><hr /></td></tr>\n";
873bf875 123
57224893 124 if (empty($to)) {
125 //Now print the Metacourse tr
126 echo "<tr>";
f2d57378 127 echo "<td align=\"right\"><b>";
57224893 128 echo get_string ("metacourse").":";
f2d57378 129 echo "</b></td><td>";
57224893 130 $meta_options[0] = get_string("no");
131 $meta_options[1] = get_string("yes");
132 choose_from_menu($meta_options, "backup_metacourse", $backup_metacourse, "");
133 echo "</td></tr>";
134 }
135 else {
136 echo '<input type="hidden" name="backup_metacourse" value="0" />';
137 }
138
873bf875 139 if (empty($to)) {
140 //Now print the Users tr
141 echo "<tr>";
f2d57378 142 echo "<td align=\"right\"><b>";
873bf875 143 echo get_string("users").":";
f2d57378 144 echo "</b></td><td>";
873bf875 145 $user_options[0] = get_string("all");
146 $user_options[1] = get_string("course");
147 $user_options[2] = get_string("none");
148 choose_from_menu($user_options, "backup_users", $backup_users, "");
149 echo "</td></tr>";
150 }
151 else {
152 echo '<input type="hidden" name="backup_users" value="0" />';
153 }
154
155 if (empty($to)) {
156 //Now print the Logs tr
157 echo "<tr>";
f2d57378 158 echo "<td align=\"right\"><b>";
873bf875 159 echo get_string("logs").":";
f2d57378 160 echo "</b></td><td>";
873bf875 161 $log_options[0] = get_string("no");
162 $log_options[1] = get_string("yes");
163 choose_from_menu($log_options, "backup_logs", $backup_logs, "");
164 echo "</td></tr>";
165 }
166 else {
167 echo '<input type="hidden" name="backup_logs" value="0" />';
168 }
ef9b35a0 169
873bf875 170 if (empty($to)) {
171 //Now print the User Files tr
172 echo "<tr>";
f2d57378 173 echo "<td align=\"right\"><b>";
873bf875 174 echo get_string ("userfiles").":";
f2d57378 175 echo "</b></td><td>";
873bf875 176 $user_file_options[0] = get_string("no");
177 $user_file_options[1] = get_string("yes");
178 choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, "");
179 echo "</td></tr>";
180 }
181 else {
182 echo '<input type="hidden" name="backup_user_files" value="0" />';
183 }
a615cc7b 184 //Now print the Course Files tr
185 echo "<tr>";
f2d57378 186 echo "<td align=\"right\"><b>";
a615cc7b 187 echo get_string ("coursefiles").":";
f2d57378 188 echo "</b></td><td>";
a615cc7b 189 $course_file_options[0] = get_string("no");
190 $course_file_options[1] = get_string("yes");
191 choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, "");
192 echo "</td></tr>";
70641539 193
194 if (empty($to) && $course->id == SITEID) {
195 //If we are in a SITEID backup print the Messages tr
196 echo "<tr>";
197 echo "<td align=\"right\"><b>";
198 echo get_string ('messages','message').":";
199 echo "</b></td><td>";
200 $mess_options[0] = get_string("no");
201 $mess_options[1] = get_string("yes");
202 choose_from_menu($mess_options, "backup_messages", $backup_messages, "");
203 echo "</td></tr>";
204 }
205 else {
206 echo '<input type="hidden" name="backup_messages" value="0" />';
207 }
a615cc7b 208 }
209?>
210</table>
7ef0797d 211<br />
212<center>
873bf875 213<input type="hidden" name="id" value="<?php p($id) ?>" />
214<input type="hidden" name="to" value="<?php p($to) ?>" />
215<input type="hidden" name="launch" value="check" />
216<input type="submit" value="<?php print_string("continue") ?>" />
217<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
7ef0797d 218</center>
219</form>