MDL-24203 unused string removed
[moodle.git] / backup / restore_form.html
CommitLineData
795b6945 1<?php
fd2f02d4 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
5 //capabilities.
6
ad4375ac 7 global $DB;
8
fd2f02d4 9 //Get objects from session
35a4a791 10 if (!($info = $SESSION->info)) {
d3b7ea93 11 print_error('sessionmissing' ,'debug', '', 'info');
35a4a791 12 }
13 if (!($course_header = $SESSION->course_header)) {
d3b7ea93 14 print_error('sessionmissing' ,'debug', '', 'course_header');
35a4a791 15 }
fd2f02d4 16
b25d9087 17 $restore_gradebook_history = optional_param('restore_gradebook_history', 0, PARAM_INT);
e5d30fdc 18
fd2f02d4 19 //Check that we have all we need
20 //backup_unique_code
d4b5bd43 21 $backup_unique_code = required_param('backup_unique_code', PARAM_INT);
fd2f02d4 22 //file
d4b5bd43 23 $file = required_param('file', PARAM_PATH);
fd2f02d4 24
25 //Check login
26 require_login();
27
93f66983 28 $loginurl = get_login_url();
29
f6459d12
EL
30 //Init restoreuserinfo
31 $restoreuserinfo = false;
32
fd2f02d4 33 //Check admin
9e426d54 34 if (!empty($id)) {
d2940003 35 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))) {
93f66983 36 print_error('cannotuseadminadminorteacher', '', $loginurl);
9e426d54 37 }
f6459d12 38 $restoreuserinfo = has_capability('moodle/restore:userinfo', get_context_instance(CONTEXT_COURSE, $id));
9e426d54 39 } else {
d2940003 40 if (!has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
93f66983 41 print_error('cannotuseadmin', '', $loginurl);
9e426d54 42 }
f6459d12 43 $restoreuserinfo = has_capability('moodle/restore:userinfo', get_context_instance(CONTEXT_SYSTEM));
fd2f02d4 44 }
45
46 //Check site
3f77c158 47 $site = get_site();
fd2f02d4 48
96376e9a 49 //Checks for the required files/functions to restore every mod
fd2f02d4 50 $count = 0;
ad4375ac 51 if ($allmods = $DB->get_records("modules") ) {
fd2f02d4 52 foreach ($allmods as $mod) {
53 $modname = $mod->name;
9c1ae5ae 54 $modfile = "$CFG->dirroot/mod/$modname/restorelib.php";
fd2f02d4 55 $modrestore = $modname."_restore_mods";
fd2f02d4 56 if (file_exists($modfile)) {
57 include_once($modfile);
96376e9a 58 if (function_exists($modrestore)) {
fd2f02d4 59 $var = "exists_".$modname;
60 $$var = true;
61 $count++;
62 }
63 }
64 //Check data
65 //Check module info
66 $var = "restore_".$modname;
67 if (!isset($$var)) {
68 $$var = 1;
69 }
70 //Check include user info
71 $var = "restore_user_info_".$modname;
f6459d12 72 if (!isset($$var) && $restoreuserinfo) {
fd2f02d4 73 $$var = 1;
f6459d12
EL
74 } else {
75 $$var = 0;
fd2f02d4 76 }
77 }
78 }
79
fd2f02d4 80 if (!isset($restore_users)) {
81 $restore_users = 1;
82 }
3bee1ead 83
b0dc3e56 84 if (!isset($restore_groups)) {
98da6021 85 $restore_groups = RESTORE_GROUPS_GROUPINGS;
b0dc3e56 86 }
87
fd2f02d4 88 if (!isset($restore_logs)) {
89 $restore_logs = 1;
90 }
91
92 if (!isset($restore_user_files)) {
93 $restore_user_files = 1;
94 }
95
96 if (!isset($restore_course_files)) {
97 $restore_course_files = 1;
98 }
99
3bee1ead 100 if (!isset($restore_site_files)) {
101 $restore_site_files = 1;
102 }
103
6d1e4162 104 if (!isset($restore_messages)) {
105 $restore_messages = 1;
8b6ccde7 106 }
107
108 if (!isset($restore_blogs)) {
109 $restore_blogs = 1;
110 }
6d1e4162 111
df73f8d4 112 $cancreatecourses = user_can_create_courses();
fd2f02d4 113 if (!isset($restore_restoreto)) {
df73f8d4 114 if (!$cancreatecourses) {
64acc5a5 115 $restore_restoreto = RESTORETO_CURRENT_ADDING;
49860445 116 } else {
64acc5a5 117 $restore_restoreto = RESTORETO_NEW_COURSE;
be2a6fc6 118 }
fd2f02d4 119 }
120
111e1261 121 if (!isset($course_header->category->id)) {
122 $course_header->category->id = 0;
123 }
124
c3b307b7 125 if(!isset($form1->startdate)) {
3bee1ead 126 $form1->startdate = $course_header->course_startdate; //$course_header->course_startdate;
c3b307b7 127 }
128
129 if (empty($form1->shortname)) {
3bee1ead 130 $form1->shortname = $course_header->course_shortname; //'_shortname'; //$course_header->course_shortname;
c3b307b7 131 }
132
133 if (empty($form1->fullname)) {
3bee1ead 134 $form1->fullname = $course_header->course_fullname; // '_fullname'; //$course_header->course_fullname;
c3b307b7 135 }
136
fd2f02d4 137 if ($count == 0) {
138 notice("No restorable modules are installed!");
139 }
140
141?>
142
f4ba7e1a 143<script type="text/javascript">
70441d0f 144<!--
145function selectItemInMenuByName(formId, menuName, selectIndex ) {
4b14ebdc 146 myForm = document.getElementById(formId)
147 for (i=0,n=myForm.elements.length;i<n;i++) {
148 myLen = menuName.length;
149 myName = myForm.elements[i].name;
150 myType = myForm.elements[i].type;
b577ebc7 151 if (myName.substring(0,myLen) == menuName && myType == "select-one") {
4b14ebdc 152 myForm.elements[i].options[selectIndex].selected = true;
153 }
b577ebc7 154 }
155}
156
157function selectItemInRadioByName(formId, radioName, selectIndex ) {
158 myForm = document.getElementById(formId)
159 for (i=0,n=myForm.elements.length;i<n;i++) {
160 myLen = radioName.length;
161 myName = myForm.elements[i].name;
162 myType = myForm.elements[i].type;
163 if (myName.substring(0,myLen) == radioName && myType == "radio") {
164 myRadioGroup = myForm.elements[myName];
165 myRadioGroup[selectIndex].checked = true;
166 }
167 }
168}
169
170function selectItemInCheckboxByName(formId, checkName, checked ) {
171 myForm = document.getElementById(formId)
172 for (i=0,n=myForm.elements.length;i<n;i++) {
173 myLen = checkName.length;
174 myName = myForm.elements[i].name;
175 myType = myForm.elements[i].type;
176 if (myName.substring(0,myLen) == checkName && myType == "checkbox") {
177 myForm.elements[i].checked = checked;
178 }
179 }
70441d0f 180}
181-->
182</script>
183
b7dc2256 184<form id="form1" method="post" action="restore.php">
b3460b8e 185<div>
186<table cellpadding="5" class="boxaligncenter">
145cb8f9 187<?php
fd2f02d4 188
189 //First, course destination
190 //Print the full tr
191 echo "<tr>";
1bbf415f 192 echo "<td align=\"right\"><b>";
7f9bd149 193 echo '<label for="menurestore_restoreto">'.get_string ('restoreto').'</label>';
194 echo "</b>";
b577ebc7 195 echo "</td><td colspan=\"3\">";
3bee1ead 196
49860445 197 // permission should have been checked already
3bee1ead 198
df997f84
PS
199 //TODO: use better function which includes all courses for admins
200 $mycourses = get_user_courses_bycap($USER->id, 'moodle/restore:restorecourse');
d8b2e5e6 201
64acc5a5 202 // if the user can restore to current course, grant the "current" options
d2940003 203 if (has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_COURSE, $id))){
64acc5a5 204 $restore_restoreto_options[RESTORETO_CURRENT_DELETING] = get_string("currentcoursedeleting");
205 $restore_restoreto_options[RESTORETO_CURRENT_ADDING] = get_string("currentcourseadding");
49860445 206 }
3bee1ead 207
64acc5a5 208 // if user can create any course, grant the "new course" option
df73f8d4 209 if ($cancreatecourses) {
64acc5a5 210 $restore_restoreto_options[RESTORETO_NEW_COURSE] = get_string("newcourse");
211 }
212
213 // if the user can restore to 2 or more courses (or to just 1 but different from current), grant the "existing" options
214 if (count($mycourses) > 1 || (count($mycourses) == 1 && $mycourses[0]->id != $id)) {
215 $restore_restoreto_options[RESTORETO_EXISTING_DELETING] = get_string("existingcoursedeleting");
216 $restore_restoreto_options[RESTORETO_EXISTING_ADDING] = get_string("existingcourseadding");
be2a6fc6 217 }
3bee1ead 218
7f9bd149 219/// Acummulator for hidden options and proper XHTML output
220 $hidden_options = '';
221
d776d59e 222 echo html_writer::select($restore_restoreto_options, "restore_restoreto", $restore_restoreto, false);
fd2f02d4 223 echo "</td></tr>";
df73f8d4 224 if ($cancreatecourses) { //display these fields conditionally
3bee1ead 225
49860445 226 // find the list of cates user can edit
227 echo "<tr valign=\"top\" >";
228 echo "<td align=\"right\">";
7f9bd149 229 echo '<label for="menurestore_restorecatto">'.get_string ('category').'</label>';
230 echo "</td>";
49860445 231 echo "<td>";
a547c180 232 // Get the list of categories where the user can create courses
233 make_categories_list($categories, $parents, 'moodle/course:create');
234 $category_default = null;
235 // Best default 1: restoring in same site, use category of original course if available
236 if (backup_is_same_site($info) &&
237 !empty($course_header->category->id) &&
238 array_key_exists($course_header->category->id, $categories)) {
239 $category_default = $course_header->category->id;
240 // Best default 2: restore to the category of the course we are restoring from if available
d8b2e5e6 241 } else {
a547c180 242 $fromcat = $DB->get_field('course', 'category', array('id' => $id));
243 if (!empty($fromcat) &&
244 array_key_exists($fromcat, $categories)) {
245 $category_default = $fromcat;
246 }
d8b2e5e6 247 }
d776d59e 248 echo html_writer::select($categories, 'restore_restorecatto', $category_default, false);
49860445 249 echo "</td>";
250 echo "</tr>";
3bee1ead 251
c3b307b7 252 echo "<tr valign=\"top\" >";
253 echo "<td align=\"right\">";
7f9bd149 254 echo '<label for="shortnamefield">'.get_string ('shortname').'</label>';
255 echo "</td>";
123d1acd 256 echo "<td><input type=\"text\" id=\"shortnamefield\" name=\"shortname\" maxlength=\"100\" size=\"20\" value=\"".s($form1->shortname)."\" alt=\"".get_string("shortname")."\" />" ;
5fb88219 257 echo $OUTPUT->help_icon('shortnamecourse'));
8cc826b2 258 if (isset($err["shortname"])) echo $OUTPUT->error_text($err["shortname"]);
33bd434d 259 echo "</td>";
260 echo "</tr>";
c3b307b7 261 echo "<tr valign=\"top\" >";
262 echo "<td align=\"right\">";
7f9bd149 263 echo '<label for="fullnamefield">'.get_string ('fullname').'</label>';
264 echo "</td>";
123d1acd 265 echo "<td><input type=\"text\" id=\"fullnamefield\" name=\"fullname\" maxlength=\"254\" size=\"50\" value=\"".s($form1->fullname)."\" alt=\" ".get_string("fullname")."\" />" ;
9f48fa37 266 echo $OUTPUT->help_icon('fullnamecourse');
8cc826b2 267 if (isset($err["fullname"])) echo $OUTPUT->error_text($err["fullname"]);
c3b307b7 268 echo"</td></tr>";
81b06e9b 269 } else {
270 // nothing to show here if the user cannot create users
271 }
272
273 // If user can roll dates (in any course is enough for now) show the roll dates option.
274 // Important: The final restore check step will validate, once we know the final category/course
275 // where the restore is happening, if the user is really capable of rolling dates there, noticing
276 // and disabling roll if not allowed.
277 if (restore_user_can_roll_dates()) {
c3b307b7 278 echo "<tr valign=\"top\"> ";
279 echo "<td align=\"right\"> ";
3bee1ead 280 print_string("startdate");
7f9bd149 281 echo "</td><td>";
bac43d63 282 /// Show the roll dates option only if the backup course has a start date
283 /// (some formats like main page, social..., haven't it and rolling dates
284 /// from 0 produces crazy dates. MDL-10125
285 if ($form1->startdate) {
f83b9b63
PS
286 $dayselector = html_writer::select_time('days', "startday", $form1->startdate);
287 $monthselector = html_writer::select_time('months', "startmonth", $form1->startdate);
288 $yearselector = html_writer::select_time('years', "startyear", $form1->startdate);
bb587f9b 289
f83b9b63 290 echo $dayselector . $monthselector . $yearselector;
5fb88219 291 echo $OUTPUT->help_icon('startdate'));
bac43d63 292 } else {
293 print_string('notavailable');
294 echo '<input type="hidden" name="startyear" value="0" />';
295 echo '<input type="hidden" name="startmonth" value="0" />';
296 echo '<input type="hidden" name="startday" value="0" />';
297 }
c3b307b7 298 echo "</td></tr>";
6c928b4c 299 } else {
81b06e9b 300 /// If user lacks the moodle/restore:rolldates completely, prevent any change in startyear/month/day (so restore won't perform any roll)
6c928b4c 301 echo '<input type="hidden" name="startyear" value="0" />';
302 echo '<input type="hidden" name="startmonth" value="0" />';
303 echo '<input type="hidden" name="startday" value="0" />';
c3b307b7 304 }
fd2f02d4 305 //Line
b577ebc7 306 echo "<tr><td colspan=\"4\"><hr /></td></tr>";
fd2f02d4 307 //Now, check modules and info and show posibilities
ad4375ac 308 if ($allmods = $DB->get_records("modules") ) {
b577ebc7 309 //Print option to select/deselect everything with 1 click.
70441d0f 310 echo "<tr>";
b577ebc7 311 echo "<td align=\"right\">";
7f9bd149 312 echo '<b>'.get_string("include")."</b>";
b577ebc7 313 echo "</td><td>";
314 echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', true);\">".
315 get_string("all")."</a>/";
316 echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', false);\">".
317 get_string("none")."</a>";
318 echo "</td>";
f6459d12
EL
319 if ($restoreuserinfo) {
320 echo "<td align=\"right\">";
321 echo '<b>&nbsp;</b>';
322 echo "</td><td>";
323 echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', true);\">".
324 get_string("all")."</a>/";
325 echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', false);\">".
326 get_string("none")."</a>";
327 echo "</td>";
328 } else {
329 echo "<td colspan=\"2\">&nbsp;</td>";
330 }
70441d0f 331 echo "</tr>";
b577ebc7 332 echo "<tr><td colspan=\"4\"><hr /></td></tr>";
333 $currentrow = 0;
1a73a3d8 334 $nonrestmod = '';
fd2f02d4 335 foreach ($allmods as $mod) {
336 $modname = $mod->name;
337 $modrestore = $modname."_restore_mods";
338 //If exists the lib & function
96376e9a 339 $exist = "exists_".$modname;
304d7785 340 $restore_var = "restore_".$modname;
341 $user_info_var = "restore_user_info_".$modname;
142a6a46 342 if (isset($$exist)) {
343 if ($$exist) {
344 //Now check that we have that module info in the backup file
345 if (isset($info->mods[$modname]) && $info->mods[$modname]->backup == "true") {
346 //Print the full tr
b577ebc7 347 echo "<tr class=\"r".$currentrow."\">";
348 echo "<td align=\"right\">&nbsp;";
349 echo "</td><td>";
142a6a46 350 $restore_options[1] = get_string("yes");
3bee1ead 351 $restore_options[0] = get_string("no");
b577ebc7 352 //Print the checkbox
1ecea976 353 print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'restore_'.$modname.'\',this.checked)');
142a6a46 354 //If backup contains user data, then show menu, else fix it to
355 //without user data
b577ebc7 356 echo "</td><td align=\"right\">&nbsp;";
357 echo "</td><td>";
f6459d12 358 if ($info->mods[$modname]->userinfo == "true" && $restoreuserinfo) {
b577ebc7 359 $restore_user_options[1] = get_string("yes");
3bee1ead 360 $restore_user_options[0] = get_string("no");
1ecea976 361 print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'restore_user_info_'.$modname.'\',this.checked)');
142a6a46 362 } else {
363 //Module haven't userdata
364 echo get_string("withoutuserdata");
1bbf415f 365 echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
142a6a46 366 }
367 echo "</td></tr>";
ffd0ab65 368 if (isset($info->mods[$modname]->instances)) {
369 $instances = $info->mods[$modname]->instances;
370 }
1ecea976 371 if (!empty($instances) && is_array($instances)) {
372 echo '<tr><td></td><td colspan="3"><table class="restore-form-instances">';
373 foreach ($instances as $instance) {
374 echo '<tr><td>';
375 $var = 'restore_'.$modname.'_instance_'.$instance->id;
92ebcabe 376 $$var = optional_param($var,1, PARAM_CLEAN);
1ecea976 377 print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'restore_'.$modname.'\'].checked=1;');
378 echo '</td><td align="right">&nbsp;';
379 $var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
92ebcabe 380 $$var = optional_param($var,1, PARAM_CLEAN);
f6459d12 381 if (!empty($info->mods[$modname]->instances) && ($info->mods[$modname]->instances[$instance->id]->userinfo == 'true') && $restoreuserinfo) {
1ecea976 382 print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'restore_user_info_'.$modname.'\'].checked=1;');
383 } else {
384 echo '<input type="hidden" name="'.$var.'" value="0" />';
385 }
386 echo '</td></tr>';
387 }
388 echo '</table></td></tr>';
389 }
96376e9a 390 } else {
142a6a46 391 //Module isn't restorable
b3460b8e 392 $nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
393 $nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
96376e9a 394 }
96376e9a 395 } else {
396 //Module isn't restorable
b3460b8e 397 $nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
398 $nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
96376e9a 399 }
400 } else {
401 //Module isn't restorable
b3460b8e 402 $nonrestmod .= "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
403 $nonrestmod .= "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
fd2f02d4 404 }
b577ebc7 405 $currentrow = ($currentrow + 1) % 2;
fd2f02d4 406 }
407 //Line
b3460b8e 408 echo "<tr><td colspan=\"4\">$nonrestmod<hr /></td></tr>";
fd2f02d4 409
410 //Now print the Users tr
411 echo "<tr>";
b577ebc7 412 echo "<td align=\"right\" colspan=\"2\"><b>";
7f9bd149 413 echo '<label for="menurestore_users">'.get_string ("users").'</label>';
b577ebc7 414 echo "</b></td><td colspan=\"2\">";
fa96ad2f 415 //If some user is present in the backup file
f6459d12 416 if (($info->backup_users == "all" or $info->backup_users == "course") and $restoreuserinfo) {
7f9bd149 417 $user_options = array();
d2940003
EL
418 //If all users are in the backup file and user has 'moodle/restore:restorecourse' at system level
419 if ($info->backup_users == "all" and has_capability('moodle/restore:restorecourse', get_context_instance(CONTEXT_SYSTEM))) {
fa96ad2f 420 $user_options[0] = get_string("all");
421 }
422 $user_options[1] = get_string("course");
423 $user_options[2] = get_string("none");
d776d59e 424 echo html_writer::select($user_options, "restore_users", $restore_users, false);
fa96ad2f 425 } else {
426 echo get_string("none");
7f9bd149 427 echo "<input type=\"hidden\" id=\"menurestore_users\" name=\"restore_users\" value=\"2\" />";
fa96ad2f 428
96376e9a 429 }
fd2f02d4 430 echo "</td></tr>";
431
b0dc3e56 432 //Now print the Groups tr (assume there is no $info->backup_groups)
433 echo "<tr>";
434 echo "<td align=\"right\" colspan=\"2\"><b>";
f6459d12
EL
435 echo '<label for="menurestore_groups">'.get_string ("groups").'</label>'.$helplink;
436 echo "</b></td><td colspan=\"2\">";
98da6021
PS
437 $group_options[RESTORE_GROUPS_NONE] = get_string('none');
438 $group_options[RESTORE_GROUPS_ONLY] = get_string('groupsonly', 'group');
439 $group_options[RESTORE_GROUPINGS_ONLY] = get_string('groupingsonly', 'group');
440 $group_options[RESTORE_GROUPS_GROUPINGS] = get_string('groupsgroupings', 'group'); //all.
d776d59e 441 echo html_writer::select($group_options, 'restore_groups', $restore_groups, false);
b0dc3e56 442 echo "</td></tr>";
443
fd2f02d4 444 //Now print the Logs tr
445 echo "<tr>";
b577ebc7 446 echo "<td align=\"right\" colspan=\"2\"><b>";
7f9bd149 447 echo '<label for="menurestore_logs">'.get_string ("logs").'</label>';
b577ebc7 448 echo "</b></td><td colspan=\"2\">";
96376e9a 449 //If logs are in the backup file, show menu, else fixed to no
f6459d12 450 if ($info->backup_logs == "true" and $restoreuserinfo) {
7f9bd149 451 $log_options = array();
96376e9a 452 $log_options[0] = get_string("no");
3bee1ead 453 $log_options[1] = get_string("yes");
d776d59e 454 echo html_writer::select($log_options, "restore_logs", $restore_logs, false);
96376e9a 455 } else {
456 echo get_string("no");
7f9bd149 457 echo "<input type=\"hidden\" id=\"menurestore_logs\" name=\"restore_logs\" value=\"0\" />";
96376e9a 458 }
fd2f02d4 459 echo "</td></tr>";
460
461 //Now print the User Files tr
462 echo "<tr>";
b577ebc7 463 echo "<td align=\"right\" colspan=\"2\"><b>";
7f9bd149 464 echo '<label for="menurestore_user_files">'.get_string ("userfiles").'</label>';
b577ebc7 465 echo "</b></td><td colspan=\"2\">";
96376e9a 466 //If user files are in the backup file, show menu, else fixed to no
f6459d12 467 if ($info->backup_user_files == "true" and $restoreuserinfo) {
7f9bd149 468 $user_file_options = array();
3bee1ead 469 $user_file_options[0] = get_string("no");
470 $user_file_options[1] = get_string("yes");
d776d59e 471 echo html_writer::select($user_file_options, "restore_user_files", $restore_user_files, false);
96376e9a 472 } else {
473 echo get_string("no");
7f9bd149 474 echo "<input type=\"hidden\" id=\"menurestore_user_files\" name=\"restore_user_files\" value=\"0\" />";
96376e9a 475 }
fd2f02d4 476 echo "</td></tr>";
477
478 //Now print the Course Files tr
479 echo "<tr>";
b577ebc7 480 echo "<td align=\"right\" colspan=\"2\"><b>";
7f9bd149 481 echo '<label for="menurestore_course_files">'.get_string ("coursefiles").'</label>';
b577ebc7 482 echo "</b></td><td colspan=\"2\">";
1bbf415f 483 echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\" />";
484 echo "<input type=\"hidden\" name=\"file\" value=\"$file\" />";
96376e9a 485 //If course files are in the backup file, show menu, else fixed to no
486 if ($info->backup_course_files == "true") {
7f9bd149 487 $course_file_options = array();
96376e9a 488 $course_file_options[0] = get_string("no");
489 $course_file_options[1] = get_string("yes");
d776d59e 490 echo html_writer::select($course_file_options, "restore_course_files", $restore_course_files, false);
96376e9a 491 } else {
492 echo get_string("no");
7f9bd149 493 echo "<input type=\"hidden\" id=\"menurestore_course_files\" name=\"restore_course_files\" value=\"0\" />";
96376e9a 494 }
fd2f02d4 495 echo "</td></tr>";
6d1e4162 496
3bee1ead 497
498 //Now print the Site Files tr
499 echo "<tr>";
500 echo "<td align=\"right\" colspan=\"2\"><b>";
7f9bd149 501 echo '<label for="menurestore_site_files">'.get_string ("sitefiles").'</label>';
3bee1ead 502 echo "</b></td><td colspan=\"2\">";
503 //If site files are in the backup file, show menu, else fixed to no
1a73a3d8 504 if (isset($info->backup_site_files) && $info->backup_site_files == "true") {
7f9bd149 505 $site_file_options = array();
3bee1ead 506 $site_file_options[0] = get_string("no");
507 $site_file_options[1] = get_string("yes");
d776d59e 508 echo html_writer::select($site_file_options, "restore_site_files", $restore_site_files, false);
3bee1ead 509 } else {
510 echo get_string("no");
7f9bd149 511 echo "<input type=\"hidden\" id=\"menurestore_site_files\" name=\"restore_site_files\" value=\"0\" />";
3bee1ead 512 }
513 echo "</td></tr>";
7b2f3680 514
e5d30fdc 515 // do you want grade histories to be restored?
f6459d12 516 if (empty($CFG->disablegradehistory) and $restoreuserinfo) {
7f9bd149 517 echo "<tr>";
518 echo "<td align=\"right\" colspan=\"2\"><b>";
519 echo '<label for="menurestore_gradebook_history">'.get_string ('gradebookhistories', 'grades').'</label>';
520 echo "</b></td><td colspan=\"2\">";
521 if (isset($info->gradebook_histories) && $info->gradebook_histories == "true") {
522 $gradebook_history_options = array();
523 $gradebook_history_options[0] = get_string("no");
524 $gradebook_history_options[1] = get_string("yes");
d776d59e 525 echo html_writer::select($gradebook_history_options, "restore_gradebook_history", $restore_gradebook_history, false);
7f9bd149 526 } else {
527 echo get_string("no");
528 echo "<input type=\"hidden\" id=\"menurestore_gradebook_history\" name=\"restore_gradebook_history\" value=\"0\" />";
529 }
530 echo "</td></tr>";
531 } else {
532 $hidden_options .= '<input type="hidden" name="restore_gradebook_history" value="0" />';
533 }
3bee1ead 534
6d1e4162 535 //This tr is slighty different. Everything becomes hidden if
536 //we haven't messages is the backup, to avoid confusions to users.
537 //If messages are in the backup file, show menu, else fixed to no and show nothing
8b6ccde7 538 //Also, messaging must be enabled in the destination site
f6459d12 539 if (isset($info->backup_messages) && $info->backup_messages == "true" && !empty($CFG->messaging) and $restoreuserinfo) {
7f9bd149 540 echo "<tr>";
541 echo "<td align=\"right\" colspan=\"2\"><b>";
59d6852b 542 echo '<label for="menurestore_messages">'.get_string ('messages', 'message').'</label>';
b577ebc7 543 echo "</b></td><td colspan=\"2\">";
7f9bd149 544 $message_options = array();
6d1e4162 545 $message_options[0] = get_string("no");
546 $message_options[1] = get_string("yes");
d776d59e 547 echo html_writer::select($message_options, "restore_messages", $restore_messages, false);
7f9bd149 548 echo "</td></tr>";
6d1e4162 549 } else {
7f9bd149 550 $hidden_options .= '<input type="hidden" name="restore_messages" value="0" />';
6d1e4162 551 }
8b6ccde7 552
553 //This tr is slighty different. Everything becomes hidden if
554 //we haven't blogs is the backup, to avoid confusions to users.
555 //If blogs are in the backup file, show menu, else fixed to no and show nothing
556 //Also, blogs must be enabled in the destination site
f6459d12 557 if (isset($info->backup_blogs) && $info->backup_blogs == "true" && !empty($CFG->bloglevel) and $restoreuserinfo) {
8b6ccde7 558 echo "<tr>";
559 echo "<td align=\"right\" colspan=\"2\"><b>";
560 echo '<label for="menurestore_blogs">'.get_string ('blogs', 'blog').'</label>';
561 echo "</b></td><td colspan=\"2\">";
562 $blog_options = array();
563 $blog_options[0] = get_string("no");
564 $blog_options[1] = get_string("yes");
d776d59e 565 echo html_writer::select($blog_options, "restore_blogs", $restore_blogs, false);
8b6ccde7 566 echo "</td></tr>";
567 } else {
568 $hidden_options .= '<input type="hidden" name="restore_blogs" value="0" />';
569 }
570
fd2f02d4 571 }
572?>
db451e99 573</table>
8020a016 574