2004-09-12 01:34:24 +00:00
|
|
|
<?php //$Id$
|
2003-05-04 21:29:27 +00:00
|
|
|
//This page prints the backup todo list to see everything
|
|
|
|
|
2003-05-18 17:15:05 +00:00
|
|
|
//Check login
|
|
|
|
require_login();
|
|
|
|
|
2003-08-01 14:42:14 +00:00
|
|
|
if (!empty($course->id)) {
|
2003-08-16 06:37:06 +00:00
|
|
|
if (!isteacheredit($course->id)) {
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
} else {
|
|
|
|
if (!isteacheredit($to)) {
|
|
|
|
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
}
|
|
|
|
}
|
2003-08-01 14:42:14 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!isadmin()) {
|
|
|
|
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
|
|
}
|
2003-05-18 17:15:05 +00:00
|
|
|
}
|
|
|
|
|
2003-08-01 14:42:14 +00:00
|
|
|
|
2003-05-18 17:15:05 +00:00
|
|
|
//Check site
|
|
|
|
if (!$site = get_site()) {
|
|
|
|
error("Site not found!");
|
|
|
|
}
|
|
|
|
|
2003-05-04 21:29:27 +00:00
|
|
|
//Checks for the required files/functions to backup every mod
|
|
|
|
//And check if there is data about it
|
|
|
|
$count = 0;
|
|
|
|
if ($allmods = get_records("modules") ) {
|
|
|
|
foreach ($allmods as $mod) {
|
|
|
|
$modname = $mod->name;
|
2003-08-01 14:34:11 +00:00
|
|
|
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
|
2003-05-04 21:29:27 +00:00
|
|
|
$modbackup = $modname."_backup_mods";
|
|
|
|
$modcheckbackup = $modname."_check_backup_mods";
|
|
|
|
if (file_exists($modfile)) {
|
|
|
|
include_once($modfile);
|
|
|
|
if (function_exists($modbackup) and function_exists($modcheckbackup)) {
|
|
|
|
$var = "exists_".$modname;
|
|
|
|
$$var = true;
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Check data
|
|
|
|
//Check module info
|
|
|
|
$var = "backup_".$modname;
|
|
|
|
if (!isset($$var)) {
|
|
|
|
$$var = 1;
|
|
|
|
}
|
|
|
|
//Check include user info
|
|
|
|
$var = "backup_user_info_".$modname;
|
|
|
|
if (!isset($$var)) {
|
|
|
|
$$var = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check other parameters
|
|
|
|
if (!isset($backup_users)) {
|
|
|
|
$backup_users = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($backup_logs)) {
|
2003-07-15 18:12:41 +00:00
|
|
|
$backup_logs = 0;
|
2003-05-04 21:29:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($backup_user_files)) {
|
|
|
|
$backup_user_files = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($backup_course_files)) {
|
|
|
|
$backup_course_files = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($count == 0) {
|
|
|
|
notice("No backupable modules are installed!");
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2003-10-13 22:45:36 +00:00
|
|
|
<form name="form" method="post" action="<?php echo $ME ?>">
|
2004-09-12 01:34:24 +00:00
|
|
|
<table cellpadding="5">
|
2003-09-11 13:21:56 +00:00
|
|
|
<?php
|
2003-05-04 21:29:27 +00:00
|
|
|
|
|
|
|
//Calculate the backup string
|
2003-12-29 20:15:56 +00:00
|
|
|
|
|
|
|
//Calculate the backup word
|
2003-09-18 17:43:52 +00:00
|
|
|
//Take off some characters in the filename !!
|
|
|
|
$takeoff = array(" ", ":", "/", "\\", "|");
|
2003-12-29 20:15:56 +00:00
|
|
|
$backup_word = str_replace($takeoff,"_",strtolower(get_string("backupfilename")));
|
2003-05-04 21:29:27 +00:00
|
|
|
//If non-translated, use "backup"
|
2003-12-29 20:15:56 +00:00
|
|
|
if (substr($backup_word,0,1) == "[") {
|
|
|
|
$backup_word= "backup";
|
2003-05-04 21:29:27 +00:00
|
|
|
}
|
2003-12-29 20:15:56 +00:00
|
|
|
|
|
|
|
//Calculate the date format string
|
|
|
|
$backup_date_format = str_replace(" ","_",get_string("backupnameformat"));
|
2003-05-04 21:29:27 +00:00
|
|
|
//If non-translated, use "%Y%m%d-%H%M"
|
2003-12-29 20:15:56 +00:00
|
|
|
if (substr($backup_date_format,0,1) == "[") {
|
|
|
|
$backup_date_format = "%%Y%%m%%d-%%H%%M";
|
|
|
|
}
|
|
|
|
|
|
|
|
//Calculate the shortname
|
|
|
|
$backup_shortname = clean_filename($course->shortname);
|
|
|
|
if (empty($backup_shortname) or $backup_shortname == '_' ) {
|
|
|
|
$backup_shortname = $course->id;
|
2003-05-04 21:29:27 +00:00
|
|
|
}
|
2003-12-29 20:15:56 +00:00
|
|
|
|
|
|
|
//Calculate the final backup filename
|
|
|
|
//The backup word
|
|
|
|
$backup_name = $backup_word."-";
|
|
|
|
//The shortname
|
|
|
|
$backup_name .= strtolower($backup_shortname)."-";
|
|
|
|
//The date format
|
|
|
|
$backup_name .= userdate(time(),$backup_date_format,99,false);
|
|
|
|
//The extension
|
|
|
|
$backup_name .= ".zip";
|
2004-12-19 16:18:10 +00:00
|
|
|
//And finally, clean everything
|
|
|
|
$backup_name = clean_filename($backup_name);
|
2003-12-29 20:15:56 +00:00
|
|
|
|
2003-05-04 21:29:27 +00:00
|
|
|
//Calculate the backup unique code to allow simultaneus backups (to define
|
|
|
|
//the temp-directory name and records in backup temp tables
|
|
|
|
$backup_unique_code = time();
|
|
|
|
//Add as hidden name
|
|
|
|
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"".$backup_unique_code."\">";
|
2005-01-27 02:35:10 +00:00
|
|
|
|
|
|
|
if (empty($to)) {
|
|
|
|
//Now print the Backup Name tr
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td align=\"right\"><P><B>";
|
|
|
|
echo get_string("name").":";
|
|
|
|
echo "</B></td><td>";
|
|
|
|
//Add as text field
|
|
|
|
echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backup_name."\">";
|
|
|
|
echo "</td></tr>";
|
2003-05-04 21:29:27 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
//Line
|
|
|
|
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
|
|
|
|
|
|
|
//Now print the To Do list
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td colspan=\"2\" align=\"center\"><p><b>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
echo '<input type="hidden" name="backup_name" value="'.$backup_name.'" />';
|
|
|
|
}
|
2003-05-04 21:29:27 +00:00
|
|
|
|
2004-05-20 18:36:59 +00:00
|
|
|
|
|
|
|
//Here we check if backup_users = None. Then, we switch off every module
|
|
|
|
//user info, user_files, logs and exercises and workshop backups. A Warning is showed to
|
|
|
|
//inform the user.
|
|
|
|
if ($backup_users == 2) {
|
|
|
|
if ($allmods = get_records("modules") ) {
|
|
|
|
foreach ($allmods as $mod) {
|
|
|
|
$modname = $mod->name;
|
|
|
|
$var = "backup_user_info_".$modname;
|
|
|
|
if (isset($$var)) {
|
|
|
|
$$var = 0;
|
|
|
|
}
|
|
|
|
$var = "backup_".$modname;
|
|
|
|
if (isset($$var)) {
|
|
|
|
if ($modname == "exercise" || $modname == "workshop") {
|
|
|
|
$$var = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$backup_user_files = 0;
|
|
|
|
$backup_logs = 0;
|
|
|
|
}
|
|
|
|
print_simple_box("<font color=\"red\">".get_string("backupnoneusersinfo")."</font>","center", "70%", "$THEME->cellheading", "20", "noticebox");
|
|
|
|
echo "<hr noshade size=\"1\">";
|
|
|
|
}
|
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
echo get_string("backupdetails").":";
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
2003-05-04 21:29:27 +00:00
|
|
|
|
|
|
|
//This is tha align to every ingo table
|
2004-09-12 01:34:24 +00:00
|
|
|
$table->align = array ("left","right");
|
2003-05-04 21:29:27 +00:00
|
|
|
|
|
|
|
if ($allmods = get_records("modules") ) {
|
|
|
|
foreach ($allmods as $mod) {
|
|
|
|
$modname = $mod->name;
|
|
|
|
$modbackup = $modname."_backup_mods";
|
|
|
|
//If exists the lib & function
|
|
|
|
$var = "exists_".$modname;
|
2003-10-14 17:26:37 +00:00
|
|
|
if (isset($$var) && $$var) {
|
2003-05-04 21:29:27 +00:00
|
|
|
//Add hidden fields
|
|
|
|
$var = "backup_".$modname;
|
|
|
|
echo "<input type=\"hidden\" name=\"".$var."\" value=\"".$$var."\">";
|
|
|
|
$var = "backup_user_info_".$modname;
|
|
|
|
echo "<input type=\"hidden\" name=\"".$var."\" value=\"".$$var."\">";
|
|
|
|
$var = "backup_".$modname;
|
|
|
|
//Only if selected
|
|
|
|
if ($$var == 1) {
|
|
|
|
//Print the full tr
|
|
|
|
echo "<tr>";
|
2004-09-12 01:34:24 +00:00
|
|
|
echo "<td colspan=\"2\"><p><b>";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print the mod name
|
|
|
|
echo "<li>".get_string("include")." ".get_string("modulenameplural",$modname)." ";
|
|
|
|
//Now look for user-data status
|
|
|
|
$backup_user_options[0] = get_string("withoutuserdata");
|
|
|
|
$backup_user_options[1] = get_string("withuserdata");
|
|
|
|
$var = "backup_user_info_".$modname;
|
|
|
|
//Print the user info
|
2004-09-12 01:34:24 +00:00
|
|
|
echo $backup_user_options[$$var]."<p>";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Call the check function to show more info
|
|
|
|
$modcheckbackup = $modname."_check_backup_mods";
|
|
|
|
$table->data = $modcheckbackup($id,$$var,$backup_unique_code);
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-01-27 02:35:10 +00:00
|
|
|
|
|
|
|
if (empty($to)) {
|
|
|
|
//Line
|
|
|
|
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
|
|
|
|
|
|
|
|
//Now print the Users tr
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td colspan=\"2\"><p><b>";
|
|
|
|
$user_options[0] = get_string("includeallusers");
|
|
|
|
$user_options[1] = get_string("includecourseusers");
|
|
|
|
$user_options[2] = get_string("includenoneusers");
|
|
|
|
echo "<li>".$user_options[$backup_users]."<p>";
|
|
|
|
//Print info
|
|
|
|
$table->data = user_check_backup($id,$backup_unique_code,$backup_users);
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
|
|
|
|
}
|
2003-05-04 21:29:27 +00:00
|
|
|
//Add as hidden name
|
|
|
|
echo "<input type=\"hidden\" name=\"backup_users\" value=\"".$backup_users."\">";
|
2005-01-27 02:35:10 +00:00
|
|
|
|
2003-05-04 21:29:27 +00:00
|
|
|
//Now print the Logs tr conditionally
|
2005-01-27 02:35:10 +00:00
|
|
|
if ($backup_logs && empty($to)) {
|
2003-05-04 21:29:27 +00:00
|
|
|
echo "<tr>";
|
2004-09-12 01:34:24 +00:00
|
|
|
echo "<td colspan=\"2\"><p><b>";
|
|
|
|
echo "<li>".get_string("includelogentries")."<p>";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print info
|
|
|
|
$table->data = log_check_backup($id);
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
//Add as hidden name
|
|
|
|
echo "<input type=\"hidden\" name=\"backup_logs\" value=\"".$backup_logs."\">";
|
|
|
|
|
|
|
|
//Now print the User Files tr conditionally
|
|
|
|
if ($backup_user_files) {
|
|
|
|
echo "<tr>";
|
2004-09-12 01:34:24 +00:00
|
|
|
echo "<td colspan=\"2\"><p><b>";
|
|
|
|
echo "<li>".get_string("includeuserfiles")."<p>";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print info
|
|
|
|
$table->data = user_files_check_backup($id,$backup_unique_code);
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
//Add as hidden name
|
|
|
|
echo "<input type=\"hidden\" name=\"backup_user_files\" value=\"".$backup_user_files."\">";
|
|
|
|
|
|
|
|
//Now print the Course Files tr conditionally
|
|
|
|
if ($backup_course_files) {
|
|
|
|
echo "<tr>";
|
2004-09-12 01:34:24 +00:00
|
|
|
echo "<td colspan=\"2\"><p><b>";
|
|
|
|
echo "<li>".get_string("includecoursefiles")."<p>";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print info
|
|
|
|
$table->data = course_files_check_backup($id,$backup_unique_code);
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
//Add as hidden name
|
|
|
|
echo "<input type=\"hidden\" name=\"backup_course_files\" value=\"".$backup_course_files."\">";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
2004-09-12 01:34:24 +00:00
|
|
|
<br />
|
|
|
|
<center>
|
2005-01-27 02:35:10 +00:00
|
|
|
<input type="hidden" name="to" value="<?php p($to) ?>" />
|
|
|
|
<input type="hidden" name="id" value="<?php p($id) ?>" />
|
|
|
|
<input type="hidden" name="launch" value="execute" />
|
|
|
|
<input type="submit" value="<?php print_string("continue") ?>" />
|
|
|
|
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
|
2004-09-12 01:34:24 +00:00
|
|
|
</center>
|
|
|
|
</form>
|