2 //This page prints the restore form to select everything yo want
3 //to restore. Form is dinamically buid, depending of
"info" object
4 //that contains the backup contents and depending of every mod
7 //Get objects from session
8 $info = $SESSION-
>info;
9 $course_header = $SESSION-
>course_header;
11 //Check that we have all we need
13 require_variable($backup_unique_code);
15 require_variable($file);
17 require_variable($info);
19 require_variable($course_header);
26 if (!isteacheredit($id)) {
27 error(
"You need to be a teacher or admin user to use this page.",
"$CFG->wwwroot/login/index.php");
31 error(
"You need to be an admin user to use this page.",
"$CFG->wwwroot/login/index.php");
36 if (!$site = get_site()) {
37 error(
"Site not found!");
40 //Checks for the required files/functions to restore every mod
42 if ($allmods = get_records(
"modules") ) {
43 foreach ($allmods as $mod) {
44 $modname = $mod-
>name;
45 $modfile =
"$CFG->dirroot/mod/$modname/restorelib.php";
46 $modrestore = $modname.
"_restore_mods";
47 if (file_exists($modfile)) {
48 include_once($modfile);
49 if (function_exists($modrestore)) {
50 $var =
"exists_".$modname;
57 $var =
"restore_".$modname;
61 //Check include user info
62 $var =
"restore_user_info_".$modname;
69 //Check other parameters
70 if (!isset($restore_users)) {
74 if (!isset($restore_logs)) {
78 if (!isset($restore_user_files)) {
79 $restore_user_files =
1;
82 if (!isset($restore_course_files)) {
83 $restore_course_files =
1;
86 if (!isset($restore_restoreto)) {
87 if (isteacheredit($id) and !isadmin()) {
88 $restore_restoreto =
1;
91 $restore_restoreto =
2;
96 notice(
"No restorable modules are installed!");
101 <form name=
"form" method=
"post" action=
"<?php echo $ME ?>">
102 <table cellpadding
=5>
105 //First, course destination
108 echo "<td align=\"right\"><P><b>";
109 echo get_string("restoreto").":</b>";
111 if (isteacheredit($id) and !isadmin()) {
112 $restore_restoreto_options[0] = get_string("currentcoursedeleting");
113 $restore_restoreto_options[1] = get_string("currentcourseadding");
116 $restore_restoreto_options[0] = get_string("existingcoursedeleting");
117 $restore_restoreto_options[1] = get_string("existingcourseadding");
118 $restore_restoreto_options[2] = get_string("newcourse");
120 choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
123 echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
124 //Now, check modules and info and show posibilities
125 if ($allmods = get_records("modules") ) {
126 foreach ($allmods as $mod) {
127 $modname = $mod->name
;
128 $modrestore = $modname."_restore_mods";
129 //If exists the lib & function
130 $exist = "exists_".$modname;
131 $restore_var = "restore_".$modname;
132 $user_info_var = "restore_user_info_".$modname;
133 if (isset($
$exist)) {
135 //Now check that we have that module info in the backup file
136 if (isset($info->mods
[$modname]) && $info->mods
[$modname]->backup
== "true") {
139 echo "<td align=\"right\"><P><B>";
140 echo get_string("include")." ". get_string("modulenameplural",$modname).":";
142 $restore_options[0] = get_string("no");
143 $restore_options[1] = get_string("yes");
144 choose_from_menu($restore_options, $restore_var, $
$restore_var, "");
145 //If backup contains user data, then show menu, else fix it to
147 if ($info->mods
[$modname]->userinfo
== "true") {
148 $restore_user_options[0] = get_string("withoutuserdata");
149 $restore_user_options[1] = get_string("withuserdata");
150 choose_from_menu($restore_user_options, $user_info_var, $
$user_info_var, "");
152 //Module haven't userdata
153 echo get_string("withoutuserdata");
154 echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
158 //Module isn't restorable
159 echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
160 echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
163 //Module isn't restorable
164 echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
165 echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
168 //Module isn't restorable
169 echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
170 echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
174 echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
176 //Now print the Users tr
178 echo "<td align=\"right\"><P><B>";
179 echo get_string("users").":";
181 //If all users are in the backup file
182 if ($info->backup_users
== "all") {
183 $user_options[0] = get_string("all");
185 $user_options[1] = get_string("course");
186 $user_options[2] = get_string("none");
187 //$user_options[2] = get_string("needed");-->NOT IMPLEMENTED
188 choose_from_menu($user_options, "restore_users", $restore_users, "");
191 //Now print the Logs tr
193 echo "<td align=\"right\"><P><B>";
194 echo get_string("logs").":";
196 //If logs are in the backup file, show menu, else fixed to no
197 if ($info->backup_logs
== "true") {
198 $log_options[0] = get_string("no");
199 $log_options[1] = get_string("yes");
200 choose_from_menu($log_options, "restore_logs", $restore_logs, "");
202 echo get_string("no");
203 echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\">";
207 //Now print the User Files tr
209 echo "<td align=\"right\"><P><B>";
210 echo get_string ("userfiles").":";
212 //If user files are in the backup file, show menu, else fixed to no
213 if ($info->backup_user_files
== "true") {
214 $user_file_options[0] = get_string("no");
215 $user_file_options[1] = get_string("yes");
216 choose_from_menu($user_file_options, "restore_user_files", $restore_user_files, "");
218 echo get_string("no");
219 echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\">";
223 //Now print the Course Files tr
225 echo "<td align=\"right\"><P><B>";
226 echo get_string ("coursefiles").":";
228 //If course files are in the backup file, show menu, else fixed to no
229 if ($info->backup_course_files
== "true") {
230 $course_file_options[0] = get_string("no");
231 $course_file_options[1] = get_string("yes");
232 choose_from_menu($course_file_options, "restore_course_files", $restore_course_files, "");
234 echo get_string("no");
235 echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\">";
238 echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\">";
239 echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
245 <input type=
"hidden" name=id
value=
"<?php p($id) ?>">
246 <input type
="hidden" name
=launch value
="check">
247 <input type
="submit" value
="<?php print_string("continue") ?>">
248 <input type
="submit" name
=cancel value
="<?php print_string("cancel
") ?>">