Incorrect variable name used for parameter.
[moodle-linuxchix.git] / backup / backup_form.html
blob65ae4e001e2dc79e38978dfdf7ce2f4617d5a3c7
1 <?php //$Id$
2 //This page prints the backup form to select everything
4 //Check login
5 require_login();
7 if (!empty($course->id)) {
8 if (!isteacheredit($course->id)) {
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");
17 } else {
18 if (!isadmin()) {
19 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
23 //Check site
24 if (!$site = get_site()) {
25 error("Site not found!");
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;
34 $modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
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++;
45 //Check data
46 //Check module info
47 $var = "backup_".$modname;
48 if (!isset($$var)) {
49 $$var = 1;
51 //Check include user info
52 $var = "backup_user_info_".$modname;
53 if (!isset($$var)) {
54 $$var = 1;
59 //Check other parameters
60 if (!isset($backup_metacourse)) {
61 $backup_metacourse = 1;
64 if (!isset($backup_users)) {
65 $backup_users = 1;
68 if (!isset($backup_logs)) {
69 $backup_logs = 0;
72 if (!isset($backup_user_files)) {
73 $backup_user_files = 1;
76 if (!isset($backup_course_files)) {
77 $backup_course_files = 1;
80 if (!isset($backup_messages)) {
81 $backup_messages = 1;
84 if ($count == 0) {
85 notice("No backupable modules are installed!");
90 <form name="form" method="post" action="backup.php">
91 <table cellpadding="5">
92 <?php
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;
99 if (isset($$var) && $$var) {
100 //Print the full tr
101 echo "<tr>";
102 echo "<td align=\"right\"><b>";
103 echo get_string("include")." ". get_string("modulenameplural",$modname).":";
104 echo "</b></td><td>";
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, "");
109 $var = "backup_user_info_".$modname;
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, "");
115 else {
116 echo '<input type="hidden" name="'.$var.'" value="0" />';
118 echo "</td></tr>";
121 //Line
122 echo "<tr><td colspan=\"2\"><hr /></td></tr>";
124 if (empty($to)) {
125 //Now print the Metacourse tr
126 echo "<tr>";
127 echo "<td align=\"right\"><b>";
128 echo get_string ("metacourse").":";
129 echo "</b></td><td>";
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>";
135 else {
136 echo '<input type="hidden" name="backup_metacourse" value="0" />';
139 if (empty($to)) {
140 //Now print the Users tr
141 echo "<tr>";
142 echo "<td align=\"right\"><b>";
143 echo get_string("users").":";
144 echo "</b></td><td>";
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>";
151 else {
152 echo '<input type="hidden" name="backup_users" value="0" />';
155 if (empty($to)) {
156 //Now print the Logs tr
157 echo "<tr>";
158 echo "<td align=\"right\"><b>";
159 echo get_string("logs").":";
160 echo "</b></td><td>";
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>";
166 else {
167 echo '<input type="hidden" name="backup_logs" value="0" />';
170 if (empty($to)) {
171 //Now print the User Files tr
172 echo "<tr>";
173 echo "<td align=\"right\"><b>";
174 echo get_string ("userfiles").":";
175 echo "</b></td><td>";
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>";
181 else {
182 echo '<input type="hidden" name="backup_user_files" value="0" />';
184 //Now print the Course Files tr
185 echo "<tr>";
186 echo "<td align=\"right\"><b>";
187 echo get_string ("coursefiles").":";
188 echo "</b></td><td>";
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>";
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>";
205 else {
206 echo '<input type="hidden" name="backup_messages" value="0" />';
210 </table>
211 <br />
212 <center>
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") ?>" />
218 </center>
219 </form>