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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
<?php //$Id: backup_execute.html,v 1.42.2.1 2006/06/03 19:44:15 stronk7 Exp $
//This page prints the backup todo list to see everything
//Check login
require_login();
if (!empty($course->id)) {
if (!isteacheredit($course->id)) {
if (empty($to)) {
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
} else {
if (!isteacheredit($to)) {
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!");
}
$preferences = new StdClass;
backup_fetch_prefs_from_request($preferences,$count,$course);
//Another Info
$preferences->moodle_version = $CFG->version;
$preferences->moodle_release = $CFG->release;
$preferences->backup_version = $CFG->backup_version;
$preferences->backup_release = $CFG->backup_release;
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>";
}
//Check for temp and backup and backup_unique_code directory
//Create them as needed
echo "<li>".get_string("creatingtemporarystructures").'</li>';
$status = check_and_create_backup_dir($preferences->backup_unique_code);
//Empty dir
if ($status) {
$status = clear_backup_dir($preferences->backup_unique_code);
}
//Delete old_entries from backup tables
echo "<li>".get_string("deletingolddata").'</li>';
$status = backup_delete_old_data();
if (!$status) {
error ("An error occurred deleting old backup data");
}
//Create the moodle.xml file
if ($status) {
echo "<li>".get_string("creatingxmlfile");
//Begin a new list to xml contents
echo "<ul>";
echo "<li>".get_string("writingheader").'</li>';
//Obtain the xml file (create and open) and print prolog information
$backup_file = backup_open_xml($preferences->backup_unique_code);
echo "<li>".get_string("writinggeneralinfo").'</li>';
//Prints general info about backup to file
if ($backup_file) {
if (!$status = backup_general_info($backup_file,$preferences)) {
notify("An error occurred while backing up general info");
}
}
echo "<li>".get_string("writingcoursedata");
//Start new ul (for course)
echo "<ul>";
echo "<li>".get_string("courseinfo").'</li>';
//Prints course start (tag and general info)
if ($status) {
if (!$status = backup_course_start($backup_file,$preferences)) {
notify("An error occurred while backing up course start");
}
}
//Metacourse information
if ($status && $preferences->backup_metacourse) {
echo "<li>".get_string("metacourse").'</li>';
if (!$status = backup_course_metacourse($backup_file,$preferences)) {
notify("An error occurred while backing up metacourse info");
}
}
echo "<li>".get_string("blocks").'</li>';
//Blocks information
if ($status) {
if (!$status = backup_course_blocks($backup_file,$preferences)) {
notify("An error occurred while backing up course blocks");
}
}
echo "<li>".get_string("sections").'</li>';
//Section info
if ($status) {
if (!$status = backup_course_sections($backup_file,$preferences)) {
notify("An error occurred while backing up course sections");
}
}
//End course contents (close ul)
echo "</ul></li>";
//User info
if ($status) {
echo "<li>".get_string("writinguserinfo").'</li>';
if (!$status = backup_user_info($backup_file,$preferences)) {
notify("An error occurred while backing up user info");
}
}
//If we have selected to backup messages and we are
//doing a SITE backup, let's do it
if ($status && $preferences->backup_messages && $preferences->backup_course == SITEID) {
echo "<li>".get_string("writingmessagesinfo").'</li>';
if (!$status = backup_messages($backup_file,$preferences)) {
notify("An error occurred while backing up messages");
}
}
//If we have selected to backup quizzes, backup categories and
//questions structure (step 1). See notes on mod/quiz/backuplib.php
if ($status and !empty($preferences->mods['quiz']->backup)) {
echo "<li>".get_string("writingcategoriesandquestions").'</li>';
require_once($CFG->dirroot.'/mod/quiz/backuplib.php');
if (!$status = backup_question_categories($backup_file,$preferences)) {
notify("An error occurred while backing up quiz categories");
}
}
//Print logs if selected
if ($status) {
if ($preferences->backup_logs) {
echo "<li>".get_string("writingloginfo").'</li>';
if (!$status = backup_log_info($backup_file,$preferences)) {
notify("An error occurred while backing up log info");
}
}
}
//Print scales info
if ($status) {
echo "<li>".get_string("writingscalesinfo").'</li>';
if (!$status = backup_scales_info($backup_file,$preferences)) {
notify("An error occurred while backing up scales");
}
}
//Print groups info
if ($status) {
echo "<li>".get_string("writinggroupsinfo").'</li>';
if (!$status = backup_groups_info($backup_file,$preferences)) {
notify("An error occurred while backing up groups");
}
}
//Print events info
if ($status) {
echo "<li>".get_string("writingeventsinfo").'</li>';
if (!$status = backup_events_info($backup_file,$preferences)) {
notify("An error occurred while backing up events");
}
}
//Print gradebook info
if ($status) {
echo "<li>".get_string("writinggradebookinfo").'</li>';
if (!$status = backup_gradebook_info($backup_file,$preferences)) {
notify("An error occurred while backing up gradebook");
}
}
//Module info, this unique function makes all the work!!
//db export and module fileis copy
if ($status) {
$mods_to_backup = false;
//Check if we have any mod to backup
foreach ($preferences->mods as $module) {
if ($module->backup) {
$mods_to_backup = true;
}
}
//If we have to backup some module
if ($mods_to_backup) {
echo "<li>".get_string("writingmoduleinfo");
//Start modules tag
if (!$status = backup_modules_start ($backup_file,$preferences)) {
notify("An error occurred while backing up module info");
}
//Open ul for module list
echo "<ul>";
//Iterate over modules and call backup
foreach ($preferences->mods as $module) {
if ($module->backup and $status) {
echo "<li>".get_string("modulenameplural",$module->name).'</li>';
if (!$status = backup_module($backup_file,$preferences,$module->name)) {
notify("An error occurred while backing up '$module->name'");
}
}
}
//Close ul for module list
echo "</ul></li>";
//Close modules tag
if (!$status = backup_modules_end ($backup_file,$preferences)) {
notify("An error occurred while finishing the module backups");
}
}
}
//Prints course end
if ($status) {
if (!$status = backup_course_end($backup_file,$preferences)) {
notify("An error occurred while closing the course backup");
}
}
//Close the xml file and xml data
if ($backup_file) {
backup_close_xml($backup_file);
}
//End xml contents (close ul)
echo "</ul></li>";
}
//Now, if selected, copy user files
if ($status) {
if ($preferences->backup_user_files) {
echo "<li>".get_string("copyinguserfiles").'</li>';
if (!$status = backup_copy_user_files ($preferences)) {
notify("An error occurred while copying user files");
}
}
}
//Now, if selected, copy course files
if ($status) {
if ($preferences->backup_course_files) {
echo "<li>".get_string("copyingcoursefiles").'</li>';
if (!$status = backup_copy_course_files ($preferences)) {
notify("An error occurred while copying course files");
}
}
}
//Now, zip all the backup directory contents
if ($status) {
echo "<li>".get_string("zippingbackup").'</li>';
if (!$status = backup_zip ($preferences)) {
notify("An error occurred while zipping the backup");
}
}
//Now, copy the zip file to course directory
if ($status) {
echo "<li>".get_string("copyingzipfile").'</li>';
if (!$status = copy_zip_to_course_dir ($preferences)) {
notify("An error occurred while copying the zip file to the course directory");
}
}
//Now, clean temporary data (db and filesystem)
if ($status) {
echo "<li>".get_string("cleaningtempdata").'</li>';
if (!$status = clean_temp_data ($preferences)) {
notify("An error occurred while cleaning up temporary data");
}
}
//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) {
error ("The backup did not complete successfully",
"$CFG->wwwroot/course/view.php?id=$course->id");
}
if (empty($to)) {
//Print final message
print_simple_box(get_string("backupfinished"),"center");
print_continue("$CFG->wwwroot/files/index.php?id=".$preferences->backup_course."&wdir=/backupdata");
} else {
print_simple_box(get_string('importdataexported'),"CENTER");
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;
print_continue($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.
?>
|