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 error(
"You need to be an admin user to use this page.",
"$CFG->wwwroot/login/index.php");
30 if (!$site = get_site()) {
31 error(
"Site not found!");
34 //Checks for the required files/functions to restore every mod
36 if ($allmods = get_records(
"modules") ) {
37 foreach ($allmods as $mod) {
38 $modname = $mod-
>name;
39 $modfile =
"$mods_home/$modname/restorelib.php";
40 $modrestore = $modname.
"_restore_mods";
41 if (file_exists($modfile)) {
42 include_once($modfile);
43 if (function_exists($modrestore)) {
44 $var =
"exists_".$modname;
51 $var =
"restore_".$modname;
55 //Check include user info
56 $var =
"restore_user_info_".$modname;
63 //Check other parameters
64 if (!isset($restore_users)) {
68 if (!isset($restore_logs)) {
72 if (!isset($restore_user_files)) {
73 $restore_user_files =
1;
76 if (!isset($restore_course_files)) {
77 $restore_course_files =
1;
80 if (!isset($restore_restoreto)) {
81 $restore_restoreto =
1;
85 notice(
"No restorable modules are installed!");
90 <form name=
"form" method=
"post" <?=$onsubmit
?> action=
"<?=$ME ?>">
94 //First, course destination
97 echo
"<td align=\"right\
"><P><b>";
98 echo get_string(
"restoreto").
":</b>";
100 $restore_restoreto_options[
0] = get_string(
"existingcourse");
101 $restore_restoreto_options[
1] = get_string(
"newcourse");
102 choose_from_menu($restore_restoreto_options,
"restore_restoreto", $restore_restoreto,
"");
105 echo
"<tr><td colspan=\"2\
"><hr noshade size=\"1\
"></td></tr>";
106 //Now, check modules and info and show posibilities
107 if ($allmods = get_records(
"modules") ) {
108 foreach ($allmods as $mod) {
109 $modname = $mod-
>name;
110 $modrestore = $modname.
"_restore_mods";
111 //If exists the lib & function
112 $exist =
"exists_".$modname;
113 $restore_var =
"restore_".$modname;
114 $user_info_var =
"restore_user_info_".$modname;
116 //Now check that we have that module info in the backup file
117 if ($info-
>mods[$modname]-
>backup ==
"true") {
120 echo
"<td align=\"right\
"><P><B>";
121 echo get_string(
"include").
" ". get_string(
"modulenameplural",$modname).
":";
123 $restore_options[
0] = get_string(
"no");
124 $restore_options[
1] = get_string(
"yes");
125 choose_from_menu($restore_options, $restore_var, $$restore_var,
"");
126 //If backup contains user data, then show menu, else fix it to
128 if ($info-
>mods[$modname]-
>userinfo ==
"true") {
129 $restore_user_options[
0] = get_string(
"withoutuserdata");
130 $restore_user_options[
1] = get_string(
"withuserdata");
131 choose_from_menu($restore_user_options, $user_info_var, $$user_info_var,
"");
133 //Module haven't userdata
134 echo get_string(
"withoutuserdata");
135 echo
"<input type=\"hidden\
" name=\"$user_info_var\
" value=\"0\
">";
139 //Module isn't restorable
140 echo
"<input type=\"hidden\
" name=\"$restore_var\
" value=\"0\
">";
141 echo
"<input type=\"hidden\
" name=\"$user_info_var\
" value=\"0\
">";
144 //Module isn't restorable
145 echo
"<input type=\"hidden\
" name=\"$restore_var\
" value=\"0\
">";
146 echo
"<input type=\"hidden\
" name=\"$user_info_var\
" value=\"0\
">";
150 echo
"<tr><td colspan=\"2\
"><hr noshade size=\"1\
"></td></tr>";
152 //Now print the Users tr
154 echo
"<td align=\"right\
"><P><B>";
155 echo get_string(
"users").
":";
157 //If all users are in the backup file
158 if ($info-
>backup_users ==
"all") {
159 $user_options[
0] = get_string(
"all");
161 $user_options[
1] = get_string(
"course");
162 $user_options[
2] = get_string(
"none");
163 //$user_options[
2] = get_string(
"needed");-->NOT IMPLEMENTED
164 choose_from_menu($user_options,
"restore_users", $restore_users,
"");
167 //Now print the Logs tr
169 echo
"<td align=\"right\
"><P><B>";
170 echo get_string(
"logs").
":";
172 //If logs are in the backup file, show menu, else fixed to no
173 if ($info-
>backup_logs ==
"true") {
174 $log_options[
0] = get_string(
"no");
175 $log_options[
1] = get_string(
"yes");
176 choose_from_menu($log_options,
"restore_logs", $restore_logs,
"");
178 echo get_string(
"no");
179 echo
"<input type=\"hidden\
" name=\"restore_logs\
" value=\"0\
">";
183 //Now print the User Files tr
185 echo
"<td align=\"right\
"><P><B>";
186 echo get_string (
"userfiles").
":";
188 //If user files are in the backup file, show menu, else fixed to no
189 if ($info-
>backup_user_files ==
"true") {
190 $user_file_options[
0] = get_string(
"no");
191 $user_file_options[
1] = get_string(
"yes");
192 choose_from_menu($user_file_options,
"restore_user_files", $restore_user_files,
"");
194 echo get_string(
"no");
195 echo
"<input type=\"hidden\
" name=\"restore_user_files\
" value=\"0\
">";
199 //Now print the Course Files tr
201 echo
"<td align=\"right\
"><P><B>";
202 echo get_string (
"coursefiles").
":";
204 //If course files are in the backup file, show menu, else fixed to no
205 if ($info-
>backup_course_files ==
"true") {
206 $course_file_options[
0] = get_string(
"no");
207 $course_file_options[
1] = get_string(
"yes");
208 choose_from_menu($course_file_options,
"restore_course_files", $restore_course_files,
"");
210 echo get_string(
"no");
211 echo
"<input type=\"hidden\
" name=\"restore_course_files\
" value=\"0\
">";
214 echo
"<input type=\"hidden\
" name=\"backup_unique_code\
" value=\"$backup_unique_code\
">";
215 echo
"<input type=\"hidden\
" name=\"file\
" value=\"$file\
">";
221 <input type=
"hidden" name=id
value=
"<? p($id) ?>">
222 <input type=
"hidden" name=launch
value=
"check">
223 <input type=
"submit" value=
"<? print_string("continue
") ?>">
224 <input type=
"submit" name=cancel
value=
"<? print_string("cancel
") ?>">