]> git.mjollnir.org Git - moodle.git/commitdiff
do not add $restore->course_startdateoffset to ANY empty dates
authorgbateson <gbateson>
Thu, 14 Sep 2006 21:50:37 +0000 (21:50 +0000)
committergbateson <gbateson>
Thu, 14 Sep 2006 21:50:37 +0000 (21:50 +0000)
mod/hotpot/restorelib.php

index d0a45c39fa475021a726bb584367b70616933539..cdd04c2e7bb0dbcfdd649805bb5afaa48589cd4a 100644 (file)
@@ -119,19 +119,14 @@ function hotpot_restore_mods($mod, $restore) {
             fwrite ($restorelog, "<br>Hotpot - ".$xml['NAME'][0]['#']." <br>");
 
             // loop through time fields
-            $TAGS = array('TIMEOPEN'=>1, 'TIMECLOSE'=>1, 'TIMECREATED'=>0, 'TIMEMODIFIED'=>0);
-            foreach ($TAGS as $TAG=>$ignoreifempty) {
+            $TAGS = array('TIMEOPEN', 'TIMECLOSE', 'TIMECREATED', 'TIMEMODIFIED');
+            foreach ($TAGS as $TAG) {
+
+                // check $TAG has a sensible value
+                if (!empty($xml[$TAG][0]['#']) && is_string($xml[$TAG][0]['#'])) {
 
-                // get $TAG value
-                if (isset($xml[$TAG][0]['#'])) {
-                    $value = $xml[$TAG][0]['#'];
-                } else {
-                    $value = 0;
-                }
-                if (empty($value) && $ignoreifempty) {
-                    // do nothing
-                } else {
                     // write old date to $restorelog
+                    $value = $xml[$TAG][0]['#'];
                     $date = usergetdate($value);
                     fwrite ($restorelog, "$TAG was ". $date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']);
 
@@ -144,7 +139,6 @@ function hotpot_restore_mods($mod, $restore) {
                     $xml[$TAG][0]['#'] = $value;
                 }
             }
-            fclose($restorelog);
         }
 
         $status = hotpot_restore_records(