From 4eb4ad04dbb872413a62f073830aa34fabd1a75b Mon Sep 17 00:00:00 2001 From: stronk7 Date: Wed, 29 Jun 2005 16:56:23 +0000 Subject: [PATCH] Now the restore form page is a bit more easy to use. Bug 1430. (http://moodle.org/bugs/bug.php?op=show&bugid=1430) --- backup/restore_check.html | 4 +- backup/restore_form.html | 109 ++++++++++++++++++++++++++------------ 2 files changed, 78 insertions(+), 35 deletions(-) diff --git a/backup/restore_check.html b/backup/restore_check.html index 50d5160ed93..bfbca4e334f 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.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 diff --git a/backup/restore_form.html b/backup/restore_form.html index 94be7910bbb..97de5fdfa4e 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -114,9 +114,35 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { 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 @@ -130,7 +156,7 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { echo ""; echo ""; echo get_string("restoreto").":"; - echo ""; + echo ""; if (isteacheredit($id) and !iscreator()) { $restore_restoreto_options[0] = get_string("currentcoursedeleting"); $restore_restoreto_options[1] = get_string("currentcourseadding"); @@ -143,20 +169,30 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, ""); echo ""; //Line - echo "
"; + echo "
"; //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 ""; - echo ""; - echo get_string("userdata").":"; - echo "". + echo ""; + echo ''.get_string("include").":"; + echo ""; + echo "". get_string("all")."/"; - echo "". + echo "". get_string("none").""; - echo ""; + echo ""; + echo ""; + echo ' '; + echo ""; + echo "". + get_string("all")."/"; + echo "". + get_string("none").""; + echo ""; echo ""; - echo "
"; + echo "
"; + $currentrow = 0; foreach ($allmods as $mod) { $modname = $mod->name; $modrestore = $modname."_restore_mods"; @@ -169,19 +205,25 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { //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 ""; - echo ""; - echo get_string("include")." ". get_string("modulenameplural",$modname).":"; - echo ""; - $restore_options[0] = get_string("no"); + echo ""; + echo " "; + echo ""; $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 " "; + echo ""; 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 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { echo ""; echo ""; } + $currentrow = ($currentrow + 1) % 2; } //Line - echo "
"; + echo "
"; //Now print the Metacourse tr echo ""; - echo ""; + echo ""; echo get_string("metacourse").":"; - echo ""; + echo ""; //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 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { echo ""; //Now print the Users tr echo ""; - echo ""; + echo ""; echo get_string("users").":"; - echo ""; + echo ""; //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 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { //Now print the Logs tr echo ""; - echo ""; + echo ""; echo get_string("logs").":"; - echo ""; + echo ""; //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 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { //Now print the User Files tr echo ""; - echo ""; + echo ""; echo get_string ("userfiles").":"; - echo ""; + echo ""; //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 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { //Now print the Course Files tr echo ""; - echo ""; + echo ""; echo get_string ("coursefiles").":"; - echo ""; + echo ""; echo ""; echo ""; //If course files are in the backup file, show menu, else fixed to no @@ -295,19 +338,19 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) { //Now print the Messages tr echo ""; - echo ""; + echo ""; //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 ""; + echo ""; $message_options[0] = get_string("no"); $message_options[1] = get_string("yes"); choose_from_menu($message_options, "restore_messages", $restore_messages, ""); } else { - echo " "; + echo " "; echo ""; } echo "";