]> git.mjollnir.org Git - moodle.git/commitdiff
Show the roll dates option only if the backup course has a start date
authorstronk7 <stronk7>
Sun, 16 Sep 2007 17:34:54 +0000 (17:34 +0000)
committerstronk7 <stronk7>
Sun, 16 Sep 2007 17:34:54 +0000 (17:34 +0000)
(some formats like main page, social..., haven't it and rolling dates
from 0 produces crazy dates. MDL-10125

Merged from MOODLE_18_STABLE

backup/restore_check.html
backup/restore_form.html

index 0e5e6b41fc3f161c14243f03c81ba91a0aaa2bea..0456fd43475465e252568a4c75b9aae93adb6ef2 100644 (file)
         $currentcourseshortname = $course_header->course_shortname; //"store_ShortName";
         $course_header->course_shortname =  stripslashes_safe($form1->shortname);  //"update_ShortName";
         $course_header->course_fullname =   stripslashes_safe($form1->fullname);   //"update_FullName";
-        $form1->startdate = make_timestamp($form1->startyear, $form1->startmonth, $form1->startday);
-        $currentcoursestartdate = $course_header->course_startdate;
-        $coursestartdatedateoffset = $form1->startdate - $currentcoursestartdate;
-        $restore->course_startdateoffset = $coursestartdatedateoffset; //change to restore
+    /// Roll dates only if the backup course has a start date
+    /// (some formats like main page, social..., haven't it and rolling dates
+    /// from 0 produces crazy dates. MDL-10125
+        if ($course_header->course_startdate) {
+            $form1->startdate = make_timestamp($form1->startyear, $form1->startmonth, $form1->startday);
+            $currentcoursestartdate = $course_header->course_startdate;
+            $coursestartdatedateoffset = $form1->startdate - $currentcoursestartdate;
+            $restore->course_startdateoffset = $coursestartdatedateoffset; //change to restore
+        } else { // don't roll if the course hasn't start date
+            $coursestartdatedateoffset = 0;
+            $restore->course_startdateoffset = 0;
+        }
     }
 
     ///Enforce SESSION->course_header rewrite (PHP 4.x needed because assigns are by value) MDL-8298
index da78ade98391ff4716b33cba020577c3ab5abe9e..6a3a715625fe3f8cfe80101dc4c74bf14a0656e1 100644 (file)
@@ -243,7 +243,17 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
         echo "<td align=\"right\"> ";
         print_string("startdate");
         echo ":</td><td>";
-        print_date_selector("startday", "startmonth", "startyear", $form1->startdate);
+    /// Show the roll dates option only if the backup course has a start date
+    /// (some formats like main page, social..., haven't it and rolling dates
+    /// from 0 produces crazy dates. MDL-10125
+        if ($form1->startdate) {
+            print_date_selector("startday", "startmonth", "startyear", $form1->startdate);
+        } else {
+            print_string('notavailable');
+            echo '<input type="hidden" name="startyear" value="0" />';
+            echo '<input type="hidden" name="startmonth" value="0" />';
+            echo '<input type="hidden" name="startday" value="0" />';
+        }
         helpbutton("coursestartdate", get_string("startdate"));
         echo "</td></tr>";
     }