calendarimporter 2.0.3:

- fixed all day events
This commit is contained in:
Christoph Haas 2013-06-13 18:49:40 +00:00
parent b2be7585d5
commit 7b4e1c4569
4 changed files with 40 additions and 17 deletions

View File

@ -1,6 +1,6 @@
<project default="all"> <project default="all">
<!--############# CONFIGURE ALL PROPERTIES FOR THE REPLACER HERE ################--> <!--############# CONFIGURE ALL PROPERTIES FOR THE REPLACER HERE ################-->
<property name="plugin_version" value="2.0.2"/> <property name="plugin_version" value="2.0.3"/>
<!-- EOC --> <!-- EOC -->
<property name="root-folder" value="${basedir}/../"/> <property name="root-folder" value="${basedir}/../"/>

View File

@ -1,3 +1,6 @@
calendarimporter 2.0.3:
- fixed all day events
calendarimporter 2.0.2: calendarimporter 2.0.2:
- fixed crash when public store does not exist - fixed crash when public store does not exist
- check if temporary directory is writeable - check if temporary directory is writeable

View File

@ -600,10 +600,12 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar'); var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
var pubStore = container.getHierarchyStore().getPublicStore(); var pubStore = container.getHierarchyStore().getPublicStore();
var pubSubFolders = []; var pubSubFolders = [];
var pubFolder;
if(typeof pubStore !== "undefined") { if(typeof pubStore !== "undefined") {
try { try {
var pubFolder = pubStore.getDefaultFolder("publicfolders"); pubFolder = pubStore.getDefaultFolder("publicfolders");
var pubSubFolders = pubFolder.getChildren(); pubSubFolders = pubFolder.getChildren();
} catch (e) { } catch (e) {
console.log("Error opening the shared folder..."); console.log("Error opening the shared folder...");
console.log(e); console.log(e);
@ -729,10 +731,12 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar'); var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
var pubStore = container.getHierarchyStore().getPublicStore(); var pubStore = container.getHierarchyStore().getPublicStore();
var pubSubFolders = []; var pubSubFolders = [];
var pubFolder;
if(typeof pubStore !== "undefined") { if(typeof pubStore !== "undefined") {
try { try {
var pubFolder = pubStore.getDefaultFolder("publicfolders"); pubFolder = pubStore.getDefaultFolder("publicfolders");
var pubSubFolders = pubFolder.getChildren(); pubSubFolders = pubFolder.getChildren();
} catch (e) { } catch (e) {
console.log("Error opening the shared folder..."); console.log("Error opening the shared folder...");
console.log(e); console.log(e);
@ -741,7 +745,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
if(calValue != "calendar") { if(calValue != "calendar") {
var subFolders = calendarFolder.getChildren(); var subFolders = calendarFolder.getChildren();
var i = 0; i = 0;
/* add public folders if any exist */ /* add public folders if any exist */
for(i = 0; i < pubSubFolders.length; i++) { for(i = 0; i < pubSubFolders.length; i++) {

View File

@ -289,6 +289,7 @@ class ICal {
private function iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue) { private function iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue) {
$timezone = false; $timezone = false;
$allday = false;
if($prop) { if($prop) {
$pos = strpos("TZIDtzid", $prop); $pos = strpos("TZIDtzid", $prop);
@ -311,15 +312,24 @@ class ICal {
$pattern .= '([0-9]{0,2})'; // 4: HH $pattern .= '([0-9]{0,2})'; // 4: HH
$pattern .= '([0-9]{0,2})'; // 5: MM $pattern .= '([0-9]{0,2})'; // 5: MM
$pattern .= '([0-9]{0,2})/'; // 6: SS $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 // Unix timestamp can't represent dates before 1970
if ($date[1] <= 1970) { if ($date[1] <= 1970) {
return false; 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 // Unix timestamps after 03:14:07 UTC 2038-01-19 might cause an overflow
// if 32 bit integers are used. // if 32 bit integers are used.
$timestamp = mktime((int)$date[4], $timestamp = mktime((int)$date[4],
@ -329,7 +339,11 @@ class ICal {
(int)$date[3], (int)$date[3],
(int)$date[1]); (int)$date[1]);
if(!$utc) { if($allday) {
date_default_timezone_set($dtz);
}
if(!$utc && !$allday) {
$tz = $this->default_timezone; $tz = $this->default_timezone;
if($timezone != false) { if($timezone != false) {
$tz = $timezone; $tz = $timezone;
@ -339,7 +353,7 @@ class ICal {
$this_tz = false; $this_tz = false;
try { try {
$this_tz = new DateTimeZone($tz); $this_tz = new DateTimeZone($tz);
} catch(Exception $e) { } catch(Exception $e) {
error_log($e->getMessage()); error_log($e->getMessage());
$error = true; $error = true;
@ -363,7 +377,7 @@ class ICal {
$timestamp_utc = $timestamp; $timestamp_utc = $timestamp;
} }
return ($timestamp_utc); return array($timestamp_utc,$allday);
} }
/** /**
@ -406,9 +420,11 @@ class ICal {
* @return {int} * @return {int}
*/ */
public function iCalDateToUnixTimestamp($icalDate, $prop, $propvalue) { public function iCalDateToUnixTimestamp($icalDate, $prop, $propvalue) {
$timestamp = $this->iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue); list($timestamp, $allday) = $this->iCalDateToUTCUnixTimestamp($icalDate, $prop, $propvalue);
$timestamp = $this->UTCTimestampToTZTimestamp($timestamp, $this->default_timezone, $this->ignore_dst); if(!$allday) {
$timestamp = $this->UTCTimestampToTZTimestamp($timestamp, $this->default_timezone, $this->ignore_dst, $allday);
}
return $timestamp; return $timestamp;
} }