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
|
|
|
|
|
2007-08-09 21:50:59 +00:00
|
|
|
//Check login
|
2003-05-18 17:15:05 +00:00
|
|
|
require_login();
|
|
|
|
|
2003-08-01 14:42:14 +00:00
|
|
|
if (!empty($course->id)) {
|
2006-09-07 08:57:56 +00:00
|
|
|
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $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 {
|
2006-09-07 08:57:56 +00:00
|
|
|
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
|
2005-01-27 02:35:10 +00:00
|
|
|
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 {
|
2006-09-07 08:57:56 +00:00
|
|
|
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
2003-08-01 14:42:14 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-08-09 21:50:59 +00:00
|
|
|
|
2006-01-16 00:39:01 +00:00
|
|
|
|
|
|
|
$backupprefs = new StdClass;
|
|
|
|
$count = 0;
|
|
|
|
backup_fetch_prefs_from_request($backupprefs,$count,$course);
|
2003-08-01 14:42:14 +00:00
|
|
|
|
2007-08-09 21:50:59 +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
|
|
|
if ($count == 0) {
|
|
|
|
notice("No backupable modules are installed!");
|
|
|
|
}
|
2007-08-09 21:50:59 +00:00
|
|
|
|
|
|
|
if (!execute_sql("DELETE FROM {$CFG->prefix}backup_ids WHERE backup_code = '{$backupprefs->backup_unique_code}'",false)){
|
|
|
|
error('Couldn\'t delete previous backup ids.');
|
|
|
|
}
|
|
|
|
|
2003-05-04 21:29:27 +00:00
|
|
|
?>
|
|
|
|
|
2007-01-04 21:32:36 +00:00
|
|
|
<form id="form" method="post" action="backup.php">
|
2007-02-06 08:24:37 +00:00
|
|
|
<table cellpadding="5" style="text-align:center;margin-left:auto;margin-right:auto">
|
2003-09-11 13:21:56 +00:00
|
|
|
<?php
|
2003-05-04 21:29:27 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
//Now print the Backup Name tr
|
|
|
|
echo "<tr>";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<td align=\"right\"><b>";
|
2005-01-27 02:35:10 +00:00
|
|
|
echo get_string("name").":";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "</b></td><td>";
|
2005-01-27 02:35:10 +00:00
|
|
|
//Add as text field
|
2006-01-16 00:39:01 +00:00
|
|
|
echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backupprefs->backup_name."\" />";
|
2005-01-27 02:35:10 +00:00
|
|
|
echo "</td></tr>";
|
2007-08-09 21:50:59 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
//Line
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
|
2007-08-09 21:50:59 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
//Now print the To Do list
|
2007-08-09 21:50:59 +00:00
|
|
|
echo "<tr>";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<td colspan=\"2\" align=\"center\"><b>";
|
2005-01-27 02:35:10 +00:00
|
|
|
|
|
|
|
}
|
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
|
2005-02-13 02:59:04 +00:00
|
|
|
//user info, user_files, logs and exercises, workshop and messages backups. A Warning is showed to
|
2004-05-20 18:36:59 +00:00
|
|
|
//inform the user.
|
2008-01-24 00:51:09 +00:00
|
|
|
// TODO: Move this logic to one function to be shared by any (manual, scheduled) backup
|
2006-01-16 00:39:01 +00:00
|
|
|
if ($backupprefs->backup_users == 2) {
|
2008-01-24 00:51:09 +00:00
|
|
|
if ($allmods = get_records('modules') ) {
|
2004-05-20 18:36:59 +00:00
|
|
|
foreach ($allmods as $mod) {
|
2008-01-24 00:51:09 +00:00
|
|
|
/// Reset global user_info settings to "no" (0)
|
2004-05-20 18:36:59 +00:00
|
|
|
$modname = $mod->name;
|
2008-01-24 00:51:09 +00:00
|
|
|
$var = 'backup_user_info_'.$modname;
|
2006-01-16 00:39:01 +00:00
|
|
|
if (isset($backupprefs->$var)) {
|
|
|
|
$backupprefs->$var = 0;
|
2004-05-20 18:36:59 +00:00
|
|
|
}
|
2008-01-24 00:51:09 +00:00
|
|
|
/// Reset each instance userinfo settings to "no" (0)
|
|
|
|
if (isset($backupprefs->mods[$modname])) {
|
|
|
|
/// Set the module userinfo to no (0)
|
|
|
|
$backupprefs->mods[$modname]->userinfo = 0;
|
|
|
|
/// Set the instances to no (o)
|
|
|
|
foreach ($backupprefs->mods[$modname]->instances as $key => $instance) {
|
|
|
|
$backupprefs->mods[$modname]->instances[$key]->userinfo = 0;
|
|
|
|
$var = 'backup_user_info_' . $modname . '_instance_' . $key;
|
|
|
|
$backupprefs->$var = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// If modules are workshop or exercise, disable their backup completely
|
|
|
|
if ($modname == 'exercise' || $modname == 'workshop') {
|
|
|
|
$var = 'backup_'.$modname;
|
|
|
|
if (isset($backupprefs->$var)) {
|
2006-01-16 00:39:01 +00:00
|
|
|
$backupprefs->$var = 0;
|
2008-01-24 00:51:09 +00:00
|
|
|
/// Reset each instance backup settings to "no" (0)
|
|
|
|
if (isset($backupprefs->mods[$modname])) {
|
|
|
|
/// Set the module backup to no (0)
|
|
|
|
$backupprefs->mods[$modname]->backup = 0;
|
|
|
|
$var = 'backup_' . $modname . '_instances';
|
|
|
|
$backupprefs->$var = 0;
|
|
|
|
/// Set the instances backup to no (o)
|
|
|
|
foreach ($backupprefs->mods[$modname]->instances as $key => $instance) {
|
|
|
|
$backupprefs->mods[$modname]->instances[$key]->backup = 0;
|
|
|
|
$var = 'backup_' . $modname . '_instance_' . $key;
|
|
|
|
$backupprefs->$var = 0;
|
|
|
|
}
|
|
|
|
}
|
2004-05-20 18:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-24 00:51:09 +00:00
|
|
|
$backupprefs->backup_user_files = 0;
|
|
|
|
$backupprefs->backup_logs = 0;
|
|
|
|
$backupprefs->backup_messages = 0;
|
|
|
|
$backupprefs->backuproleassignments = array();
|
|
|
|
|
2005-01-28 00:01:20 +00:00
|
|
|
print_simple_box("<font color=\"red\">".get_string("backupnoneusersinfo")."</font>","center", "70%", '', "20", "noticebox");
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<hr />";
|
2004-05-20 18:36:59 +00:00
|
|
|
}
|
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
echo get_string("backupdetails").":";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "</b></td></tr>";
|
2005-01-27 02:35:10 +00:00
|
|
|
}
|
2003-05-04 21:29:27 +00:00
|
|
|
|
2007-08-09 21:50:59 +00:00
|
|
|
//This is the alignment of every row in the 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;
|
2006-01-16 00:39:01 +00:00
|
|
|
$modfile = $CFG->dirroot.'/mod/'.$modname.'/backuplib.php';
|
|
|
|
if (!file_exists($modfile)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
require_once($modfile);
|
2003-05-04 21:29:27 +00:00
|
|
|
$modbackup = $modname."_backup_mods";
|
|
|
|
//If exists the lib & function
|
|
|
|
$var = "exists_".$modname;
|
2006-01-16 00:39:01 +00:00
|
|
|
if (isset($backupprefs->$var) && $backupprefs->$var) {
|
2003-05-04 21:29:27 +00:00
|
|
|
$var = "backup_".$modname;
|
|
|
|
//Only if selected
|
2006-05-23 13:33:44 +00:00
|
|
|
if (!empty($backupprefs->$var) and ($backupprefs->$var == 1)) {
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print the full tr
|
|
|
|
echo "<tr>";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<td colspan=\"2\">";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print the mod name
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<b>".get_string("include")." ".get_string("modulenameplural",$modname)." ";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Now look for user-data status
|
2007-08-09 21:50:59 +00:00
|
|
|
$backup_user_options[0] = get_string("withoutuserdata");
|
2003-05-04 21:29:27 +00:00
|
|
|
$backup_user_options[1] = get_string("withuserdata");
|
|
|
|
$var = "backup_user_info_".$modname;
|
|
|
|
//Print the user info
|
2006-01-16 00:39:01 +00:00
|
|
|
echo $backup_user_options[$backupprefs->$var]."</b>";
|
2003-05-04 21:29:27 +00:00
|
|
|
//Call the check function to show more info
|
|
|
|
$modcheckbackup = $modname."_check_backup_mods";
|
2006-01-13 03:45:31 +00:00
|
|
|
$var = $modname.'_instances';
|
|
|
|
$instancestopass = array();
|
2006-01-16 00:39:01 +00:00
|
|
|
if (!empty($backupprefs->$var) && is_array($backupprefs->$var) && count($backupprefs->$var)) {
|
2006-01-13 03:45:31 +00:00
|
|
|
$table->data = array();
|
|
|
|
$countinstances = 0;
|
2006-01-16 00:39:01 +00:00
|
|
|
foreach ($backupprefs->$var as $instance) {
|
2006-01-13 03:45:31 +00:00
|
|
|
$var1 = 'backup_'.$modname.'_instance_'.$instance->id;
|
|
|
|
$var2 = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
|
2006-01-16 00:39:01 +00:00
|
|
|
if (!empty($backupprefs->$var1)) {
|
2006-01-13 03:45:31 +00:00
|
|
|
$obj = new StdClass;
|
|
|
|
$obj->name = $instance->name;
|
2006-01-16 00:39:01 +00:00
|
|
|
$obj->userdata = $backupprefs->$var2;
|
2006-01-13 03:45:31 +00:00
|
|
|
$obj->id = $instance->id;
|
|
|
|
$instancestopass[$instance->id]= $obj;
|
|
|
|
$countinstances++;
|
2007-08-09 21:50:59 +00:00
|
|
|
|
2006-01-13 03:45:31 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-09 21:50:59 +00:00
|
|
|
}
|
2006-01-16 00:39:01 +00:00
|
|
|
$table->data = $modcheckbackup($id,$backupprefs->$var,$backupprefs->backup_unique_code,$instancestopass);
|
2007-08-09 21:50:59 +00:00
|
|
|
print_table($table);
|
2003-05-04 21:29:27 +00:00
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-09 21:50:59 +00:00
|
|
|
|
2005-02-04 14:33:51 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
//Line
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<tr><td colspan=\"2\"><hr /></td></tr>";
|
2005-02-04 14:33:51 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
//Now print the Users tr
|
|
|
|
echo "<tr>";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<td colspan=\"2\"><b>";
|
2005-01-27 02:35:10 +00:00
|
|
|
$user_options[0] = get_string("includeallusers");
|
|
|
|
$user_options[1] = get_string("includecourseusers");
|
|
|
|
$user_options[2] = get_string("includenoneusers");
|
2006-01-16 00:39:01 +00:00
|
|
|
echo $user_options[$backupprefs->backup_users].'</b>';
|
2005-01-27 02:35:10 +00:00
|
|
|
//Print info
|
2007-08-09 21:50:59 +00:00
|
|
|
$table->data = user_check_backup($id,$backupprefs->backup_unique_code,$backupprefs->backup_users,$backupprefs->backup_messages);
|
|
|
|
print_table($table);
|
2005-01-27 02:35:10 +00:00
|
|
|
echo "</td></tr>";
|
2007-08-09 21:50:59 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
}
|
2007-08-09 21:50:59 +00:00
|
|
|
|
2003-05-04 21:29:27 +00:00
|
|
|
//Now print the Logs tr conditionally
|
2006-01-16 00:39:01 +00:00
|
|
|
if ($backupprefs->backup_logs && empty($to)) {
|
2003-05-04 21:29:27 +00:00
|
|
|
echo "<tr>";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<td colspan=\"2\"><b>";
|
|
|
|
echo get_string("includelogentries").'</b>';
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print info
|
|
|
|
$table->data = log_check_backup($id);
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
|
|
|
|
//Now print the User Files tr conditionally
|
2006-01-16 00:39:01 +00:00
|
|
|
if ($backupprefs->backup_user_files) {
|
2003-05-04 21:29:27 +00:00
|
|
|
echo "<tr>";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<td colspan=\"2\"><b>";
|
|
|
|
echo get_string("includeuserfiles").'</b>';
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print info
|
2006-01-16 00:39:01 +00:00
|
|
|
$table->data = user_files_check_backup($id,$backupprefs->backup_unique_code);
|
2003-05-04 21:29:27 +00:00
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
|
|
|
|
|
|
|
//Now print the Course Files tr conditionally
|
2007-09-25 14:44:53 +00:00
|
|
|
if ($backupprefs->backup_course_files) {
|
2003-05-04 21:29:27 +00:00
|
|
|
echo "<tr>";
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<td colspan=\"2\"><b>";
|
|
|
|
echo get_string("includecoursefiles").'</b>';
|
2003-05-04 21:29:27 +00:00
|
|
|
//Print info
|
2006-01-16 00:39:01 +00:00
|
|
|
$table->data = course_files_check_backup($id,$backupprefs->backup_unique_code);
|
2003-05-04 21:29:27 +00:00
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
2007-09-25 14:44:53 +00:00
|
|
|
|
|
|
|
//Now print the site Files tr conditionally
|
|
|
|
if ($backupprefs->backup_site_files) {
|
2007-08-09 21:50:59 +00:00
|
|
|
echo "<tr>";
|
|
|
|
echo "<td colspan=\"2\"><b>";
|
|
|
|
echo get_string("includesitefiles").'</b>';
|
|
|
|
//Print info
|
|
|
|
$table->data = site_files_check_backup($id,$backupprefs->backup_unique_code);
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
2007-09-25 14:44:53 +00:00
|
|
|
|
|
|
|
//Now print the role assignments information conditionally
|
|
|
|
if (!empty($backupprefs->backuproleassignments)) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td colspan=\"2\"><b>";
|
|
|
|
echo get_string("includeroleassignments").'</b>';
|
|
|
|
//Print info
|
|
|
|
$table->data = array(array(get_string('roles'), count($backupprefs->backuproleassignments)));
|
|
|
|
print_table($table);
|
|
|
|
echo "</td></tr>";
|
|
|
|
}
|
2003-05-04 21:29:27 +00:00
|
|
|
}
|
2006-01-16 00:39:01 +00:00
|
|
|
|
|
|
|
// now keep it for next time.
|
|
|
|
$SESSION->backupprefs[$course->id] = $backupprefs;
|
|
|
|
|
2003-05-04 21:29:27 +00:00
|
|
|
?>
|
|
|
|
</table>
|
2007-02-06 08:24:37 +00:00
|
|
|
<div style="text-align:center;margin-left:auto;margin-right:auto">
|
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") ?>" />
|
2007-02-06 08:24:37 +00:00
|
|
|
</div>
|
2004-09-12 01:34:24 +00:00
|
|
|
</form>
|