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)) {
|
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)) {
|
2008-05-08 08:43:17 +00:00
|
|
|
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
|
2005-01-27 02:35:10 +00:00
|
|
|
} else {
|
2006-09-13 09:08:14 +00:00
|
|
|
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
|
2008-05-08 08:43:17 +00:00
|
|
|
print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
|
2005-01-27 02:35:10 +00:00
|
|
|
}
|
|
|
|
}
|
2003-08-01 14:42:14 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-05-02 04:37:02 +00:00
|
|
|
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
|
2008-05-08 08:43:17 +00:00
|
|
|
print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
|
2003-08-01 14:42:14 +00:00
|
|
|
}
|
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()) {
|
2008-05-08 08:43:17 +00:00
|
|
|
print_error("siteisnotdefined", 'debug');
|
2003-05-18 17:15:05 +00:00
|
|
|
}
|
|
|
|
|
2006-01-16 00:39:01 +00:00
|
|
|
$preferences = new StdClass;
|
|
|
|
backup_fetch_prefs_from_request($preferences,$count,$course);
|
2003-05-06 22:48:25 +00:00
|
|
|
//Another Info
|
2007-03-23 06:14:40 +00:00
|
|
|
backup_add_static_preferences($preferences);
|
2003-05-04 23:24:48 +00:00
|
|
|
|
2003-05-04 21:29:27 +00:00
|
|
|
if ($count == 0) {
|
|
|
|
notice("No backupable modules are installed!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
//Start the main table
|
2005-02-05 01:00:33 +00:00
|
|
|
echo "<table cellpadding=\"5\">";
|
2005-01-27 02:35:10 +00:00
|
|
|
|
|
|
|
//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").":";
|
|
|
|
echo "</b></td><td>";
|
|
|
|
echo $preferences->backup_name;
|
|
|
|
echo "</td></tr>";
|
|
|
|
|
|
|
|
//Start the main tr, where all the backup progress is done
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td colspan=\"2\">";
|
|
|
|
|
|
|
|
//Start the main ul
|
|
|
|
echo "<ul>";
|
|
|
|
}
|
2003-05-11 11:06:23 +00:00
|
|
|
|
2007-03-23 06:14:40 +00:00
|
|
|
$errorstr = '';
|
|
|
|
$status = backup_execute($preferences, $errorstr);
|
2003-05-11 11:06:23 +00:00
|
|
|
|
2003-05-06 22:48:25 +00:00
|
|
|
//Ends th main ul
|
|
|
|
echo "</ul>";
|
2003-05-04 21:29:27 +00:00
|
|
|
|
2003-05-04 23:24:48 +00:00
|
|
|
//End the main tr, where all the backup is done
|
2003-05-06 22:48:25 +00:00
|
|
|
echo "</td></tr>";
|
2003-05-04 21:29:27 +00:00
|
|
|
|
2003-05-04 23:24:48 +00:00
|
|
|
//End the main table
|
|
|
|
echo "</table>";
|
2003-07-07 18:42:19 +00:00
|
|
|
|
|
|
|
if (!$status) {
|
2008-12-12 05:45:43 +00:00
|
|
|
print_error('error', 'error', "$CFG->wwwroot/course/view.php?id=$course->id");
|
2003-07-07 18:42:19 +00:00
|
|
|
}
|
2003-05-11 17:45:56 +00:00
|
|
|
|
2005-01-27 02:35:10 +00:00
|
|
|
if (empty($to)) {
|
|
|
|
//Print final message
|
|
|
|
print_simple_box(get_string("backupfinished"),"center");
|
2008-11-06 06:49:33 +00:00
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
|
|
|
print_continue("$CFG->wwwroot/files/index.php?contextid=".$context->id."&filearea=course_backup&itemid=0");
|
2005-01-27 02:35:10 +00:00
|
|
|
} else {
|
|
|
|
print_simple_box(get_string('importdataexported'),"CENTER");
|
|
|
|
if (!empty($preferences->backup_destination)) {
|
|
|
|
$filename = $preferences->backup_destination."/".$preferences->backup_name;
|
|
|
|
} else {
|
|
|
|
$filename = $preferences->backup_course."/backupdata/".$preferences->backup_name;
|
|
|
|
}
|
|
|
|
error_log($filename);
|
|
|
|
$SESSION->import_preferences = $preferences;
|
2005-11-08 07:01:12 +00:00
|
|
|
print_continue($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
|
2005-01-27 02:35:10 +00:00
|
|
|
}
|
2006-01-16 00:39:01 +00:00
|
|
|
|
|
|
|
$SESSION->backupprefs[$course->id] = null; // unset it so we're clear next time.
|
2003-05-04 21:29:27 +00:00
|
|
|
?>
|