More logical wording on button to import from local file
[moodle-linuxchix.git] / backup / backup_check.html
blobefc5c82f84ba76ea131a37cde88899ab7db773fe
1 <?php //$Id$
2 //This page prints the backup todo list to see everything
4 //Check login
5 require_login();
7 if (!empty($course->id)) {
8 if (!isteacheredit($course->id)) {
9 if (empty($to)) {
10 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
11 } else {
12 if (!isteacheredit($to)) {
13 error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
17 } else {
18 if (!isadmin()) {
19 error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
25 $backupprefs = new StdClass;
26 $count = 0;
27 backup_fetch_prefs_from_request($backupprefs,$count,$course);
29 //Check site
30 if (!$site = get_site()) {
31 error("Site not found!");
33 if ($count == 0) {
34 notice("No backupable modules are installed!");
38 <form name="form" method="post" action="backup.php">
39 <table cellpadding="5">
40 <?php
42 if (empty($to)) {
43 //Now print the Backup Name tr
44 echo "<tr>";
45 echo "<td align=\"right\"><b>";
46 echo get_string("name").":";
47 echo "</b></td><td>";
48 //Add as text field
49 echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backupprefs->backup_name."\" />";
50 echo "</td></tr>";
52 //Line
53 echo "<tr><td colspan=\"2\"><hr /></td></tr>";
55 //Now print the To Do list
56 echo "<tr>";
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
64 //inform the user.
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");
85 echo "<hr />";
88 if (empty($to)) {
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)) {
101 continue;
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;
109 //Only if selected
110 if ($backupprefs->$var == 1) {
111 //Print the full tr
112 echo "<tr>";
113 echo "<td colspan=\"2\">";
114 //Add hidden fields
115 $var = "backup_".$modname;
116 $var = "backup_user_info_".$modname;
117 //Print the mod name
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();
131 $countinstances = 0;
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)) {
136 $obj = new StdClass;
137 $obj->name = $instance->name;
138 $obj->userdata = $backupprefs->$var2;
139 $obj->id = $instance->id;
140 $instancestopass[$instance->id]= $obj;
141 $countinstances++;
146 $table->data = $modcheckbackup($id,$backupprefs->$var,$backupprefs->backup_unique_code,$instancestopass);
147 print_table($table);
148 echo "</td></tr>";
154 if (empty($to)) {
155 //Line
156 echo "<tr><td colspan=\"2\"><hr /></td></tr>";
158 //Now print the Users tr
159 echo "<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>';
165 //Print info
166 $table->data = user_check_backup($id,$backupprefs->backup_unique_code,$backupprefs->backup_users,$backupprefs->backup_messages);
167 print_table($table);
168 echo "</td></tr>";
172 //Now print the Logs tr conditionally
173 if ($backupprefs->backup_logs && empty($to)) {
174 echo "<tr>";
175 echo "<td colspan=\"2\"><b>";
176 echo get_string("includelogentries").'</b>';
177 //Print info
178 $table->data = log_check_backup($id);
179 print_table($table);
180 echo "</td></tr>";
183 //Now print the User Files tr conditionally
184 if ($backupprefs->backup_user_files) {
185 echo "<tr>";
186 echo "<td colspan=\"2\"><b>";
187 echo get_string("includeuserfiles").'</b>';
188 //Print info
189 $table->data = user_files_check_backup($id,$backupprefs->backup_unique_code);
190 print_table($table);
191 echo "</td></tr>";
194 //Now print the Course Files tr conditionally
195 if ($backupprefs->backup_course_files) {
196 echo "<tr>";
197 echo "<td colspan=\"2\"><b>";
198 echo get_string("includecoursefiles").'</b>';
199 //Print info
200 $table->data = course_files_check_backup($id,$backupprefs->backup_unique_code);
201 print_table($table);
202 echo "</td></tr>";
206 // now keep it for next time.
207 $SESSION->backupprefs[$course->id] = $backupprefs;
210 </table>
211 <br />
212 <center>
213 <input type="hidden" name="to" value="<?php p($to) ?>" />
214 <input type="hidden" name="id" value="<?php p($id) ?>" />
215 <input type="hidden" name="launch" value="execute" />
216 <input type="submit" value="<?php print_string("continue") ?>" />
217 <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
218 </center>
219 </form>