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
, SITEID
))) {
19 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
25 $backupprefs = new StdClass
;
27 backup_fetch_prefs_from_request($backupprefs,$count,$course);
30 if (!$site = get_site()) {
31 error("Site not found!");
34 notice("No backupable modules are installed!");
38 <form id=
"form" method=
"post" action=
"backup.php">
39 <table cellpadding=
"5" style=
"text-align:center;margin-left:auto;margin-right:auto">
43 //Now print the Backup Name tr
45 echo "<td align=\"right\"><b>";
46 echo get_string("name").":";
49 echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backupprefs->backup_name
."\" />";
53 echo "<tr><td colspan=\"2\"><hr /></td></tr>";
55 //Now print the To Do list
57 echo "<td colspan=\"2\" align=\"center\"><b>";
62 //Here we check if backup_users = None. Then, we switch off every module
63 //user info, user_files, logs and exercises, workshop and messages backups. A Warning is showed to
65 if ($backupprefs->backup_users
== 2) {
66 if ($allmods = get_records("modules") ) {
67 foreach ($allmods as $mod) {
68 $modname = $mod->name
;
69 $var = "backup_user_info_".$modname;
70 if (isset($backupprefs->$var)) {
71 $backupprefs->$var = 0;
73 $var = "backup_".$modname;
74 if (isset($backupprefs->$var)) {
75 if ($modname == "exercise" ||
$modname == "workshop") {
76 $backupprefs->$var = 0;
80 $backupprefs->backup_user_files
= 0;
81 $backupprefs->backup_logs
= 0;
82 $backupprefs->backup_messages
= 0;
84 print_simple_box("<font color=\"red\">".get_string("backupnoneusersinfo")."</font>","center", "70%", '', "20", "noticebox");
89 echo get_string("backupdetails").":";
90 echo "</b></td></tr>";
93 //This is tha align to every ingo table
94 $table->align
= array ("left","right");
96 if ($allmods = get_records("modules") ) {
97 foreach ($allmods as $mod) {
98 $modname = $mod->name
;
99 $modfile = $CFG->dirroot
.'/mod/'.$modname.'/backuplib.php';
100 if (!file_exists($modfile)) {
103 require_once($modfile);
104 $modbackup = $modname."_backup_mods";
105 //If exists the lib & function
106 $var = "exists_".$modname;
107 if (isset($backupprefs->$var) && $backupprefs->$var) {
108 $var = "backup_".$modname;
110 if (!empty($backupprefs->$var) and ($backupprefs->$var == 1)) {
113 echo "<td colspan=\"2\">";
115 $var = "backup_".$modname;
116 $var = "backup_user_info_".$modname;
118 echo "<b>".get_string("include")." ".get_string("modulenameplural",$modname)." ";
119 //Now look for user-data status
120 $backup_user_options[0] = get_string("withoutuserdata");
121 $backup_user_options[1] = get_string("withuserdata");
122 $var = "backup_user_info_".$modname;
123 //Print the user info
124 echo $backup_user_options[$backupprefs->$var]."</b>";
125 //Call the check function to show more info
126 $modcheckbackup = $modname."_check_backup_mods";
127 $var = $modname.'_instances';
128 $instancestopass = array();
129 if (!empty($backupprefs->$var) && is_array($backupprefs->$var) && count($backupprefs->$var)) {
130 $table->data
= array();
132 foreach ($backupprefs->$var as $instance) {
133 $var1 = 'backup_'.$modname.'_instance_'.$instance->id
;
134 $var2 = 'backup_user_info_'.$modname.'_instance_'.$instance->id
;
135 if (!empty($backupprefs->$var1)) {
137 $obj->name
= $instance->name
;
138 $obj->userdata
= $backupprefs->$var2;
139 $obj->id
= $instance->id
;
140 $instancestopass[$instance->id
]= $obj;
146 $table->data
= $modcheckbackup($id,$backupprefs->$var,$backupprefs->backup_unique_code
,$instancestopass);
156 echo "<tr><td colspan=\"2\"><hr /></td></tr>";
158 //Now print the Users tr
160 echo "<td colspan=\"2\"><b>";
161 $user_options[0] = get_string("includeallusers");
162 $user_options[1] = get_string("includecourseusers");
163 $user_options[2] = get_string("includenoneusers");
164 echo $user_options[$backupprefs->backup_users
].'</b>';
166 $table->data
= user_check_backup($id,$backupprefs->backup_unique_code
,$backupprefs->backup_users
,$backupprefs->backup_messages
);
172 //Now print the Logs tr conditionally
173 if ($backupprefs->backup_logs
&& empty($to)) {
175 echo "<td colspan=\"2\"><b>";
176 echo get_string("includelogentries").'</b>';
178 $table->data
= log_check_backup($id);
183 //Now print the User Files tr conditionally
184 if ($backupprefs->backup_user_files
) {
186 echo "<td colspan=\"2\"><b>";
187 echo get_string("includeuserfiles").'</b>';
189 $table->data
= user_files_check_backup($id,$backupprefs->backup_unique_code
);
194 //Now print the Course Files tr conditionally
195 if ($backupprefs->backup_course_files
) {
197 echo "<td colspan=\"2\"><b>";
198 echo get_string("includecoursefiles").'</b>';
200 $table->data
= course_files_check_backup($id,$backupprefs->backup_unique_code
);
206 // now keep it for next time.
207 $SESSION->backupprefs
[$course->id
] = $backupprefs;
211 <div style=
"text-align:center;margin-left:auto;margin-right:auto">
212 <input type=
"hidden" name=
"to" value=
"<?php p($to) ?>" />
213 <input type
="hidden" name
="id" value
="<?php p($id) ?>" />
214 <input type
="hidden" name
="launch" value
="execute" />
215 <input type
="submit" value
="<?php print_string("continue") ?>" />
216 <input type
="submit" name
="cancel" value
="<?php print_string("cancel
") ?>" />