~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to backup/restore_form.html

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
5
5
    //capabilities.
6
6
 
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' );
 
10
    }
 
11
    if (!($course_header = $SESSION->course_header)) {
 
12
      error( 'course_header object missing from session' );
 
13
    }
10
14
 
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' );
14
18
    //file
15
 
    require_variable($file);
16
 
    //info
17
 
    require_variable($info);
18
 
    //course_header
19
 
    require_variable($course_header);
 
19
    $file = required_param( 'file' );
20
20
 
21
21
    //Check login
22
22
    require_login();
67
67
    }
68
68
 
69
69
    //Check other parameters
 
70
    if (!isset($restore_metacourse)) {
 
71
        $restore_metacourse = 1;
 
72
    }
 
73
   
70
74
    if (!isset($restore_users)) {
71
75
        $restore_users = 1;
72
76
    }
83
87
        $restore_course_files = 1;
84
88
    }
85
89
 
 
90
    if (!isset($restore_messages)) {
 
91
        $restore_messages = 1;
 
92
        }
 
93
 
86
94
    if (!isset($restore_restoreto)) {
87
95
        if (isteacheredit($id) and !isadmin()) {
88
96
            $restore_restoreto = 1;
98
106
 
99
107
?>
100
108
 
101
 
<SCRIPT LANGUAGE="JavaScript">
 
109
<script language="JavaScript" type="text/javascript">
102
110
<!--
103
111
function selectItemInMenuByName(formId, menuName, selectIndex ) {
104
112
    myForm = document.getElementById(formId)
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;
111
119
        }
 
120
    }
 
121
}
 
122
 
 
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;
 
132
        }
 
133
    }
 
134
}
 
135
 
 
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;
 
144
        }
 
145
    }
112
146
}
113
147
-->
114
148
</script>
115
149
 
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">
118
152
<?php
119
153
 
120
154
    //First, course destination
121
155
    //Print the full tr
122
156
    echo "<tr>";
123
 
    echo "<td align=\"right\"><P><b>";
 
157
    echo "<td align=\"right\"><b>";
124
158
    echo get_string("restoreto").":</b>";
125
 
    echo "</td><td>";
 
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>";
137
171
    //Line
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.
142
176
        echo "<tr>";
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>";
149
 
        echo "</font></td>";
 
177
        echo "<td align=\"right\">";
 
178
        echo '<b>'.get_string("include").":</b>";
 
179
        echo "</td><td>";
 
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>";
 
184
        echo "</td>";
 
185
        echo "<td align=\"right\">";
 
186
        echo '<b>&nbsp;</b>';
 
187
        echo "</td><td>";
 
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>";
 
192
        echo "</td>";
150
193
        echo "</tr>";
151
 
        echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
 
194
        echo "<tr><td colspan=\"4\"><hr /></td></tr>";
 
195
        $currentrow = 0;
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
164
 
                        echo "<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\">&nbsp;";
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);
 
215
                        //Print the checkbox
 
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\">&nbsp;";
 
220
                        echo "</td><td>";
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"));
177
227
                        } else {
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\" />";
181
231
                        }
182
232
                        echo "</td></tr>";
183
233
                    } else {
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\" />";
187
237
                    }
188
238
                } else {
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\" />";
192
242
                }
193
243
            } else {
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\" />";
197
247
            }
 
248
            $currentrow = ($currentrow + 1) % 2;
198
249
        }
199
250
        //Line
200
 
        echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
 
251
        echo "<tr><td colspan=\"4\"><hr /></td></tr>";
201
252
 
 
253
        //Now print the Metacourse tr
 
254
        echo "<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, ""); 
 
263
        } else {
 
264
            echo get_string("no");
 
265
            echo "<input type=\"hidden\" name=\"restore_metacourse\" value=\"0\" />";
 
266
        }
 
267
        echo "</td></tr>";
202
268
        //Now print the Users tr
203
269
        echo "<tr>";
204
 
        echo "<td align=\"right\"><P><B>";
 
270
        echo "<td align=\"right\" colspan=\"2\"><b>";
205
271
        echo get_string("users").":";
206
 
        echo "</td><td>";
 
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
215
281
            choose_from_menu($user_options, "restore_users", $restore_users, "");
216
282
        } else {
217
283
            echo get_string("none");
218
 
            echo "<input type=\"hidden\" name=\"restore_users\" value=\"2\">";
 
284
            echo "<input type=\"hidden\" name=\"restore_users\" value=\"2\" />";
219
285
 
220
286
        }
221
287
        echo "</td></tr>";
222
288
 
223
289
        //Now print the Logs tr
224
290
        echo "<tr>";
225
 
        echo "<td align=\"right\"><P><B>";
 
291
        echo "<td align=\"right\" colspan=\"2\"><b>";
226
292
        echo get_string("logs").":";                                               
227
 
        echo "</td><td>";
 
293
        echo "</b></td><td colspan=\"2\">";
228
294
        //If logs are in the backup file, show menu, else fixed to no
229
295
        if ($info->backup_logs == "true") {
230
296
            $log_options[0] = get_string("no");
232
298
            choose_from_menu($log_options, "restore_logs", $restore_logs, ""); 
233
299
        } else {
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\" />";
236
302
        }
237
303
        echo "</td></tr>";
238
304
 
239
305
        //Now print the User Files tr
240
306
        echo "<tr>";
241
 
        echo "<td align=\"right\"><P><B>";
 
307
        echo "<td align=\"right\" colspan=\"2\"><b>";
242
308
        echo get_string ("userfiles").":";
243
 
        echo "</td><td>";
 
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, "");
249
315
        } else {
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\" />";
252
318
        }
253
319
        echo "</td></tr>";
254
320
 
255
321
        //Now print the Course Files tr
256
322
        echo "<tr>";
257
 
        echo "<td align=\"right\"><P><B>";
 
323
        echo "<td align=\"right\" colspan=\"2\"><b>";
258
324
        echo get_string ("coursefiles").":";
259
 
        echo "</td><td>";
 
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, "");
265
333
        } else {
266
334
            echo get_string("no");
267
 
            echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\">";
268
 
        }
269
 
        echo "</td></tr>";
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\" />";
 
336
        }
 
337
        echo "</td></tr>";
 
338
 
 
339
        //Now print the Messages tr
 
340
        echo "<tr>";
 
341
        echo "<td align=\"right\" colspan=\"2\"><b>";
 
342
        
 
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, "");
 
352
        } else {
 
353
            echo "&nbsp;</b></td><td colspan=\"2\">";
 
354
            echo "<input type=\"hidden\" name=\"restore_messages\" value=\"0\" />";
 
355
        }
 
356
        echo "</td></tr>";
272
357
    }
273
358
?>
274
359
</table>
275
 
<BR>
276
 
<CENTER>
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") ?>">
281
 
</CENTER>
282
 
</FORM>
 
360
<br />
 
361
<center>
 
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") ?>" />
 
366
</center>
 
367
</form>