polished.
[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
60 if (!isset($backup_users)) {
61 $backup_users = 1;
62 }
63
64 if (!isset($backup_logs)) {
042c19f5 65 $backup_logs = 0;
a615cc7b 66 }
67
68 if (!isset($backup_user_files)) {
69 $backup_user_files = 1;
70 }
71
72 if (!isset($backup_course_files)) {
73 $backup_course_files = 1;
74 }
75
76 if ($count == 0) {
77 notice("No backupable modules are installed!");
78 }
79
80?>
81
0e232d18 82<form name="form" method="post" action="<?php echo $ME ?>">
7ef0797d 83<table cellpadding="5">
145cb8f9 84<?php
a615cc7b 85 if ($allmods = get_records("modules") ) {
86 foreach ($allmods as $mod) {
87 $modname = $mod->name;
88 $modbackup = $modname."_backup_mods";
89 //If exists the lib & function
90 $var = "exists_".$modname;
142a6a46 91 if (isset($$var) && $$var) {
a615cc7b 92 //Print the full tr
93 echo "<tr>";
7ef0797d 94 echo "<td align=\"right\"><p><b>";
a615cc7b 95 echo get_string("include")." ". get_string("modulenameplural",$modname).":";
96 echo "</td><td>";
97 $backup_options[0] = get_string("no");
98 $backup_options[1] = get_string("yes");
99 $var = "backup_".$modname;
100 choose_from_menu($backup_options, $var, $$var, "");
a615cc7b 101 $var = "backup_user_info_".$modname;
873bf875 102 if (empty($to)) {
103 $backup_user_options[0] = get_string("withoutuserdata");
104 $backup_user_options[1] = get_string("withuserdata");
105 choose_from_menu($backup_user_options, $var, $$var, "");
106 }
107 else {
108 echo '<input type="hidden" name="'.$var.'" value="0" />';
109 }
110 echo "</td></tr>";
a615cc7b 111 }
112 }
113 //Line
114 echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
873bf875 115
116 if (empty($to)) {
117 //Now print the Users tr
118 echo "<tr>";
119 echo "<td align=\"right\"><P><B>";
120 echo get_string("users").":";
121 echo "</td><td>";
122 $user_options[0] = get_string("all");
123 $user_options[1] = get_string("course");
124 $user_options[2] = get_string("none");
125 choose_from_menu($user_options, "backup_users", $backup_users, "");
126 echo "</td></tr>";
127 }
128 else {
129 echo '<input type="hidden" name="backup_users" value="0" />';
130 }
131
132 if (empty($to)) {
133 //Now print the Logs tr
134 echo "<tr>";
135 echo "<td align=\"right\"><P><B>";
136 echo get_string("logs").":";
137 echo "</td><td>";
138 $log_options[0] = get_string("no");
139 $log_options[1] = get_string("yes");
140 choose_from_menu($log_options, "backup_logs", $backup_logs, "");
141 echo "</td></tr>";
142 }
143 else {
144 echo '<input type="hidden" name="backup_logs" value="0" />';
145 }
146
147 if (empty($to)) {
148 //Now print the User Files tr
149 echo "<tr>";
150 echo "<td align=\"right\"><P><B>";
151 echo get_string ("userfiles").":";
152 echo "</td><td>";
153 $user_file_options[0] = get_string("no");
154 $user_file_options[1] = get_string("yes");
155 choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, "");
156 echo "</td></tr>";
157 }
158 else {
159 echo '<input type="hidden" name="backup_user_files" value="0" />';
160 }
a615cc7b 161 //Now print the Course Files tr
162 echo "<tr>";
873bf875 163 echo "<td align=\"right\"><P><B>";
a615cc7b 164 echo get_string ("coursefiles").":";
165 echo "</td><td>";
166 $course_file_options[0] = get_string("no");
167 $course_file_options[1] = get_string("yes");
168 choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, "");
169 echo "</td></tr>";
170 }
171?>
172</table>
7ef0797d 173<br />
174<center>
873bf875 175<input type="hidden" name="id" value="<?php p($id) ?>" />
176<input type="hidden" name="to" value="<?php p($to) ?>" />
177<input type="hidden" name="launch" value="check" />
178<input type="submit" value="<?php print_string("continue") ?>" />
179<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
7ef0797d 180</center>
181</form>