]> git.mjollnir.org Git - moodle.git/commitdiff
Added support in copy_zip_to_course_dir() to save course
authorstronk7 <stronk7>
Mon, 1 Dec 2003 20:25:50 +0000 (20:25 +0000)
committerstronk7 <stronk7>
Mon, 1 Dec 2003 20:25:50 +0000 (20:25 +0000)
backup file in a custom directory (via $preferences->backup_destination).
Needed in scheduled backups.

backup/backuplib.php
backup/lib.php

index d2bd32b0713107ea18cb1590062b6abdea442d3b..33968ff92601961a5aa29b22d5d7acc131e9726e 100644 (file)
     
         global $CFG;
 
+        $status = true;
+
         //Define zip location (from)
         $from_zip_file = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/".$preferences->backup_name;
 
-        //Define zip destination (course dir)
-        $to_zip_file = $CFG->dataroot."/".$preferences->backup_course;
-
-        //echo "<p>From: ".$from_zip_file."<br>";                                              //Debug
-
-        //echo "<p>Checking: ".$to_zip_file."<br>";                                          //Debug
+        //Initialise $to_zip_file
+        $to_zip_file="";
 
-        //Checks course dir exists
-        $status = check_dir_exists($to_zip_file,true);
-
-        //Define zip destination (backup dir)
-        $to_zip_file = $to_zip_file."/backupdata";
-
-        //echo "<p>Checking: ".$to_zip_file."<br>";                                          //Debug
+        //If $preferences->backup_destination isn't empty, then copy to custom directory
+        if (!empty($preferences->backup_destination)) {
+            $to_zip_file = $preferences->backup_destination."/".$preferences->backup_name;
+        } else {
+            //Define zip destination (course dir)
+            $to_zip_file = $CFG->dataroot."/".$preferences->backup_course;
+    
+            //echo "<p>From: ".$from_zip_file."<br>";                                              //Debug
+    
+            //echo "<p>Checking: ".$to_zip_file."<br>";                                          //Debug
+    
+            //Checks course dir exists
+            $status = check_dir_exists($to_zip_file,true);
+    
+            //Define zip destination (backup dir)
+            $to_zip_file = $to_zip_file."/backupdata";
+    
+            //echo "<p>Checking: ".$to_zip_file."<br>";                                          //Debug
+    
+            //Checks backup dir exists
+            $status = check_dir_exists($to_zip_file,true);
 
-        //Checks backup dir exists
-        $status = check_dir_exists($to_zip_file,true);
+            //Define zip destination (zip file)
+            $to_zip_file = $to_zip_file."/".$preferences->backup_name;
+        }
 
-        //Define zip destination (zip file)
-        $to_zip_file = $to_zip_file."/".$preferences->backup_name;
-        
         //echo "<p>To: ".$to_zip_file."<br>";                                              //Debug
 
         //Copy zip file
index 30539d4f82b555a6ec09a293e36b65f1c12d46b2..1441efef93b1e6f214fd66399811d5d2a8aa1e01 100644 (file)
@@ -16,7 +16,7 @@
     //Gets all the information from backup_config table
     function backup_get_config() {
         $backup_config = null;
-        if ($configs = get_records('backup_config')) {
+        if ($configs = get_records("backup_config")) {
             foreach ($configs as $config) {
                 $backup_config[$config->name] = $config->value;
             }