forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_form.html
155 lines (140 loc) · 5.08 KB
/
backup_form.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?PHP //$Id$
//This page prints the backup form to select everything
//Check login
require_login();
if (!empty($course->id)) {
if (!isteacheredit($course->id)) {
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
} else {
if (!isadmin()) {
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
error("Site not found!");
}
//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;
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$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)) {
$backup_logs = 0;
}
if (!isset($backup_user_files)) {
$backup_user_files = 1;
}
if (!isset($backup_course_files)) {
$backup_course_files = 1;
}
if ($count == 0) {
notice("No backupable modules are installed!");
}
?>
<form name="form" method="post" action="<?php echo $ME ?>">
<table cellpadding=5>
<?php
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modbackup = $modname."_backup_mods";
//If exists the lib & function
$var = "exists_".$modname;
if (isset($$var) && $$var) {
//Print the full tr
echo "<tr>";
echo "<td align=\"right\"><P><B>";
echo get_string("include")." ". get_string("modulenameplural",$modname).":";
echo "</td><td>";
$backup_options[0] = get_string("no");
$backup_options[1] = get_string("yes");
$var = "backup_".$modname;
choose_from_menu($backup_options, $var, $$var, "");
$backup_user_options[0] = get_string("withoutuserdata");
$backup_user_options[1] = get_string("withuserdata");
$var = "backup_user_info_".$modname;
choose_from_menu($backup_user_options, $var, $$var, "");
echo "</td></tr>";
}
}
//Line
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
//Now print the Users tr
echo "<tr>";
echo "<td align=\"right\"><P><B>";
echo get_string("users").":";
echo "</td><td>";
$user_options[0] = get_string("all");
$user_options[1] = get_string("course");
$user_options[2] = get_string("none");
choose_from_menu($user_options, "backup_users", $backup_users, "");
echo "</td></tr>";
//Now print the Logs tr
echo "<tr>";
echo "<td align=\"right\"><P><B>";
echo get_string("logs").":";
echo "</td><td>";
$log_options[0] = get_string("no");
$log_options[1] = get_string("yes");
choose_from_menu($log_options, "backup_logs", $backup_logs, "");
echo "</td></tr>";
//Now print the User Files tr
echo "<tr>";
echo "<td align=\"right\"><P><B>";
echo get_string ("userfiles").":";
echo "</td><td>";
$user_file_options[0] = get_string("no");
$user_file_options[1] = get_string("yes");
choose_from_menu($user_file_options, "backup_user_files", $backup_user_files, "");
echo "</td></tr>";
//Now print the Course Files tr
echo "<tr>";
echo "<td align=\"right\"><P><B>";
echo get_string ("coursefiles").":";
echo "</td><td>";
$course_file_options[0] = get_string("no");
$course_file_options[1] = get_string("yes");
choose_from_menu($course_file_options, "backup_course_files", $backup_course_files, "");
echo "</td></tr>";
}
?>
</table>
<BR>
<CENTER>
<input type="hidden" name=id value="<?php p($id) ?>">
<input type="hidden" name=launch value="check">
<input type="submit" value="<?php print_string("continue") ?>">
<input type="submit" name=cancel value="<?php print_string("cancel") ?>">
</CENTER>
</FORM>