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)
This commit is contained in:
Christoph Haas 2013-03-30 22:10:58 +00:00
parent 55b6e41277
commit b2be7585d5
4 changed files with 95 additions and 8 deletions

View File

@ -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;"

View File

@ -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 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;i<subFolders.length;i++) {
// loo up right folder
// TODO: improve!!
@ -713,11 +724,56 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
var i = 0;
//receive existing calendar store
var calValue = this.calendarselector.value;
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
var pubStore = container.getHierarchyStore().getPublicStore();
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;i<subFolders.length;i++) {
// loo up right folder
// TODO: improve!!
if(subFolders[i].getDisplayName() == calValue) {
calendarFolder = subFolders[i];
break;
}
}
if(calendarFolder.isDefaultFolder()) {
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
msg : _('Selected calendar does not exist!'),
icon : Zarafa.common.dialogs.MessageBox.ERROR,
buttons : Zarafa.common.dialogs.MessageBox.OK
});
}
}
for(i = 0; i < requests; i++) {
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: this.storeResult.createDelegate(this)
});
this.requestNext(responseHandler, response.page.rowcount *(i+1), response.page.rowcount);
this.requestNext(calendarFolder, responseHandler, response.page.rowcount *(i+1), response.page.rowcount);
}
},
@ -754,12 +810,12 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
/**
* build a new event request for the listmodule
* @param {Object} calendarFolder the calendarFolder to export
* @param {Object} responseHandler (should be storeResult)
* @param {int} start
* @param {int} limit
*/
requestNext: function(responseHandler, start, limit) {
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
requestNext: function(calendarFolder, responseHandler, start, limit) {
container.getRequest().singleRequest(
'appointmentlistmodule',

View File

@ -188,8 +188,8 @@ class ICal {
//$keyword = $keyword[0]; // remove additional content like VALUE=DATE
//}
if (stristr($keyword, "TIMEZONE") && !$this->timezone_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);
}
}
@ -415,6 +434,15 @@ class ICal {
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
*

View File

@ -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()
);