mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Checks everything is OK before lanunch the process. It allows to
select the destination course. Initial version, it doesn't work !!
This commit is contained in:
parent
8d5b052f35
commit
3f50cab58d
1 changed files with 218 additions and 0 deletions
218
backup/restore_check.html
Normal file
218
backup/restore_check.html
Normal file
|
@ -0,0 +1,218 @@
|
|||
<?PHP //$Id$
|
||||
//This page receive all the restore_form data. Then, if existing course
|
||||
//has been selected, shows a list of courses to select one.
|
||||
//It cheks that the parammeter from restore_form are coherent.
|
||||
//It puts all the restore info in the session.
|
||||
//Finally, it calls restore_execute to do the hard work
|
||||
|
||||
//Get objects from session
|
||||
$info = $SESSION->info;
|
||||
$course_header = $SESSION->course_header;
|
||||
|
||||
//Check that we have all we need
|
||||
//backup_unique_code
|
||||
require_variable($backup_unique_code);
|
||||
//file
|
||||
require_variable($file);
|
||||
//info
|
||||
require_variable($info);
|
||||
//course_header
|
||||
require_variable($course_header);
|
||||
//Checks for the required restoremod parameters
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$var = "restore_".$modname;
|
||||
require_variable($$var);
|
||||
$var = "restore_user_info_".$modname;
|
||||
require_variable($$var);
|
||||
}
|
||||
}
|
||||
|
||||
//Check login
|
||||
require_login();
|
||||
|
||||
//Check admin
|
||||
if (!isadmin()) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
//Check site
|
||||
if (!$site = get_site()) {
|
||||
error("Site not found!");
|
||||
}
|
||||
|
||||
//Checks for the required restoremod parameters
|
||||
$count = 0;
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$var = "restore_".$modname;
|
||||
require_variable($$var);
|
||||
$var = "restore_user_info_".$modname;
|
||||
require_variable($$var);
|
||||
}
|
||||
}
|
||||
|
||||
//Check other parameters
|
||||
if (!isset($restore_users)) {
|
||||
$restore_users = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_logs)) {
|
||||
$restore_logs = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_user_files)) {
|
||||
$restore_user_files = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_course_files)) {
|
||||
$restore_course_files = 1;
|
||||
}
|
||||
|
||||
if (!isset($restore_restoreto)) {
|
||||
$restore_restoreto = 1;
|
||||
}
|
||||
|
||||
if ($count == 0) {
|
||||
notice("No restorable modules are installed!");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
|
||||
<table cellpadding=5>
|
||||
<?
|
||||
|
||||
//First, course destination
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><b>";
|
||||
echo get_string("restoreto").":</b>";
|
||||
echo "</td><td>";
|
||||
$restore_restoreto_options[0] = get_string("existingcourse");
|
||||
$restore_restoreto_options[1] = get_string("newcourse");
|
||||
choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
|
||||
echo "</td></tr>";
|
||||
//Line
|
||||
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
||||
//Now, check modules and info and show posibilities
|
||||
if ($allmods = get_records("modules") ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modrestore = $modname."_restore_mods";
|
||||
//If exists the lib & function
|
||||
$exist = "exists_".$modname;
|
||||
$var = "restore_".$modname;
|
||||
if ($$exist) {
|
||||
//Now check that we have that module info in the backup file
|
||||
if ($info->mods[$modname]->backup == "true") {
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("include")." ". get_string("modulenameplural",$modname).":";
|
||||
echo "</td><td>";
|
||||
$restore_options[0] = get_string("no");
|
||||
$restore_options[1] = get_string("yes");
|
||||
choose_from_menu($restore_options, $var, $$var, "");
|
||||
$var = "restore_user_info_".$modname;
|
||||
//If backup contains user data, then show menu, else fix it to
|
||||
//without user data
|
||||
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, $var, $$var, "");
|
||||
} else {
|
||||
//Module haven't userdata
|
||||
echo get_string("withoutuserdata");
|
||||
echo "<input type=\"hidden\" name=\"$var\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
} else {
|
||||
//Module isn't restorable
|
||||
echo "<input type=\"hidden\" name=\"$var\" value=\"0\">";
|
||||
}
|
||||
} else {
|
||||
//Module isn't restorable
|
||||
echo "<input type=\"hidden\" name=\"$var\" value=\"0\">";
|
||||
}
|
||||
}
|
||||
//Line
|
||||
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
||||
|
||||
//Now print the Users tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("users").":";
|
||||
echo "</td><td>";
|
||||
//If all users are in the backup file
|
||||
if ($info->backup_users == "all") {
|
||||
$user_options[0] = get_string("all");
|
||||
}
|
||||
$user_options[1] = get_string("course");
|
||||
$user_options[2] = get_string("none");
|
||||
//$user_options[2] = get_string("needed");-->NOT IMPLEMENTED
|
||||
choose_from_menu($user_options, "restore_users", $restore_users, "");
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Logs tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("logs").":";
|
||||
echo "</td><td>";
|
||||
//If logs are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_logs == "true") {
|
||||
$log_options[0] = get_string("no");
|
||||
$log_options[1] = get_string("yes");
|
||||
choose_from_menu($log_options, "restore_logs", $restore_logs, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the User Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string ("userfiles").":";
|
||||
echo "</td><td>";
|
||||
//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");
|
||||
$user_file_options[1] = get_string("yes");
|
||||
choose_from_menu($user_file_options, "restore_user_files", $restore_user_files, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Course Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string ("coursefiles").":";
|
||||
echo "</td><td>";
|
||||
//If course files are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_course_files == "true") {
|
||||
$course_file_options[0] = get_string("no");
|
||||
$course_file_options[1] = get_string("yes");
|
||||
choose_from_menu($course_file_options, "restore_course_files", $restore_course_files, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\">";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\">";
|
||||
echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<BR>
|
||||
<CENTER>
|
||||
<input type="hidden" name=id value="<? p($id) ?>">
|
||||
<input type="hidden" name=launch value="form">
|
||||
<input type="submit" value="<? print_string("continue") ?>">
|
||||
<input type="submit" name=cancel value="<? print_string("cancel") ?>">
|
||||
</CENTER>
|
||||
</FORM>
|
Loading…
Add table
Add a link
Reference in a new issue