]> git.mjollnir.org Git - moodle.git/commitdiff
Now, nextexecutiontime is recalculated everytime the form is submitted to
authorstronk7 <stronk7>
Fri, 14 May 2004 16:37:45 +0000 (16:37 +0000)
committerstronk7 <stronk7>
Fri, 14 May 2004 16:37:45 +0000 (16:37 +0000)
have the time updated in the logs page.

admin/backup.php

index 3623bb6572d3b890c84568635b279973f6ed627f..14fd644e4ebacb50f0111c2f84a96147f4549f2a 100644 (file)
@@ -3,6 +3,7 @@
 
     require_once("../config.php");
     require_once("../backup/lib.php");
+    require_once("../backup/backup_scheduled.php");
 
     require_login();
 
         foreach ($config as $name => $value) {
             backup_set_config($name, $value);
         }
+
+        //And now, we execute schedule_backup_next_execution() for each course in the server to have the next
+        //execution time updated automatically everytime it's changed.
+        $status = true;
+        //get admin
+        $admin = get_admin();
+        if (!$admin) {
+            $status = false;
+        }
+        //get backup config
+        if ($status) {
+            if (! $backup_config =  backup_get_config()) {
+                $status = false;
+            }
+            //get courses
+            if ($courses = get_records("course")) {
+                //For each course, we check (insert, update) the backup_course table
+                //with needed data
+                foreach ($courses as $course) {
+                    //We check if the course exists in backup_course
+                    $backup_course = get_record("backup_courses","courseid",$course->id);
+                    //If it doesn't exist, create 
+                    if (!$backup_course) {
+                        $temp_backup_course->courseid = $course->id;
+                        $newid = insert_record("backup_courses",$temp_backup_course);
+                        //And get it from db
+                        $backup_course = get_record("backup_courses","id",$newid);
+                    }
+                    //Now, calculate next execution of the course
+                    $nextstarttime = schedule_backup_next_execution ($backup_course,$backup_config,time(),$admin->timezone);
+                    //Save it to db
+                    set_field("backup_courses","nextstarttime",$nextstarttime,"courseid",$backup_course->courseid);
+                }
+            }
+        }
+
         if (!$error) {
             redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
             exit;