2 //This file contains all the general function needed (file manipulation...)
3 //not directly part of the backup/restore utility
5 require_once($CFG->dirroot
.'/lib/uploadlib.php');
7 //Sets a name/value pair in backup_config table
8 function backup_set_config($name, $value) {
9 if (get_field("backup_config", "name", "name", $name)) {
10 return set_field("backup_config", "value", addslashes($value), "name", $name);
12 $config = new object();
13 $config->name
= $name;
14 $config->value
= addslashes($value);
15 return insert_record("backup_config", $config);
19 //Gets all the information from backup_config table
20 function backup_get_config() {
21 $backup_config = null;
22 if ($configs = get_records("backup_config")) {
23 foreach ($configs as $config) {
24 $backup_config[$config->name
] = $config->value
;
27 return (object)$backup_config;
30 //Delete old data in backup tables (if exists)
31 //Four hours seem to be appropiate now that backup is stable
32 function backup_delete_old_data() {
36 //Change this if you want !!
39 $seconds = $hours * 60 * 60;
40 $delete_from = time()-$seconds;
41 //Now delete from tables
42 $status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
43 WHERE backup_code < '$delete_from'",false);
45 $status = execute_sql("DELETE FROM {$CFG->prefix}backup_files
46 WHERE backup_code < '$delete_from'",false);
48 //Now, delete old directory (if exists)
50 $status = backup_delete_old_dirs($delete_from);
55 //Function to delete dirs/files into temp/backup directory
56 //older than $delete_from
57 function backup_delete_old_dirs($delete_from) {
62 //Get files and directories in the temp backup dir witout descend
63 $list = get_directory_list($CFG->dataroot
."/temp/backup", "", false, true, true);
64 foreach ($list as $file) {
65 $file_path = $CFG->dataroot
."/temp/backup/".$file;
66 $moddate = filemtime($file_path);
67 if ($status && $moddate < $delete_from) {
68 //If directory, recurse
69 if (is_dir($file_path)) {
70 $status = delete_dir_contents($file_path);
71 //There is nothing, delete the directory itself
73 $status = rmdir($file_path);
85 //Function to check and create the needed dir to
87 function check_and_create_backup_dir($backup_unique_code) {
91 $status = check_dir_exists($CFG->dataroot
."/temp",true);
93 $status = check_dir_exists($CFG->dataroot
."/temp/backup",true);
96 $status = check_dir_exists($CFG->dataroot
."/temp/backup/".$backup_unique_code,true);
102 //Function to delete all the directory contents recursively
103 //it supports a excluded dit too
104 //Copied from the web !!
105 function delete_dir_contents ($dir,$excludeddir="") {
108 // if we've been given a directory that doesn't exist yet, return true.
109 // this happens when we're trying to clear out a course that has only just
115 // Create arrays to store files and directories
116 $dir_files = array();
117 $dir_subdirs = array();
119 // Make sure we can delete it
122 if ((($handle = opendir($dir))) == FALSE) {
123 // The directory could not be opened
127 // Loop through all directory entries, and construct two temporary arrays containing files and sub directories
128 while($entry = readdir($handle)) {
129 if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != "." && $entry != $excludeddir) {
130 $dir_subdirs[] = $dir. $slash .$entry;
132 else if ($entry != ".." && $entry != "." && $entry != $excludeddir) {
133 $dir_files[] = $dir. $slash .$entry;
137 // Delete all files in the curent directory return false and halt if a file cannot be removed
138 for($i=0; $i<count($dir_files); $i++
) {
139 chmod($dir_files[$i], 0777);
140 if (((unlink($dir_files[$i]))) == FALSE) {
145 // Empty sub directories and then remove the directory
146 for($i=0; $i<count($dir_subdirs); $i++
) {
147 chmod($dir_subdirs[$i], 0777);
148 if (delete_dir_contents($dir_subdirs[$i]) == FALSE) {
152 if (rmdir($dir_subdirs[$i]) == FALSE) {
161 // Success, every thing is gone return true
165 //Function to clear (empty) the contents of the backup_dir
166 function clear_backup_dir($backup_unique_code) {
170 $rootdir = $CFG->dataroot
."/temp/backup/".$backup_unique_code;
173 $status = delete_dir_contents($rootdir);
178 //Returns the module type of a course_module's id in a course
179 function get_module_type ($courseid,$moduleid) {
183 $results = get_records_sql ("SELECT cm.id, m.name
184 FROM {$CFG->prefix}course_modules cm,
185 {$CFG->prefix}modules m
186 WHERE cm.course = '$courseid' AND
187 cm.id = '$moduleid' AND
191 $name = $results[$moduleid]->name
;
198 //This function return the names of all directories under a give directory
200 function list_directories ($rootdir) {
204 $dir = opendir($rootdir);
205 while ($file=readdir($dir)) {
206 if ($file=="." ||
$file=="..") {
209 if (is_dir($rootdir."/".$file)) {
210 $results[$file] = $file;
217 //This function return the names of all directories and files under a give directory
219 function list_directories_and_files ($rootdir) {
223 $dir = opendir($rootdir);
224 while ($file=readdir($dir)) {
225 if ($file=="." ||
$file=="..") {
228 $results[$file] = $file;
234 //This function clean data from backup tables and
235 //delete all temp files used
236 function clean_temp_data ($preferences) {
242 //true->do it, false->don't do it. To debug if necessary.
244 //Now delete from tables
245 $status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
246 WHERE backup_code = '$preferences->backup_unique_code'",false);
248 $status = execute_sql("DELETE FROM {$CFG->prefix}backup_files
249 WHERE backup_code = '$preferences->backup_unique_code'",false);
251 //Now, delete temp directory (if exists)
252 $file_path = $CFG->dataroot
."/temp/backup/".$preferences->backup_unique_code
;
253 if (is_dir($file_path)) {
254 $status = delete_dir_contents($file_path);
255 //There is nothing, delete the directory itself
257 $status = rmdir($file_path);
264 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
265 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
266 //This functions are used to copy any file or directory ($from_file)
267 //to a new file or directory ($to_file). It works recursively and
268 //mantains file perms.
269 //I've copied it from: http://www.php.net/manual/en/function.copy.php
270 //Little modifications done
272 function backup_copy_file ($from_file,$to_file,$log_clam=false) {
276 if (is_file($from_file)) {
277 //echo "<br />Copying ".$from_file." to ".$to_file; //Debug
278 //$perms=fileperms($from_file);
279 //return copy($from_file,$to_file) && chmod($to_file,$perms);
281 if (copy($from_file,$to_file)) {
282 chmod($to_file,$CFG->directorypermissions
);
283 if (!empty($log_clam)) {
284 clam_log_upload($to_file,null,true);
290 else if (is_dir($from_file)) {
291 return backup_copy_dir($from_file,$to_file);
294 //echo "<br />Error: not file or dir ".$from_file; //Debug
299 function backup_copy_dir($from_file,$to_file) {
303 $status = true; // Initialize this, next code will change its value if needed
305 if (!is_dir($to_file)) {
306 //echo "<br />Creating ".$to_file; //Debug
308 $status = mkdir($to_file,$CFG->directorypermissions
);
310 $dir = opendir($from_file);
311 while ($file=readdir($dir)) {
312 if ($file=="." ||
$file=="..") {
315 $status = backup_copy_file ("$from_file/$file","$to_file/$file");
320 ///Ends copy file/dirs functions
321 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
322 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
325 function upgrade_backup_db($continueto) {
326 /// This function upgrades the backup tables, if necessary
327 /// It's called from admin/index.php, also backup.php and restore.php
331 require_once ("$CFG->dirroot/backup/version.php"); // Get code versions
333 if (empty($CFG->backup_version
)) { // Backup has never been installed.
334 $strdatabaseupgrades = get_string("databaseupgrades");
335 print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, "",
336 upgrade_get_javascript(), false, " ", " ");
339 print_heading('backup');
342 /// Both old .sql files and new install.xml are supported
343 /// but we priorize install.xml (XMLDB) if present
345 if (file_exists($CFG->dirroot
. '/backup/db/install.xml')) {
346 $status = install_from_xmldb_file($CFG->dirroot
. '/backup/db/install.xml'); //New method
347 } else if (file_exists($CFG->dirroot
. '/backup/db/' . $CFG->dbtype
. '.sql')) {
348 $status = modify_database($CFG->dirroot
. '/backup/db/' . $CFG->dbtype
. '.sql'); //Old method
353 if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
354 //initialize default backup settings now
355 $adminroot = admin_get_root();
356 apply_default_settings($adminroot->locate('backups'));
357 notify(get_string("databasesuccess"), "green");
358 notify(get_string("databaseupgradebackups", "", $backup_version), "green");
359 print_continue($continueto);
360 print_footer('none');
363 error("Upgrade of backup system failed! (Could not update version in config table)");
366 error("Backup tables could NOT be set up successfully!");
370 /// Upgrading code starts here
373 if (is_readable($CFG->dirroot
. '/backup/db/' . $CFG->dbtype
. '.php')) {
374 include_once($CFG->dirroot
. '/backup/db/' . $CFG->dbtype
. '.php'); // defines old upgrading function
377 if (is_readable($CFG->dirroot
. '/backup/db/upgrade.php')) {
378 include_once($CFG->dirroot
. '/backup/db/upgrade.php'); // defines new upgrading function
382 if ($backup_version > $CFG->backup_version
) { // Upgrade tables
383 $strdatabaseupgrades = get_string("databaseupgrades");
384 print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript());
387 print_heading('backup');
389 /// Run de old and new upgrade functions for the module
390 $oldupgrade_function = 'backup_upgrade';
391 $newupgrade_function = 'xmldb_backup_upgrade';
393 /// First, the old function if exists
394 $oldupgrade_status = true;
395 if ($oldupgrade && function_exists($oldupgrade_function)) {
397 $oldupgrade_status = $oldupgrade_function($CFG->backup_version
);
398 } else if ($oldupgrade) {
399 notify ('Upgrade function ' . $oldupgrade_function . ' was not available in ' .
400 '/backup/db/' . $CFG->dbtype
. '.php');
403 /// Then, the new function if exists and the old one was ok
404 $newupgrade_status = true;
405 if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) {
407 $newupgrade_status = $newupgrade_function($CFG->backup_version
);
408 } else if ($newupgrade) {
409 notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' .
410 '/backup/db/upgrade.php');
414 /// Now analyze upgrade results
415 if ($oldupgrade_status && $newupgrade_status) { // No upgrading failed
416 if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
417 notify(get_string("databasesuccess"), "green");
418 notify(get_string("databaseupgradebackups", "", $backup_version), "green");
419 print_continue($continueto);
420 print_footer('none');
423 error("Upgrade of backup system failed! (Could not update version in config table)");
426 error("Upgrade failed! See backup/version.php");
429 } else if ($backup_version < $CFG->backup_version
) {
431 notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
433 upgrade_log_finish();
437 //This function is used to insert records in the backup_ids table
438 //If the info field is greater than max_db_storage, then its info
439 //is saved to filesystem
440 function backup_putid ($backup_unique_code, $table, $old_id, $new_id, $info="") {
444 $max_db_storage = 128; //Max bytes to save to db, else save to file
448 //First delete to avoid PK duplicates
449 $status = backup_delid($backup_unique_code, $table, $old_id);
451 //Now, serialize info
452 $info_ser = serialize($info);
454 //Now, if the size of $info_ser > $max_db_storage, save it to filesystem and
455 //insert a "infile" in the info field
457 if (strlen($info_ser) > $max_db_storage) {
458 //Calculate filename (in current_backup_dir, $backup_unique_code_$table_$old_id.info)
459 $filename = $CFG->dataroot
."/temp/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
461 $status = backup_data2file($filename,$info_ser);
463 $info_to_save = "infile";
465 //Saving to db, addslashes
466 $info_to_save = addslashes($info_ser);
469 //Now, insert the record
472 $rec->backup_code
= $backup_unique_code;
473 $rec->table_name
= $table;
474 $rec->old_id
= $old_id;
475 $rec->new_id
= ($new_id === null?
0 : $new_id);
476 $rec->info
= $info_to_save;
478 if (!insert_record('backup_ids', $rec, false)) {
485 //This function is used to delete recods from the backup_ids table
486 //If the info field is "infile" then the file is deleted too
487 function backup_delid ($backup_unique_code, $table, $old_id) {
493 $status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
494 WHERE backup_code = $backup_unique_code AND
495 table_name = '$table' AND
496 old_id = '$old_id'",false);
500 //This function is used to get a record from the backup_ids table
501 //If the info field is "infile" then its info
502 //is read from filesystem
503 function backup_getid ($backup_unique_code, $table, $old_id) {
510 $status = get_record ("backup_ids","backup_code",$backup_unique_code,
514 //If info field = "infile", get file contents
515 if (!empty($status->info
) && $status->info
== "infile") {
516 $filename = $CFG->dataroot
."/temp/backup/".$backup_unique_code."/".$backup_unique_code."_".$table."_".$old_id.".info";
517 //Read data from file
518 $status2 = backup_file2data($filename,$info);
521 $status->info
= unserialize($info);
526 //Only if status (record exists)
528 ////First strip slashes
529 $temp = stripslashes($status->info
);
531 $status->info
= unserialize($temp);
538 //This function is used to add slashes (and decode from UTF-8 if needed)
539 //It's used intensivelly when restoring modules and saving them in db
540 function backup_todb ($data) {
541 return restore_decode_absolute_links(addslashes($data));
544 //This function is used to check that every necessary function to
545 //backup/restore exists in the current php installation. Thanks to
546 //gregb@crowncollege.edu by the idea.
547 function backup_required_functions($justcheck=false) {
549 if(!function_exists('utf8_encode')) {
550 if (empty($justcheck)) {
551 error('You need to add XML support to your PHP installation');
560 //This function send n white characters to the browser and flush the
561 //output buffer. Used to avoid browser timeouts and to show the progress.
562 function backup_flush($n=0,$time=false) {
563 if (defined('RESTORE_SILENTLY_NOFLUSH')) {
567 $ti = strftime("%X",time());
571 echo str_repeat(" ", $n) . $ti . "\n";
575 //This function creates the filename and write data to it
576 //returning status as result
577 function backup_data2file ($file,&$data) {
582 $f = fopen($file,"w");
583 $status = fwrite($f,$data);
584 $status2 = fclose($f);
586 return ($status && $status2);
589 //This function read the filename and read data from it
590 function backup_file2data ($file,&$data) {
595 $f = fopen($file,"r");
596 $data = fread ($f,filesize($file));
597 $status2 = fclose($f);
599 return ($status && $status2);
602 /** this function will restore an entire backup.zip into the specified course
603 * using standard moodle backup/restore functions, but silently.
604 * @param string $pathtofile the absolute path to the backup file.
605 * @param int $destinationcourse the course id to restore to.
606 * @param boolean $emptyfirst whether to delete all coursedata first.
607 * @param boolean $userdata whether to include any userdata that may be in the backup file.
608 * @param array $preferences optional, 0 will be used. Can contain:
614 function import_backup_file_silently($pathtofile,$destinationcourse,$emptyfirst=false,$userdata=false, $preferences=array()) {
615 global $CFG,$SESSION,$USER; // is there such a thing on cron? I guess so..
616 global $restore; // ick
619 $USER->admin
= 1; // not sure why, but this doesn't get set
622 define('RESTORE_SILENTLY',true); // don't output all the stuff to us.
624 $debuginfo = 'import_backup_file_silently: ';
625 $cleanupafter = false;
626 $errorstr = ''; // passed by reference to restore_precheck to get errors from.
628 if (!$course = get_record('course','id',$destinationcourse)) {
629 mtrace($debuginfo.'Course with id $destinationcourse was not a valid course!');
633 // first check we have a valid file.
634 if (!file_exists($pathtofile) ||
!is_readable($pathtofile)) {
635 mtrace($debuginfo.'File '.$pathtofile.' either didn\'t exist or wasn\'t readable');
639 // now make sure it's a zip file
640 require_once($CFG->dirroot
.'/lib/filelib.php');
641 $filename = substr($pathtofile,strrpos($pathtofile,'/')+
1);
642 $mimetype = mimeinfo("type", $filename);
643 if ($mimetype != 'application/zip') {
644 mtrace($debuginfo.'File '.$pathtofile.' was of wrong mimetype ('.$mimetype.')' );
648 // restore_precheck wants this within dataroot, so lets put it there if it's not already..
649 if (strstr($pathtofile,$CFG->dataroot
) === false) {
650 // first try and actually move it..
651 if (!check_dir_exists($CFG->dataroot
.'/temp/backup/',true)) {
652 mtrace($debuginfo.'File '.$pathtofile.' outside of dataroot and couldn\'t move it! ');
655 if (!copy($pathtofile,$CFG->dataroot
.'/temp/backup/'.$filename)) {
656 mtrace($debuginfo.'File '.$pathtofile.' outside of dataroot and couldn\'t move it! ');
659 $pathtofile = 'temp/backup/'.$filename;
660 $cleanupafter = true;
663 // it is within dataroot, so take it off the path for restore_precheck.
664 $pathtofile = substr($pathtofile,strlen($CFG->dataroot
.'/'));
667 if (!backup_required_functions()) {
668 mtrace($debuginfo.'Required function check failed (see backup_required_functions)');
672 @ini_set
("max_execution_time","3000");
673 raise_memory_limit("192M");
675 if (!$backup_unique_code = restore_precheck($destinationcourse,$pathtofile,$errorstr,true)) {
676 mtrace($debuginfo.'Failed restore_precheck (error was '.$errorstr.')');
680 $SESSION->restore
= new StdClass
;
682 // add on some extra stuff we need...
683 $SESSION->restore
->metacourse
= $restore->metacourse
= (isset($preferences['restore_metacourse']) ?
$preferences['restore_metacourse'] : 0);
684 $SESSION->restore
->restoreto
= $restore->restoreto
= 1;
685 $SESSION->restore
->users
= $restore->users
= $userdata;
686 $SESSION->restore
->logs
= $restore->logs
= (isset($preferences['restore_logs']) ?
$preferences['restore_logs'] : 0);
687 $SESSION->restore
->user_files
= $restore->user_files
= $userdata;
688 $SESSION->restore
->messages
= $restore->messages
= (isset($preferences['restore_messages']) ?
$preferences['restore_messages'] : 0);
689 $SESSION->restore
->course_id
= $restore->course_id
= $destinationcourse;
690 $SESSION->restore
->restoreto
= 1;
691 $SESSION->restore
->course_id
= $destinationcourse;
692 $SESSION->restore
->deleting
= $emptyfirst;
693 $SESSION->restore
->restore_course_files
= $restore->course_files
= (isset($preferences['restore_course_files']) ?
$preferences['restore_course_files'] : 0);
694 $SESSION->restore
->backup_version
= $SESSION->info
->backup_backup_version
;
695 $SESSION->restore
->course_startdateoffset
= $course->startdate
- $SESSION->course_header
->course_startdate
;
697 restore_setup_for_check($SESSION->restore
,$backup_unique_code);
699 // maybe we need users (defaults to 2 in restore_setup_for_check)
700 if (!empty($userdata)) {
701 $SESSION->restore
->users
= 1;
704 // we also need modules...
705 if ($allmods = get_records("modules")) {
706 foreach ($allmods as $mod) {
707 $modname = $mod->name
;
708 //Now check that we have that module info in the backup file
709 if (isset($SESSION->info
->mods
[$modname]) && $SESSION->info
->mods
[$modname]->backup
== "true") {
710 $SESSION->restore
->mods
[$modname]->restore
= true;
711 $SESSION->restore
->mods
[$modname]->userinfo
= $userdata;
715 $SESSION->restore
->mods
[$modname]->restore
= false;
716 $SESSION->restore
->mods
[$modname]->userinfo
= false;
720 $restore = clone($SESSION->restore
);
721 if (!restore_execute($SESSION->restore
,$SESSION->info
,$SESSION->course_header
,$errorstr)) {
722 mtrace($debuginfo.'Failed restore_execute (error was '.$errorstr.')');
729 * Function to backup an entire course silently and create a zipfile.
731 * @param int $courseid the id of the course
732 * @param array $prefs see {@link backup_generate_preferences_artificially}
734 function backup_course_silently($courseid, $prefs, &$errorstring) {
735 global $CFG, $preferences; // global preferences here because something else wants it :(
736 define('BACKUP_SILENTLY', 1);
737 if (!$course = get_record('course', 'id', $courseid)) {
738 debugging("Couldn't find course with id $courseid in backup_course_silently");
741 $preferences = backup_generate_preferences_artificially($course, $prefs);
742 if (backup_execute($preferences, $errorstring)) {
743 return $CFG->dataroot
. '/' . $course->id
. '/backupdata/' . $preferences->backup_name
;
751 * Function to generate the $preferences variable that
752 * backup uses. This will back up all modules and instances in a course.
754 * @param object $course course object
755 * @param array $prefs can contain:
762 * and if not provided, they will not be included.
765 function backup_generate_preferences_artificially($course, $prefs) {
767 $preferences = new StdClass
;
768 $preferences->backup_unique_code
= time();
769 $preferences->backup_name
= backup_get_zipfile_name($course, $preferences->backup_unique_code
);
772 if ($allmods = get_records("modules") ) {
773 foreach ($allmods as $mod) {
774 $modname = $mod->name
;
775 $modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
776 $modbackup = $modname."_backup_mods";
777 $modbackupone = $modname."_backup_one_mod";
778 $modcheckbackup = $modname."_check_backup_mods";
779 if (!file_exists($modfile)) {
782 include_once($modfile);
783 if (!function_exists($modbackup) ||
!function_exists($modcheckbackup)) {
786 $var = "exists_".$modname;
787 $preferences->$var = true;
789 // check that there are instances and we can back them up individually
790 if (!count_records('course_modules','course',$course->id
,'module',$mod->id
) ||
!function_exists($modbackupone)) {
793 $var = 'exists_one_'.$modname;
794 $preferences->$var = true;
795 $varname = $modname.'_instances';
796 $preferences->$varname = get_all_instances_in_course($modname,$course);
797 foreach ($preferences->$varname as $instance) {
798 $preferences->mods
[$modname]->instances
[$instance->id
]->name
= $instance->name
;
799 $var = 'backup_'.$modname.'_instance_'.$instance->id
;
800 $preferences->$var = true;
801 $preferences->mods
[$modname]->instances
[$instance->id
]->backup
= true;
802 $var = 'backup_user_info_'.$modname.'_instance_'.$instance->id
;
803 $preferences->$var = true;
804 $preferences->mods
[$modname]->instances
[$instance->id
]->userinfo
= true;
805 $var = 'backup_'.$modname.'_instances';
806 $preferences->$var = 1; // we need this later to determine what to display in modcheckbackup.
811 $preferences->mods
[$modname]->name
= $modname;
813 $var = "backup_".$modname;
814 $preferences->$var = true;
815 $preferences->mods
[$modname]->backup
= true;
817 //Check include user info
818 $var = "backup_user_info_".$modname;
819 $preferences->$var = true;
820 $preferences->mods
[$modname]->userinfo
= true;
825 //Check other parameters
826 $preferences->backup_metacourse
= (isset($prefs['backup_metacourse']) ?
$prefs['backup_metacourse'] : 0);
827 $preferences->backup_users
= (isset($prefs['backup_users']) ?
$prefs['backup_users'] : 0);
828 $preferences->backup_logs
= (isset($prefs['backup_logs']) ?
$prefs['backup_logs'] : 0);
829 $preferences->backup_user_files
= (isset($prefs['backup_user_files']) ?
$prefs['backup_user_files'] : 0);
830 $preferences->backup_course_files
= (isset($prefs['backup_course_files']) ?
$prefs['backup_course_files'] : 0);
831 $preferences->backup_messages
= (isset($prefs['backup_messages']) ?
$prefs['backup_messages'] : 0);
832 $preferences->backup_course
= $course->id
;
833 backup_add_static_preferences($preferences);