Permalink
Browse files

Now the restore form page is a bit more easy to use. Bug 1430.

  • Loading branch information...
stronk7
stronk7 committed Jun 29, 2005
1 parent 3fc2938 commit 4eb4ad04dbb872413a62f073830aa34fabd1a75b
Showing with 78 additions and 35 deletions.
  1. +2 −2 backup/restore_check.html
  2. +76 −33 backup/restore_form.html
@@ -39,9 +39,9 @@
foreach ($allmods as $mod) {
$modname = $mod->name;
$var = "restore_".$modname;
$$var = required_param( $var);
$$var = optional_param( $var,0);
$var = "restore_user_info_".$modname;
$$var = required_param( $var);
$$var = optional_param( $var,0);
}
}
//restoreto
View
@@ -114,9 +114,35 @@
myLen = menuName.length;
myName = myForm.elements[i].name;
myType = myForm.elements[i].type;
if (myName.substring(0,myLen) == menuName && myType == "select-one")
if (myName.substring(0,myLen) == menuName && myType == "select-one") {
myForm.elements[i].options[selectIndex].selected = true;
}
}
}
function selectItemInRadioByName(formId, radioName, selectIndex ) {
myForm = document.getElementById(formId)
for (i=0,n=myForm.elements.length;i<n;i++) {
myLen = radioName.length;
myName = myForm.elements[i].name;
myType = myForm.elements[i].type;
if (myName.substring(0,myLen) == radioName && myType == "radio") {
myRadioGroup = myForm.elements[myName];
myRadioGroup[selectIndex].checked = true;
}
}
}
function selectItemInCheckboxByName(formId, checkName, checked ) {
myForm = document.getElementById(formId)
for (i=0,n=myForm.elements.length;i<n;i++) {
myLen = checkName.length;
myName = myForm.elements[i].name;
myType = myForm.elements[i].type;
if (myName.substring(0,myLen) == checkName && myType == "checkbox") {
myForm.elements[i].checked = checked;
}
}
}
-->
</script>
@@ -130,7 +156,7 @@
echo "<tr>";
echo "<td align=\"right\"><b>";
echo get_string("restoreto").":</b>";
echo "</td><td>";
echo "</td><td colspan=\"3\">";
if (isteacheredit($id) and !iscreator()) {
$restore_restoreto_options[0] = get_string("currentcoursedeleting");
$restore_restoreto_options[1] = get_string("currentcourseadding");
@@ -143,20 +169,30 @@
choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
echo "</td></tr>";
//Line
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
//Now, check modules and info and show posibilities
if ($allmods = get_records("modules") ) {
//Print option to select/deselect every "with user info" popup. For Gustav, lol, Eloy :-)
//Print option to select/deselect everything with 1 click.
echo "<tr>";
echo "<td colspan=\"2\" align=\"right\"><font size=\"-1\">";
echo get_string("userdata").":";
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInMenuByName('form1', 'restore_user_info_', '1');\">".
echo "<td align=\"right\">";
echo '<b>'.get_string("include").":</b>";
echo "</td><td>";
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', true);\">".
get_string("all")."</a>/";
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', false);\">".
get_string("none")."</a>";
echo "</td>";
echo "<td align=\"right\">";
echo '<b>&nbsp;</b>';
echo "</td><td>";
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', true);\">".
get_string("all")."</a>/";
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInMenuByName('form1', 'restore_user_info_', '0');\">".
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_user_info_', false);\">".
get_string("none")."</a>";
echo "</font></td>";
echo "</td>";
echo "</tr>";
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
$currentrow = 0;
foreach ($allmods as $mod) {
$modname = $mod->name;
$modrestore = $modname."_restore_mods";
@@ -169,19 +205,25 @@
//Now check that we have that module info in the backup file
if (isset($info->mods[$modname]) && $info->mods[$modname]->backup == "true") {
//Print the full tr
echo "<tr>";
echo "<td align=\"right\"><b>";
echo get_string("include")." ". get_string("modulenameplural",$modname).":";
echo "</b></td><td>";
$restore_options[0] = get_string("no");
echo "<tr class=\"r".$currentrow."\">";
echo "<td align=\"right\">&nbsp;";
echo "</td><td>";
$restore_options[1] = get_string("yes");
choose_from_menu($restore_options, $restore_var, $$restore_var, "");
$restore_options[0] = get_string("no");
//choose_from_menu($restore_options, $restore_var, $$restore_var, "");
//choose_from_radio($restore_options, $restore_var, $$restore_var);
//Print the checkbox
print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname));
//If backup contains user data, then show menu, else fix it to
//without user data
echo "</td><td align=\"right\">&nbsp;";
echo "</td><td>";
if ($info->mods[$modname]->userinfo == "true") {
$restore_user_options[0] = get_string("withoutuserdata");
$restore_user_options[1] = get_string("withuserdata");
choose_from_menu($restore_user_options, $user_info_var, $$user_info_var, "");
$restore_user_options[1] = get_string("yes");
$restore_user_options[0] = get_string("no");
//choose_from_menu($restore_user_options, $user_info_var, $$user_info_var, "");
//choose_from_radio($restore_user_options, $user_info_var, $$user_info_var);
print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"));
} else {
//Module haven't userdata
echo get_string("withoutuserdata");
@@ -203,15 +245,16 @@
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
}
$currentrow = ($currentrow + 1) % 2;
}
//Line
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
//Now print the Metacourse tr
echo "<tr>";
echo "<td align=\"right\"><b>";
echo "<td align=\"right\" colspan=\"2\"><b>";
echo get_string("metacourse").":";
echo "</b></td><td>";
echo "</b></td><td colspan=\"2\">";
//If metacourse are in the backup file, show menu, else fixed to no
if ($info->backup_metacourse == "true") {
$metacourse_options[0] = get_string("no");
@@ -224,9 +267,9 @@
echo "</td></tr>";
//Now print the Users tr
echo "<tr>";
echo "<td align=\"right\"><b>";
echo "<td align=\"right\" colspan=\"2\"><b>";
echo get_string("users").":";
echo "</b></td><td>";
echo "</b></td><td colspan=\"2\">";
//If some user is present in the backup file
if ($info->backup_users == "all" or $info->backup_users == "course") {
//If all users are in the backup file
@@ -245,9 +288,9 @@
//Now print the Logs tr
echo "<tr>";
echo "<td align=\"right\"><b>";
echo "<td align=\"right\" colspan=\"2\"><b>";
echo get_string("logs").":";
echo "</b></td><td>";
echo "</b></td><td colspan=\"2\">";
//If logs are in the backup file, show menu, else fixed to no
if ($info->backup_logs == "true") {
$log_options[0] = get_string("no");
@@ -261,9 +304,9 @@
//Now print the User Files tr
echo "<tr>";
echo "<td align=\"right\"><b>";
echo "<td align=\"right\" colspan=\"2\"><b>";
echo get_string ("userfiles").":";
echo "</b></td><td>";
echo "</b></td><td colspan=\"2\">";
//If user files are in the backup file, show menu, else fixed to no
if ($info->backup_user_files == "true") {
$user_file_options[0] = get_string("no");
@@ -277,9 +320,9 @@
//Now print the Course Files tr
echo "<tr>";
echo "<td align=\"right\"><b>";
echo "<td align=\"right\" colspan=\"2\"><b>";
echo get_string ("coursefiles").":";
echo "</b></td><td>";
echo "</b></td><td colspan=\"2\">";
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\" />";
echo "<input type=\"hidden\" name=\"file\" value=\"$file\" />";
//If course files are in the backup file, show menu, else fixed to no
@@ -295,19 +338,19 @@
//Now print the Messages tr
echo "<tr>";
echo "<td align=\"right\"><b>";
echo "<td align=\"right\" colspan=\"2\"><b>";
//This tr is slighty different. Everything becomes hidden if
//we haven't messages is the backup, to avoid confusions to users.
//If messages are in the backup file, show menu, else fixed to no and show nothing
if ($info->backup_messages == "true") {
echo get_string ('messages','message').":";
echo "</b></td><td>";
echo "</b></td><td colspan=\"2\">";
$message_options[0] = get_string("no");
$message_options[1] = get_string("yes");
choose_from_menu($message_options, "restore_messages", $restore_messages, "");
} else {
echo "&nbsp;</b></td><td>";
echo "&nbsp;</b></td><td colspan=\"2\">";
echo "<input type=\"hidden\" name=\"restore_messages\" value=\"0\" />";
}
echo "</td></tr>";

0 comments on commit 4eb4ad0

Please sign in to comment.