1
<?PHP //$Id: restore_form.html,v 1.15.4.1 2004/09/23 11:25:44 moodler Exp $
1
<?php //$Id: restore_form.html,v 1.21.2.2 2005/06/29 16:56:23 stronk7 Exp $
2
2
//This page prints the restore form to select everything yo want
3
3
//to restore. Form is dinamically buid, depending of "info" object
4
4
//that contains the backup contents and depending of every mod
7
7
//Get objects from session
8
$info = $SESSION->info;
9
$course_header = $SESSION->course_header;
8
if (!($info = $SESSION->info)) {
9
error( 'info object missing from session' );
11
if (!($course_header = $SESSION->course_header)) {
12
error( 'course_header object missing from session' );
11
15
//Check that we have all we need
12
16
//backup_unique_code
13
require_variable($backup_unique_code);
17
$backup_unique_code = required_param( 'backup_unique_code' );
15
require_variable($file);
17
require_variable($info);
19
require_variable($course_header);
19
$file = required_param( 'file' );
106
114
myLen = menuName.length;
107
115
myName = myForm.elements[i].name;
108
116
myType = myForm.elements[i].type;
109
if (myName.substring(0,myLen) == menuName && myType == "select-one")
117
if (myName.substring(0,myLen) == menuName && myType == "select-one") {
110
118
myForm.elements[i].options[selectIndex].selected = true;
123
function selectItemInRadioByName(formId, radioName, selectIndex ) {
124
myForm = document.getElementById(formId)
125
for (i=0,n=myForm.elements.length;i<n;i++) {
126
myLen = radioName.length;
127
myName = myForm.elements[i].name;
128
myType = myForm.elements[i].type;
129
if (myName.substring(0,myLen) == radioName && myType == "radio") {
130
myRadioGroup = myForm.elements[myName];
131
myRadioGroup[selectIndex].checked = true;
136
function selectItemInCheckboxByName(formId, checkName, checked ) {
137
myForm = document.getElementById(formId)
138
for (i=0,n=myForm.elements.length;i<n;i++) {
139
myLen = checkName.length;
140
myName = myForm.elements[i].name;
141
myType = myForm.elements[i].type;
142
if (myName.substring(0,myLen) == checkName && myType == "checkbox") {
143
myForm.elements[i].checked = checked;
116
<form name="form1" id="form1" method="post" action="<?php echo $ME ?>">
117
<table cellpadding=5>
150
<form name="form1" id="form1" method="post" action="restore.php">
151
<table cellpadding="5">
120
154
//First, course destination
121
155
//Print the full tr
123
echo "<td align=\"right\"><P><b>";
157
echo "<td align=\"right\"><b>";
124
158
echo get_string("restoreto").":</b>";
159
echo "</td><td colspan=\"3\">";
126
160
if (isteacheredit($id) and !iscreator()) {
127
161
$restore_restoreto_options[0] = get_string("currentcoursedeleting");
128
162
$restore_restoreto_options[1] = get_string("currentcourseadding");
135
169
choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
136
170
echo "</td></tr>";
138
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
172
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
139
173
//Now, check modules and info and show posibilities
140
174
if ($allmods = get_records("modules") ) {
141
//Print option to select/deselect every "with user info" popup. For Gustav, lol, Eloy :-)
175
//Print option to select/deselect everything with 1 click.
143
echo "<td colspan=\"2\" align=\"right\"><font size=\"-1\">";
144
echo get_string("userdata").":";
145
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInMenuByName('form1', 'restore_user_info_', '1');\">".
146
get_string("all")."</a>/";
147
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInMenuByName('form1', 'restore_user_info_', '0');\">".
148
get_string("none")."</a>";
177
echo "<td align=\"right\">";
178
echo '<b>'.get_string("include").":</b>";
180
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', true);\">".
181
get_string("all")."</a>/";
182
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', false);\">".
183
get_string("none")."</a>";
185
echo "<td align=\"right\">";
186
echo '<b> </b>';
188
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', true);\">".
189
get_string("all")."</a>/";
190
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', false);\">".
191
get_string("none")."</a>";
151
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
194
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
152
196
foreach ($allmods as $mod) {
153
197
$modname = $mod->name;
154
198
$modrestore = $modname."_restore_mods";
161
205
//Now check that we have that module info in the backup file
162
206
if (isset($info->mods[$modname]) && $info->mods[$modname]->backup == "true") {
163
207
//Print the full tr
165
echo "<td align=\"right\"><P><B>";
166
echo get_string("include")." ". get_string("modulenameplural",$modname).":";
208
echo "<tr class=\"r".$currentrow."\">";
209
echo "<td align=\"right\"> ";
167
210
echo "</td><td>";
211
$restore_options[1] = get_string("yes");
168
212
$restore_options[0] = get_string("no");
169
$restore_options[1] = get_string("yes");
170
choose_from_menu($restore_options, $restore_var, $$restore_var, "");
213
//choose_from_menu($restore_options, $restore_var, $$restore_var, "");
214
//choose_from_radio($restore_options, $restore_var, $$restore_var);
216
print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname));
171
217
//If backup contains user data, then show menu, else fix it to
172
218
//without user data
219
echo "</td><td align=\"right\"> ";
173
221
if ($info->mods[$modname]->userinfo == "true") {
174
$restore_user_options[0] = get_string("withoutuserdata");
175
$restore_user_options[1] = get_string("withuserdata");
176
choose_from_menu($restore_user_options, $user_info_var, $$user_info_var, "");
222
$restore_user_options[1] = get_string("yes");
223
$restore_user_options[0] = get_string("no");
224
//choose_from_menu($restore_user_options, $user_info_var, $$user_info_var, "");
225
//choose_from_radio($restore_user_options, $user_info_var, $$user_info_var);
226
print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"));
178
228
//Module haven't userdata
179
229
echo get_string("withoutuserdata");
180
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
230
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
182
232
echo "</td></tr>";
184
234
//Module isn't restorable
185
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
186
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
235
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
236
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
189
239
//Module isn't restorable
190
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
191
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
240
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
241
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
194
244
//Module isn't restorable
195
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\">";
196
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\">";
245
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
246
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
248
$currentrow = ($currentrow + 1) % 2;
200
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
251
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
253
//Now print the Metacourse tr
255
echo "<td align=\"right\" colspan=\"2\"><b>";
256
echo get_string("metacourse").":";
257
echo "</b></td><td colspan=\"2\">";
258
//If metacourse are in the backup file, show menu, else fixed to no
259
if ($info->backup_metacourse == "true") {
260
$metacourse_options[0] = get_string("no");
261
$metacourse_options[1] = get_string("yes");
262
choose_from_menu($metacourse_options, "restore_metacourse", $restore_metacourse, "");
264
echo get_string("no");
265
echo "<input type=\"hidden\" name=\"restore_metacourse\" value=\"0\" />";
202
268
//Now print the Users tr
204
echo "<td align=\"right\"><P><B>";
270
echo "<td align=\"right\" colspan=\"2\"><b>";
205
271
echo get_string("users").":";
272
echo "</b></td><td colspan=\"2\">";
207
273
//If some user is present in the backup file
208
274
if ($info->backup_users == "all" or $info->backup_users == "course") {
209
275
//If all users are in the backup file
232
298
choose_from_menu($log_options, "restore_logs", $restore_logs, "");
234
300
echo get_string("no");
235
echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\">";
301
echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\" />";
237
303
echo "</td></tr>";
239
305
//Now print the User Files tr
241
echo "<td align=\"right\"><P><B>";
307
echo "<td align=\"right\" colspan=\"2\"><b>";
242
308
echo get_string ("userfiles").":";
309
echo "</b></td><td colspan=\"2\">";
244
310
//If user files are in the backup file, show menu, else fixed to no
245
311
if ($info->backup_user_files == "true") {
246
312
$user_file_options[0] = get_string("no");
248
314
choose_from_menu($user_file_options, "restore_user_files", $restore_user_files, "");
250
316
echo get_string("no");
251
echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\">";
317
echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\" />";
253
319
echo "</td></tr>";
255
321
//Now print the Course Files tr
257
echo "<td align=\"right\"><P><B>";
323
echo "<td align=\"right\" colspan=\"2\"><b>";
258
324
echo get_string ("coursefiles").":";
325
echo "</b></td><td colspan=\"2\">";
326
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\" />";
327
echo "<input type=\"hidden\" name=\"file\" value=\"$file\" />";
260
328
//If course files are in the backup file, show menu, else fixed to no
261
329
if ($info->backup_course_files == "true") {
262
330
$course_file_options[0] = get_string("no");
264
332
choose_from_menu($course_file_options, "restore_course_files", $restore_course_files, "");
266
334
echo get_string("no");
267
echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\">";
270
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\">";
271
echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
335
echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\" />";
339
//Now print the Messages tr
341
echo "<td align=\"right\" colspan=\"2\"><b>";
343
//This tr is slighty different. Everything becomes hidden if
344
//we haven't messages is the backup, to avoid confusions to users.
345
//If messages are in the backup file, show menu, else fixed to no and show nothing
346
if ($info->backup_messages == "true") {
347
echo get_string ('messages','message').":";
348
echo "</b></td><td colspan=\"2\">";
349
$message_options[0] = get_string("no");
350
$message_options[1] = get_string("yes");
351
choose_from_menu($message_options, "restore_messages", $restore_messages, "");
353
echo " </b></td><td colspan=\"2\">";
354
echo "<input type=\"hidden\" name=\"restore_messages\" value=\"0\" />";
277
<input type="hidden" name=id value="<?php p($id) ?>">
278
<input type="hidden" name=launch value="check">
279
<input type="submit" value="<?php print_string("continue") ?>">
280
<input type="submit" name=cancel value="<?php print_string("cancel") ?>">
362
<input type="hidden" name="id" value="<?php p($id) ?>" />
363
<input type="hidden" name="launch" value="check" />
364
<input type="submit" value="<?php print_string("continue") ?>" />
365
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />