2 //This page prints the backup todo list to see everything
7 if (!empty($course->id
)) {
8 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
10 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
12 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE
, $to))) {
13 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
18 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM
))) {
19 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
25 if (!$site = get_site()) {
26 error("Site not found!");
29 $preferences = new StdClass
;
30 backup_fetch_prefs_from_request($preferences,$count,$course);
32 backup_add_static_preferences($preferences);
35 notice("No backupable modules are installed!");
40 //Start the main table
41 echo "<table cellpadding=\"5\">";
43 //Now print the Backup Name tr
45 echo "<td align=\"right\"><b>";
46 echo get_string("name").":";
48 echo $preferences->backup_name
;
51 //Start the main tr, where all the backup progress is done
53 echo "<td colspan=\"2\">";
60 $status = backup_execute($preferences, $errorstr);
65 //End the main tr, where all the backup is done
72 error ("The backup did not complete successfully",
73 "$CFG->wwwroot/course/view.php?id=$course->id");
78 print_simple_box(get_string("backupfinished"),"center");
79 print_continue("$CFG->wwwroot/files/index.php?id=".$preferences->backup_course
."&wdir=/backupdata");
81 print_simple_box(get_string('importdataexported'),"CENTER");
82 if (!empty($preferences->backup_destination
)) {
83 $filename = $preferences->backup_destination
."/".$preferences->backup_name
;
85 $filename = $preferences->backup_course
."/backupdata/".$preferences->backup_name
;
88 $SESSION->import_preferences
= $preferences;
89 print_continue($CFG->wwwroot
.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
92 $SESSION->backupprefs
[$course->id
] = null; // unset it so we're clear next time.