forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup_execute.html
93 lines (74 loc) · 2.9 KB
/
backup_execute.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
//This page prints the backup todo list to see everything
//Check login
require_login();
$loginurl = get_login_url();
if (!empty($course->id)) {
if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (empty($to)) {
print_error("cannotuseadminadminorteacher", '', $loginurl);
} else {
if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("cannotuseadminadminorteacher", '', $loginurl);
}
}
}
} else {
if (!has_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM))) {
print_error("cannotuseadmin", '', $loginurl);
}
}
//Check site
$site = get_site();
$preferences = new StdClass;
backup_fetch_prefs_from_request($preferences,$count,$course);
//Another Info
backup_add_static_preferences($preferences);
if ($count == 0) {
notice("No backupable modules are installed!");
}
if (empty($to)) {
//Start the main table
echo "<table cellpadding=\"5\">";
//Now print the Backup Name tr
echo "<tr>";
echo "<td align=\"right\"><b>";
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>";
}
$errorstr = '';
$status = backup_execute($preferences, $errorstr);
//Ends th main ul
echo "</ul>";
//End the main tr, where all the backup is done
echo "</td></tr>";
//End the main table
echo "</table>";
if (!$status) {
print_error('error', 'error', "$CFG->wwwroot/course/view.php?id=$course->id");
}
if (empty($to)) {
//Print final message
echo $OUTPUT->box(get_string("backupfinished"));
$context = get_context_instance(CONTEXT_COURSE, $course->id);
echo $OUTPUT->continue_button("$CFG->wwwroot/files/index.php?contextid=".$context->id."&filearea=course_backup&itemid=0");
} else {
echo $OUTPUT->box(get_string('importdataexported'));
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;
echo $OUTPUT->continue_button($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename);
}
$SESSION->backupprefs[$course->id] = null; // unset it so we're clear next time.
?>