New string to backup messages in SITE backups
[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
80 if ($count == 0) {
81 notice("No backupable modules are installed!");
82 }
83
84?>
85
0e232d18 86<form name="form" method="post" action="<?php echo $ME ?>">
7ef0797d 87<table cellpadding="5">
145cb8f9 88<?php
a615cc7b 89 if ($allmods = get_records("modules") ) {
90 foreach ($allmods as $mod) {
91 $modname = $mod->name;
92 $modbackup = $modname."_backup_mods";
93 //If exists the lib & function
94 $var = "exists_".$modname;
142a6a46 95 if (isset($$var) && $$var) {
a615cc7b 96 //Print the full tr
97 echo "<tr>";
f2d57378 98 echo "<td align=\"right\"><b>";
a615cc7b 99 echo get_string("include")." ". get_string("modulenameplural",$modname).":";
f2d57378 100 echo "</b></td><td>";
a615cc7b 101 $backup_options[0] = get_string("no");
102 $backup_options[1] = get_string("yes");
103 $var = "backup_".$modname;
104 choose_from_menu($backup_options, $var, $$var, "");
a615cc7b 105 $var = "backup_user_info_".$modname;
873bf875 106 if (empty($to)) {
107 $backup_user_options[0] = get_string("withoutuserdata");
108 $backup_user_options[1] = get_string("withuserdata");
109 choose_from_menu($backup_user_options, $var, $$var, "");
110 }
111 else {
112 echo '<input type="hidden" name="'.$var.'" value="0" />';
113 }
114 echo "</td></tr>";
a615cc7b 115 }
116 }
117 //Line
f2d57378 118 echo "<tr><td colspan=\"2\"><hr /></td></tr>";
873bf875 119
57224893 120 if (empty($to)) {
121 //Now print the Metacourse tr
122 echo "<tr>";
f2d57378 123 echo "<td align=\"right\"><b>";
57224893 124 echo get_string ("metacourse").":";
f2d57378 125 echo "</b></td><td>";
57224893 126 $meta_options[0] = get_string("no");
127 $meta_options[1] = get_string("yes");
128 choose_from_menu($meta_options, "backup_metacourse", $backup_metacourse, "");
129 echo "</td></tr>";
130 }
131 else {
132 echo '<input type="hidden" name="backup_metacourse" value="0" />';
133 }
134
873bf875 135 if (empty($to)) {
136 //Now print the Users tr
137 echo "<tr>";
f2d57378 138 echo "<td align=\"right\"><b>";
873bf875 139 echo get_string("users").":";
f2d57378 140 echo "</b></td><td>";
873bf875 141 $user_options[0] = get_string("all");
142 $user_options[1] = get_string("course");
143 $user_options[2] = get_string("none");
144 choose_from_menu($user_options, "backup_users", $backup_users, "");
145 echo "</td></tr>";
146 }
147 else {
148 echo '<input type="hidden" name="backup_users" value="0" />';
149 }
150
151 if (empty($to)) {
152 //Now print the Logs tr
153 echo "<tr>";
f2d57378 154 echo "<td align=\"right\"><b>";
873bf875 155 echo get_string("logs").":";
f2d57378 156 echo "</b></td><td>";
873bf875 157 $log_options[0] = get_string("no");
158 $log_options[1] = get_string("yes");
159 choose_from_menu($log_options, "backup_logs", $backup_logs, "");
160 echo "</td></tr>";
161 }
162 else {
163 echo '<input type="hidden" name="backup_logs" value="0" />';
164 }
165
166 if (empty($to)) {
167 //Now print the User Files tr
168 echo "<tr>";
f2d57378 169 echo "<td align=\"right\"><b>";
873bf875 170 echo get_string ("userfiles").":";
f2d57378 171 echo "</b></td><td>";
873bf875 172 $user_file_options[0] = get_string("no");
173 $user_file_options[1] = get_string("yes");
174 choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, "");
175 echo "</td></tr>";
176 }
177 else {
178 echo '<input type="hidden" name="backup_user_files" value="0" />';
179 }
a615cc7b 180 //Now print the Course Files tr
181 echo "<tr>";
f2d57378 182 echo "<td align=\"right\"><b>";
a615cc7b 183 echo get_string ("coursefiles").":";
f2d57378 184 echo "</b></td><td>";
a615cc7b 185 $course_file_options[0] = get_string("no");
186 $course_file_options[1] = get_string("yes");
187 choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, "");
188 echo "</td></tr>";
189 }
190?>
191</table>
7ef0797d 192<br />
193<center>
873bf875 194<input type="hidden" name="id" value="<?php p($id) ?>" />
195<input type="hidden" name="to" value="<?php p($to) ?>" />
196<input type="hidden" name="launch" value="check" />
197<input type="submit" value="<?php print_string("continue") ?>" />
198<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
7ef0797d 199</center>
200</form>