diff --git a/changelog.txt b/changelog.txt index d91086f..389d0a0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,8 @@ calendarimporter 2.0.2: - fixed crash when public store does not exist - check if temporary directory is writeable - disabled display_error with ini_set + - fixed exporter: now really exporting the chosen calendar + - improved parser (timezone detection) calendarimporter 2.0.1: - removed debug line "utc = true;" diff --git a/js/dialogs/ImportPanel.js b/js/dialogs/ImportPanel.js index 10cf38f..a0653cf 100644 --- a/js/dialogs/ImportPanel.js +++ b/js/dialogs/ImportPanel.js @@ -505,7 +505,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { if(typeof response.parsed.calendar["X-WR-TIMEZONE"] !== "undefined") {; this.timezone = response.parsed.calendar["X-WR-TIMEZONE"]; this.timezoneselector.setValue(Zarafa.plugins.calendarimporter.data.Timezones.unMap(this.timezone)); - } + } this.reloadGridStore(response.parsed); } else { Ext.getCmp('submitButton').disable(); @@ -599,17 +599,28 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { var calexist = true; var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar'); var pubStore = container.getHierarchyStore().getPublicStore(); - var pubFolder = pubStore.getDefaultFolder("publicfolders"); - var pubSubFolders = pubFolder.getChildren(); + var pubSubFolders = []; + if(typeof pubStore !== "undefined") { + try { + var pubFolder = pubStore.getDefaultFolder("publicfolders"); + var pubSubFolders = pubFolder.getChildren(); + } catch (e) { + console.log("Error opening the shared folder..."); + console.log(e); + } + } if(calValue != "calendar") { var subFolders = calendarFolder.getChildren(); var i = 0; + + /* add public folders if any exist */ for(i = 0; i < pubSubFolders.length; i++) { if(pubSubFolders[i].isContainerClass("IPF.Appointment")){ subFolders.push(pubSubFolders[i]); } } + for(i=0;itimezone_set) { // check if timezone already set... - $this->default_timezone = $value; // store the calendertimezone + if ((stristr($keyword, "TIMEZONE") || stristr($keyword, "TZID")) && !$this->timezone_set) { // check if timezone already set... + $this->default_timezone = $this->trimTimeZone($value); // store the calendertimezone } switch ($component) { @@ -238,6 +238,24 @@ class ICal { return $value; } + /** + * Trim a Timezone String + * + * @param {string} $timezone timezone string which should be trimmed + * @return {string} trimmed value + */ + private function trimTimeZone($timezone) { + if(preg_match('~([?<=/]*)([^/]*[/|-][^/]*$)~', $timezone, $matches)) { // detects tzurls in tzids + if ($matches[2] != "") { + return $matches[2]; // 2 = extracted timezone + } else { + return $timezone; + } + } + + return $timezone; + } + /** * Get a key-value pair of a string. * @@ -277,6 +295,7 @@ class ICal { if($pos !== false && $propvalue != false) { $timezone = str_replace('"', '', $propvalue); $timezone = str_replace('\'', '', $timezone); + $timezone = $this->trimTimeZone($timezone); } } @@ -414,6 +433,15 @@ class ICal { $array = $this->cal; return $array['VCALENDAR']; } + + /** + * Returns the default or set timezone + * + * @return {string} + */ + public function timezone() { + return $this->default_timezone; + } /** * Returns a boolean value whether thr current calendar has events or not diff --git a/php/module.calendar.php b/php/module.calendar.php index 6bc1ba5..0f65770 100644 --- a/php/module.calendar.php +++ b/php/module.calendar.php @@ -413,6 +413,7 @@ class CalendarModule extends Module { $response['status'] = true; $response['parsed_file']= $actionData["ics_filepath"]; $response['parsed'] = array ( + 'timezone' => $ical->timezone(), 'calendar' => $ical->calendar(), 'events' => $ical->events() );