diff --git a/build.xml b/build.xml index db4f49a..c1362ad 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ - + diff --git a/changelog.txt b/changelog.txt index 389d0a0..61bc3e0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +calendarimporter 2.0.3: + - fixed all day events + calendarimporter 2.0.2: - fixed crash when public store does not exist - check if temporary directory is writeable diff --git a/js/dialogs/ImportPanel.js b/js/dialogs/ImportPanel.js index a0653cf..fcea308 100644 --- a/js/dialogs/ImportPanel.js +++ b/js/dialogs/ImportPanel.js @@ -600,10 +600,12 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar'); var pubStore = container.getHierarchyStore().getPublicStore(); var pubSubFolders = []; + var pubFolder; + if(typeof pubStore !== "undefined") { try { - var pubFolder = pubStore.getDefaultFolder("publicfolders"); - var pubSubFolders = pubFolder.getChildren(); + pubFolder = pubStore.getDefaultFolder("publicfolders"); + pubSubFolders = pubFolder.getChildren(); } catch (e) { console.log("Error opening the shared folder..."); console.log(e); @@ -729,10 +731,12 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar'); var pubStore = container.getHierarchyStore().getPublicStore(); var pubSubFolders = []; + var pubFolder; + if(typeof pubStore !== "undefined") { try { - var pubFolder = pubStore.getDefaultFolder("publicfolders"); - var pubSubFolders = pubFolder.getChildren(); + pubFolder = pubStore.getDefaultFolder("publicfolders"); + pubSubFolders = pubFolder.getChildren(); } catch (e) { console.log("Error opening the shared folder..."); console.log(e); @@ -741,7 +745,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { if(calValue != "calendar") { var subFolders = calendarFolder.getChildren(); - var i = 0; + i = 0; /* add public folders if any exist */ for(i = 0; i < pubSubFolders.length; i++) { diff --git a/php/ical/class.icalparser.php b/php/ical/class.icalparser.php index f9e5697..58c4b54 100644 --- a/php/ical/class.icalparser.php +++ b/php/ical/class.icalparser.php @@ -289,6 +289,7 @@ class ICal { private function iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue) { $timezone = false; + $allday = false; if($prop) { $pos = strpos("TZIDtzid", $prop); @@ -311,15 +312,24 @@ class ICal { $pattern .= '([0-9]{0,2})'; // 4: HH $pattern .= '([0-9]{0,2})'; // 5: MM $pattern .= '([0-9]{0,2})/'; // 6: SS - preg_match($pattern, $icalDate, $date); - - - + preg_match($pattern, $icalDate, $date); // Unix timestamp can't represent dates before 1970 if ($date[1] <= 1970) { return false; - } + } + + // check if we have a allday event + if((!$date[6] || $date[6] === "") || (!$date[5] || $date[5] === "") || (!$date[4] || $date[4] === "")) { + $date[6] = 0; + $date[5] = 0; + $date[4] = 0; + $allday = true; + + $dtz = date_default_timezone_get(); + date_default_timezone_set('UTC'); + } + // Unix timestamps after 03:14:07 UTC 2038-01-19 might cause an overflow // if 32 bit integers are used. $timestamp = mktime((int)$date[4], @@ -329,7 +339,11 @@ class ICal { (int)$date[3], (int)$date[1]); - if(!$utc) { + if($allday) { + date_default_timezone_set($dtz); + } + + if(!$utc && !$allday) { $tz = $this->default_timezone; if($timezone != false) { $tz = $timezone; @@ -339,7 +353,7 @@ class ICal { $this_tz = false; try { - $this_tz = new DateTimeZone($tz); + $this_tz = new DateTimeZone($tz); } catch(Exception $e) { error_log($e->getMessage()); $error = true; @@ -363,7 +377,7 @@ class ICal { $timestamp_utc = $timestamp; } - return ($timestamp_utc); + return array($timestamp_utc,$allday); } /** @@ -406,9 +420,11 @@ class ICal { * @return {int} */ public function iCalDateToUnixTimestamp($icalDate, $prop, $propvalue) { - $timestamp = $this->iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue); - - $timestamp = $this->UTCTimestampToTZTimestamp($timestamp, $this->default_timezone, $this->ignore_dst); + list($timestamp, $allday) = $this->iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue); + + if(!$allday) { + $timestamp = $this->UTCTimestampToTZTimestamp($timestamp, $this->default_timezone, $this->ignore_dst, $allday); + } return $timestamp; }