From 275913dea8983feb23ccfd119939a53aea405b6a Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Fri, 16 Dec 2016 14:51:48 +0100 Subject: [PATCH] Line endings --- backend/README.txt | 26 +- backend/config.php | 9 +- backend/functions.php | 328 ++-- backend/sync.php | 298 ++-- changelog.txt | 126 +- js/ABOUT.js | 130 +- js/data/ResponseHandler.js | 168 +- js/data/timezones.js | 1532 ++++++++-------- js/dialogs/ImportContentPanel.js | 130 +- js/external/Ext.util.base64.js | 92 +- js/plugin.calendarimporter.js | 612 +++---- js/settings/SettingsCalSyncWidget.js | 270 +-- js/settings/SettingsWidget.js | 460 ++--- .../dialogs/CalSyncEditContentPanel.js | 120 +- js/settings/dialogs/CalSyncEditPanel.js | 446 ++--- js/settings/ui/CalSyncGrid.js | 360 ++-- js/settings/ui/CalSyncPanel.js | 344 ++-- manifest.xml | 104 +- php/download.php | 148 +- php/module.calendar.php | 1540 ++++++++--------- resources/css/calendarimporter-main.css | 60 +- 21 files changed, 3655 insertions(+), 3648 deletions(-) diff --git a/backend/README.txt b/backend/README.txt index e004f5b..db6c01b 100644 --- a/backend/README.txt +++ b/backend/README.txt @@ -1,14 +1,14 @@ -Backend setup: - -1. Create a Admin User in Zarafa: -zarafa-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1 - -2. Edit the config.php to fit your needs. - -3. Setup cron to run your script every 10 minutes (or whatever...) - -4. If you get an error, make sure that the mapi module is loaded for php-cli: - * Add: /etc/php5/cli/conf.d/50-mapi.ini - * Content: extension=mapi.so - +Backend setup: + +1. Create a Admin User in Zarafa: +zarafa-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1 + +2. Edit the config.php to fit your needs. + +3. Setup cron to run your script every 10 minutes (or whatever...) + +4. If you get an error, make sure that the mapi module is loaded for php-cli: + * Add: /etc/php5/cli/conf.d/50-mapi.ini + * Content: extension=mapi.so + Never run the backend script as root! \ No newline at end of file diff --git a/backend/config.php b/backend/config.php index 093b626..4a456a5 100644 --- a/backend/config.php +++ b/backend/config.php @@ -1 +1,8 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/backend/functions.php b/backend/functions.php index b4df684..248c6e8 100644 --- a/backend/functions.php +++ b/backend/functions.php @@ -1,165 +1,165 @@ - - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/* gets the data from a URL */ -function curl_get_data($url, $username = NULL, $password = NULL) { - $ch = curl_init(); - $timeout = 5; - - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); - - if($username != NULL && $password != NULL) { - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); - } - - $data = curl_exec($ch); - $http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE)); - curl_close($ch); - - if($http_status > 210 || $http_status < 200) - return NULL; - return $data; -} - -/* gets all zarafa users */ -function get_user_ics_list($userStore) { - // get settings - // first check if property exist and we can open that using mapi_openproperty - $storeProps = mapi_getprops($userStore, array(PR_EC_WEBACCESS_SETTINGS_JSON)); - - // Check if property exists, if it doesn not exist then we can continue with empty set of settings - if (isset($storeProps[PR_EC_WEBACCESS_SETTINGS_JSON]) || propIsError(PR_EC_WEBACCESS_SETTINGS_JSON, $storeProps) == MAPI_E_NOT_ENOUGH_MEMORY) { - // read the settings property - $stream = mapi_openproperty($userStore, PR_EC_WEBACCESS_SETTINGS_JSON, IID_IStream, 0, 0); - if ($stream == false) { - echo "Error opening settings property\n"; - } - - $settings_string = ""; - $stat = mapi_stream_stat($stream); - mapi_stream_seek($stream, 0, STREAM_SEEK_SET); - for ($i = 0; $i < $stat['cb']; $i += 1024) { - $settings_string .= mapi_stream_read($stream, 1024); - } - - if(empty($settings_string)) { - // property exists but without any content so ignore it and continue with - // empty set of settings - return; - } - - $settings = json_decode($settings_string, true); - if (empty($settings) || empty($settings['settings'])) { - echo "Error retrieving existing settings\n"; - } - - $calcontext = $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]; - if(isset($calcontext["icssync"])) { - foreach($calcontext["icssync"] as $syncitem) { - echo "Found sync url: " . $syncitem["icsurl"] . " for calendar: " . $syncitem["calendar"] . "\n"; - } - - return $calcontext["icssync"]; - } - - return NULL; - } -} - -/* updates the webapp settings */ -function update_last_sync_date($userStore, $icsentry) { - // get settings - // first check if property exist and we can open that using mapi_openproperty - $storeProps = mapi_getprops($userStore, array(PR_EC_WEBACCESS_SETTINGS_JSON)); - - // Check if property exists, if it doesn not exist then we can continue with empty set of settings - if (isset($storeProps[PR_EC_WEBACCESS_SETTINGS_JSON]) || propIsError(PR_EC_WEBACCESS_SETTINGS_JSON, $storeProps) == MAPI_E_NOT_ENOUGH_MEMORY) { - // read the settings property - $stream = mapi_openpropertytostream($userStore, PR_EC_WEBACCESS_SETTINGS_JSON, MAPI_MODIFY); - if ($stream == false) { - echo "Error opening settings property\n"; - } - - $settings_string = ""; - $stat = mapi_stream_stat($stream); - mapi_stream_seek($stream, 0, STREAM_SEEK_SET); - for ($i = 0; $i < $stat['cb']; $i += 1024) { - $settings_string .= mapi_stream_read($stream, 1024); - } - - if(empty($settings_string)) { - // property exists but without any content so ignore it and continue with - // empty set of settings - return; - } - - $settings = json_decode($settings_string, true); - if (empty($settings) || empty($settings['settings'])) { - echo "Error retrieving existing settings\n"; - } - - $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]["icssync"][$icsentry]["lastsync"] = date('Y-m-d H:i:s'); - - $newsettings = json_encode($settings); - mapi_stream_setsize($stream, strlen($newsettings)); - mapi_stream_seek($stream, 0, STREAM_SEEK_SET); - mapi_stream_write($stream, $newsettings); - $res = mapi_stream_commit ($stream); - return $res; - } - - return false; -} - -/* upload a file */ -function upload_ics_to_caldav($filename, $caldavurl, $username, $calendarname, $authuser = NULL, $authpass = NULL) { - $url = $caldavurl . $username . "/" . rawurlencode($calendarname) . "/"; - $post = array('file'=>'@'.$filename); - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL,$url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - $fp = fopen($filename, 'r'); - curl_setopt($ch, CURLOPT_PUT, true); - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); - curl_setopt($ch, CURLOPT_INFILE, $fp); - curl_setopt($ch, CURLOPT_INFILESIZE, filesize ($filename)); - - if($authuser != NULL && $authpass != NULL) { - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, "$authuser:$authpass"); - } - - $result=curl_exec($ch); - $http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE)); - curl_close($ch); - - echo "uploading file to: " . $url . " (" . $http_status . ")\n"; - - return $http_status; -} + + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* gets the data from a URL */ +function curl_get_data($url, $username = NULL, $password = NULL) { + $ch = curl_init(); + $timeout = 5; + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); + + if($username != NULL && $password != NULL) { + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); + } + + $data = curl_exec($ch); + $http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE)); + curl_close($ch); + + if($http_status > 210 || $http_status < 200) + return NULL; + return $data; +} + +/* gets all zarafa users */ +function get_user_ics_list($userStore) { + // get settings + // first check if property exist and we can open that using mapi_openproperty + $storeProps = mapi_getprops($userStore, array(PR_EC_WEBACCESS_SETTINGS_JSON)); + + // Check if property exists, if it doesn not exist then we can continue with empty set of settings + if (isset($storeProps[PR_EC_WEBACCESS_SETTINGS_JSON]) || propIsError(PR_EC_WEBACCESS_SETTINGS_JSON, $storeProps) == MAPI_E_NOT_ENOUGH_MEMORY) { + // read the settings property + $stream = mapi_openproperty($userStore, PR_EC_WEBACCESS_SETTINGS_JSON, IID_IStream, 0, 0); + if ($stream == false) { + echo "Error opening settings property\n"; + } + + $settings_string = ""; + $stat = mapi_stream_stat($stream); + mapi_stream_seek($stream, 0, STREAM_SEEK_SET); + for ($i = 0; $i < $stat['cb']; $i += 1024) { + $settings_string .= mapi_stream_read($stream, 1024); + } + + if(empty($settings_string)) { + // property exists but without any content so ignore it and continue with + // empty set of settings + return; + } + + $settings = json_decode($settings_string, true); + if (empty($settings) || empty($settings['settings'])) { + echo "Error retrieving existing settings\n"; + } + + $calcontext = $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]; + if(isset($calcontext["icssync"])) { + foreach($calcontext["icssync"] as $syncitem) { + echo "Found sync url: " . $syncitem["icsurl"] . " for calendar: " . $syncitem["calendar"] . "\n"; + } + + return $calcontext["icssync"]; + } + + return NULL; + } +} + +/* updates the webapp settings */ +function update_last_sync_date($userStore, $icsentry) { + // get settings + // first check if property exist and we can open that using mapi_openproperty + $storeProps = mapi_getprops($userStore, array(PR_EC_WEBACCESS_SETTINGS_JSON)); + + // Check if property exists, if it doesn not exist then we can continue with empty set of settings + if (isset($storeProps[PR_EC_WEBACCESS_SETTINGS_JSON]) || propIsError(PR_EC_WEBACCESS_SETTINGS_JSON, $storeProps) == MAPI_E_NOT_ENOUGH_MEMORY) { + // read the settings property + $stream = mapi_openpropertytostream($userStore, PR_EC_WEBACCESS_SETTINGS_JSON, MAPI_MODIFY); + if ($stream == false) { + echo "Error opening settings property\n"; + } + + $settings_string = ""; + $stat = mapi_stream_stat($stream); + mapi_stream_seek($stream, 0, STREAM_SEEK_SET); + for ($i = 0; $i < $stat['cb']; $i += 1024) { + $settings_string .= mapi_stream_read($stream, 1024); + } + + if(empty($settings_string)) { + // property exists but without any content so ignore it and continue with + // empty set of settings + return; + } + + $settings = json_decode($settings_string, true); + if (empty($settings) || empty($settings['settings'])) { + echo "Error retrieving existing settings\n"; + } + + $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]["icssync"][$icsentry]["lastsync"] = date('Y-m-d H:i:s'); + + $newsettings = json_encode($settings); + mapi_stream_setsize($stream, strlen($newsettings)); + mapi_stream_seek($stream, 0, STREAM_SEEK_SET); + mapi_stream_write($stream, $newsettings); + $res = mapi_stream_commit ($stream); + return $res; + } + + return false; +} + +/* upload a file */ +function upload_ics_to_caldav($filename, $caldavurl, $username, $calendarname, $authuser = NULL, $authpass = NULL) { + $url = $caldavurl . $username . "/" . rawurlencode($calendarname) . "/"; + $post = array('file'=>'@'.$filename); + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $fp = fopen($filename, 'r'); + curl_setopt($ch, CURLOPT_PUT, true); + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); + curl_setopt($ch, CURLOPT_INFILE, $fp); + curl_setopt($ch, CURLOPT_INFILESIZE, filesize ($filename)); + + if($authuser != NULL && $authpass != NULL) { + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($ch, CURLOPT_USERPWD, "$authuser:$authpass"); + } + + $result=curl_exec($ch); + $http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE)); + curl_close($ch); + + echo "uploading file to: " . $url . " (" . $http_status . ")\n"; + + return $http_status; +} ?> \ No newline at end of file diff --git a/backend/sync.php b/backend/sync.php index 90e2322..ab63b2b 100644 --- a/backend/sync.php +++ b/backend/sync.php @@ -1,150 +1,150 @@ -#!/usr/bin/php - - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -if(php_sapi_name() !== 'cli') { - die("Script must be run from commandline!"); -} - -/** - * Make sure that the zarafa mapi extension is enabled in cli mode: - * Add: /etc/php5/cli/conf.d/50-mapi.ini - * Content: extension=mapi.so - */ - -// MAPI includes -include('/usr/share/php/mapi/mapi.util.php'); -include('/usr/share/php/mapi/mapidefs.php'); -include('/usr/share/php/mapi/mapicode.php'); -include('/usr/share/php/mapi/mapitags.php'); -include('/usr/share/php/mapi/mapiguid.php'); -include('config.php'); -include('functions.php'); - -// log in to zarafa -$session = mapi_logon_zarafa($ADMINUSERNAME, $ADMINPASSWORD, $SERVER); -if($session === FALSE) { - exit("Logon failed with error " .mapi_last_hresult() . "\n"); -} - -// load all stores for the admin user -$storeTable = mapi_getmsgstorestable($session); -if($storeTable === FALSE) { - exit("Storetable could not be opened. Error " .mapi_last_hresult() . "\n"); -} -$storesList = mapi_table_queryallrows($storeTable, array(PR_ENTRYID, PR_DEFAULT_STORE)); - -// get admin users default store -foreach ($storesList as $row) { - if($row[PR_DEFAULT_STORE]) { - $storeEntryid = $row[PR_ENTRYID]; - } -} -if(!$storeEntryid) { - exit("Can't find default store\n"); -} - -// open default store -$store = mapi_openmsgstore($session, $storeEntryid); -if(!$store) { - exit("Unable to open system store\n"); -} - -// get a userlist -$userList = array(); -// for multi company setup -$companyList = mapi_zarafa_getcompanylist($store); -if(mapi_last_hresult() == NOERROR && is_array($companyList)) { - // multi company setup, get all users from all companies - foreach($companyList as $companyName => $companyData) { - $userList = array_merge($userList, mapi_zarafa_getuserlist($store, $companyData["companyid"])); - } -} else { - // single company setup, get list of all zarafa users - $userList = mapi_zarafa_getuserlist($store); -} -if(count($userList) <= 0) { - exit("Unable to get user list\n"); -} - -// loop over all users -foreach($userList as $userName => $userData) { - // check for valid users - if($userName == "SYSTEM" ||$userName == $ADMINUSERNAME) { - continue; - } - - echo "###Getting sync settings for user: " . $userName . "\n"; - - $userEntryId = mapi_msgstore_createentryid($store, $userName); - $userStore = mapi_openmsgstore($session, $userEntryId); - if(!$userStore) { - echo "Can't open user store\n"; - continue; - } - - $syncItems = get_user_ics_list($userStore); - - if($syncItems != NULL && count($syncItems) > 0) { - foreach($syncItems as $syncItemName => $syncItem) { - //check update intervall - $lastUpdate = strtotime($syncItem["lastsync"]); - $updateIntervall = intval($syncItem["intervall"]) * 60; // we need seconds - $currenttime = time(); - - if(($lastUpdate + $updateIntervall) <= $currenttime) { - echo "Update intervall OK ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n"; - - $tmpFilename = $TEMPDIR . uniqid($userName . $syncItem["calendar"], true) . ".ics"; - - $user = NULL; - $pass= NULL; - - if($syncItem["user"] != NULL && !empty($syncItem["user"])) - $user = $syncItem["user"]; - if($syncItem["pass"] != NULL && !empty($syncItem["pass"])) - $pass= base64_decode($syncItem["pass"]); - - $icsData = curl_get_data($syncItem["icsurl"], $user, $pass); - - if($icsData != NULL) { - file_put_contents($tmpFilename, $icsData); - echo "Got valid data for " . $syncItem["icsurl"] . " stored in " . $tmpFilename . "\n"; - $result = upload_ics_to_caldav($tmpFilename, $CALDAVURL, $userName, $syncItem["calendarname"], $ADMINUSERNAME, $ADMINPASSWORD); - if(intval($result) == 200) { - echo "Import completed: $result\n"; - $result = update_last_sync_date($userStore, $syncItemName); - $res = $result ? "true":"false"; - echo "Updated Zarafa settings: " . $res . "\n"; - } else { - echo "Uploading failed: " . $result . "\n"; - } - } - } else { - echo "Update intervall STOP ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n"; - } - } - } - - echo "###Done sync for user: " . $userName . "\n\n"; -} +#!/usr/bin/php + + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +if(php_sapi_name() !== 'cli') { + die("Script must be run from commandline!"); +} + +/** + * Make sure that the zarafa mapi extension is enabled in cli mode: + * Add: /etc/php5/cli/conf.d/50-mapi.ini + * Content: extension=mapi.so + */ + +// MAPI includes +include('/usr/share/php/mapi/mapi.util.php'); +include('/usr/share/php/mapi/mapidefs.php'); +include('/usr/share/php/mapi/mapicode.php'); +include('/usr/share/php/mapi/mapitags.php'); +include('/usr/share/php/mapi/mapiguid.php'); +include('config.php'); +include('functions.php'); + +// log in to zarafa +$session = mapi_logon_zarafa($ADMINUSERNAME, $ADMINPASSWORD, $SERVER); +if($session === FALSE) { + exit("Logon failed with error " .mapi_last_hresult() . "\n"); +} + +// load all stores for the admin user +$storeTable = mapi_getmsgstorestable($session); +if($storeTable === FALSE) { + exit("Storetable could not be opened. Error " .mapi_last_hresult() . "\n"); +} +$storesList = mapi_table_queryallrows($storeTable, array(PR_ENTRYID, PR_DEFAULT_STORE)); + +// get admin users default store +foreach ($storesList as $row) { + if($row[PR_DEFAULT_STORE]) { + $storeEntryid = $row[PR_ENTRYID]; + } +} +if(!$storeEntryid) { + exit("Can't find default store\n"); +} + +// open default store +$store = mapi_openmsgstore($session, $storeEntryid); +if(!$store) { + exit("Unable to open system store\n"); +} + +// get a userlist +$userList = array(); +// for multi company setup +$companyList = mapi_zarafa_getcompanylist($store); +if(mapi_last_hresult() == NOERROR && is_array($companyList)) { + // multi company setup, get all users from all companies + foreach($companyList as $companyName => $companyData) { + $userList = array_merge($userList, mapi_zarafa_getuserlist($store, $companyData["companyid"])); + } +} else { + // single company setup, get list of all zarafa users + $userList = mapi_zarafa_getuserlist($store); +} +if(count($userList) <= 0) { + exit("Unable to get user list\n"); +} + +// loop over all users +foreach($userList as $userName => $userData) { + // check for valid users + if($userName == "SYSTEM" ||$userName == $ADMINUSERNAME) { + continue; + } + + echo "###Getting sync settings for user: " . $userName . "\n"; + + $userEntryId = mapi_msgstore_createentryid($store, $userName); + $userStore = mapi_openmsgstore($session, $userEntryId); + if(!$userStore) { + echo "Can't open user store\n"; + continue; + } + + $syncItems = get_user_ics_list($userStore); + + if($syncItems != NULL && count($syncItems) > 0) { + foreach($syncItems as $syncItemName => $syncItem) { + //check update intervall + $lastUpdate = strtotime($syncItem["lastsync"]); + $updateIntervall = intval($syncItem["intervall"]) * 60; // we need seconds + $currenttime = time(); + + if(($lastUpdate + $updateIntervall) <= $currenttime) { + echo "Update intervall OK ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n"; + + $tmpFilename = $TEMPDIR . uniqid($userName . $syncItem["calendar"], true) . ".ics"; + + $user = NULL; + $pass= NULL; + + if($syncItem["user"] != NULL && !empty($syncItem["user"])) + $user = $syncItem["user"]; + if($syncItem["pass"] != NULL && !empty($syncItem["pass"])) + $pass= base64_decode($syncItem["pass"]); + + $icsData = curl_get_data($syncItem["icsurl"], $user, $pass); + + if($icsData != NULL) { + file_put_contents($tmpFilename, $icsData); + echo "Got valid data for " . $syncItem["icsurl"] . " stored in " . $tmpFilename . "\n"; + $result = upload_ics_to_caldav($tmpFilename, $CALDAVURL, $userName, $syncItem["calendarname"], $ADMINUSERNAME, $ADMINPASSWORD); + if(intval($result) == 200) { + echo "Import completed: $result\n"; + $result = update_last_sync_date($userStore, $syncItemName); + $res = $result ? "true":"false"; + echo "Updated Zarafa settings: " . $res . "\n"; + } else { + echo "Uploading failed: " . $result . "\n"; + } + } + } else { + echo "Update intervall STOP ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n"; + } + } + } + + echo "###Done sync for user: " . $userName . "\n\n"; +} ?> \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index 92fe510..43928a2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,64 +1,64 @@ -calendarimporter 2.2.1: - - finally supporting Kopano Webapp 3.1.x - - translation to german added - -calendarimporter 2.2.0: - - support for Kopano Webapp 3.1.1 - - Code rework - - Calendar export improved - - Calendar import improved - - GUI improvements - -calendarimporter 2.1.0: - - ics sync is now implemented - -calendarimporter 2.0.5: - - added settings widget - - compatible with webapp 1.5 and 1.6 - -calendarimporter 2.0.4: - - added compatible with webapp 1.4 - - added gui for sync - sync algorithms not jet implemented - -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 - - 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;" - - Fixed problems with colons in value fields (improved regex) - - minor fixes/improvements - -calendarimporter 2.0: - - updated iCalcreator to 2.16.12 - - fixed exporter problem: now you can export more than 50 events - - fixed button visibility for attachment importing - - minor fixes/improvements - -calendarimporter 2.0b: - - Completely rewritten timezone management - - Import of iCal attachments possible - - webapp 1.3 about page added - - bugfixes - -calendarimporter 1.2: - - New timezone management - - more imported fields (Busystatus, importance, label, class, organizer, reminder) - - smaller improvements - - deploy/build script - - support for shared/public folders - -calendarimporter 1.1 final: - - ics exporter - - improved ics fileparser - - fixed ExtJS Problem in chrome - -KNOWN PROBLEMS: - - attachments in events are ignored +calendarimporter 2.2.1: + - finally supporting Kopano Webapp 3.1.x + - translation to german added + +calendarimporter 2.2.0: + - support for Kopano Webapp 3.1.1 + - Code rework + - Calendar export improved + - Calendar import improved + - GUI improvements + +calendarimporter 2.1.0: + - ics sync is now implemented + +calendarimporter 2.0.5: + - added settings widget + - compatible with webapp 1.5 and 1.6 + +calendarimporter 2.0.4: + - added compatible with webapp 1.4 + - added gui for sync - sync algorithms not jet implemented + +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 + - 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;" + - Fixed problems with colons in value fields (improved regex) + - minor fixes/improvements + +calendarimporter 2.0: + - updated iCalcreator to 2.16.12 + - fixed exporter problem: now you can export more than 50 events + - fixed button visibility for attachment importing + - minor fixes/improvements + +calendarimporter 2.0b: + - Completely rewritten timezone management + - Import of iCal attachments possible + - webapp 1.3 about page added + - bugfixes + +calendarimporter 1.2: + - New timezone management + - more imported fields (Busystatus, importance, label, class, organizer, reminder) + - smaller improvements + - deploy/build script + - support for shared/public folders + +calendarimporter 1.1 final: + - ics exporter + - improved ics fileparser + - fixed ExtJS Problem in chrome + +KNOWN PROBLEMS: + - attachments in events are ignored - recurrent events are not handled properly (im/export) \ No newline at end of file diff --git a/js/ABOUT.js b/js/ABOUT.js index b422e4d..0dcce4c 100644 --- a/js/ABOUT.js +++ b/js/ABOUT.js @@ -1,66 +1,66 @@ -/** - * ABOUT.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace('Zarafa.plugins.calendarimporter'); - -/** - * @class Zarafa.plugins.calendarimporter.ABOUT - * @extends String - * - * The copyright string holding the copyright notice for the Zarafa calendarimporter Plugin. - */ -Zarafa.plugins.calendarimporter.ABOUT = "" - + "

Copyright (C) 2012-2016 Christoph Haas <christoph.h@sprinternet.at>

" - - + "

This program is free software; you can redistribute it and/or " - + "modify it under the terms of the GNU Lesser General Public " - + "License as published by the Free Software Foundation; either " - + "version 2.1 of the License, or (at your option) any later version.

" - - + "

This program is distributed in the hope that it will be useful, " - + "but WITHOUT ANY WARRANTY; without even the implied warranty of " - + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU " - + "Lesser General Public License for more details.

" - - + "

You should have received a copy of the GNU Lesser General Public " - + "License along with this program; if not, write to the Free Software " - + "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

" - - + "
" - - + "

The calendarimporter plugin contains the following third-party components:

" - - + "

iCalcreator v2.16.12

" - - + "

Copyright 2007-2013 Kjell-Inge Gustafsson kigkonsult

" - - + "

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

" - - + "

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

" - - + "

Ics-parser

" - - + "

Copyright 2002-2007 Martin Thoma <info@martin-thoma.de>

" - - + "

Licensed under the MIT License.

" - +/** + * ABOUT.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace('Zarafa.plugins.calendarimporter'); + +/** + * @class Zarafa.plugins.calendarimporter.ABOUT + * @extends String + * + * The copyright string holding the copyright notice for the Zarafa calendarimporter Plugin. + */ +Zarafa.plugins.calendarimporter.ABOUT = "" + + "

Copyright (C) 2012-2016 Christoph Haas <christoph.h@sprinternet.at>

" + + + "

This program is free software; you can redistribute it and/or " + + "modify it under the terms of the GNU Lesser General Public " + + "License as published by the Free Software Foundation; either " + + "version 2.1 of the License, or (at your option) any later version.

" + + + "

This program is distributed in the hope that it will be useful, " + + "but WITHOUT ANY WARRANTY; without even the implied warranty of " + + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU " + + "Lesser General Public License for more details.

" + + + "

You should have received a copy of the GNU Lesser General Public " + + "License along with this program; if not, write to the Free Software " + + "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

" + + + "
" + + + "

The calendarimporter plugin contains the following third-party components:

" + + + "

iCalcreator v2.16.12

" + + + "

Copyright 2007-2013 Kjell-Inge Gustafsson kigkonsult

" + + + "

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

" + + + "

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

" + + + "

Ics-parser

" + + + "

Copyright 2002-2007 Martin Thoma <info@martin-thoma.de>

" + + + "

Licensed under the MIT License.

" + + "

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

"; \ No newline at end of file diff --git a/js/data/ResponseHandler.js b/js/data/ResponseHandler.js index 54365a4..c17129f 100644 --- a/js/data/ResponseHandler.js +++ b/js/data/ResponseHandler.js @@ -1,85 +1,85 @@ -/** - * ResponseHandler.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/** - * ResponseHandler - * - * This class handles all responses from the php backend - */ -Ext.namespace('Zarafa.plugins.calendarimporter.data'); - -/** - * @class Zarafa.plugins.calendarimporter.data.ResponseHandler - * @extends Zarafa.plugins.calendarimporter.data.AbstractResponseHandler - * - * Calendar specific response handler. - */ -Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, { - /** - * @cfg {Function} successCallback The function which - * will be called after success request. - */ - successCallback: null, - - /** - * Call the successCallback callback function. - * @param {Object} response Object contained the response data. - */ - doExport: function (response) { - this.successCallback(response); - }, - - /** - * Call the successCallback callback function. - * @param {Object} response Object contained the response data. - */ - doLoad: function (response) { - this.successCallback(response); - }, - - /** - * Call the successCallback callback function. - * @param {Object} response Object contained the response data. - */ - doImport: function (response) { - this.successCallback(response); - }, - - /** - * Call the successCallback callback function. - * @param {Object} response Object contained the response data. - */ - doImportattachment: function (response) { - this.successCallback(response); - }, - - /** - * In case exception happened on server, server will return - * exception response with the code of exception. - * @param {Object} response Object contained the response data. - */ - doError: function (response) { - alert("error response code: " + response.error.info.code); - } -}); - +/** + * ResponseHandler.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/** + * ResponseHandler + * + * This class handles all responses from the php backend + */ +Ext.namespace('Zarafa.plugins.calendarimporter.data'); + +/** + * @class Zarafa.plugins.calendarimporter.data.ResponseHandler + * @extends Zarafa.plugins.calendarimporter.data.AbstractResponseHandler + * + * Calendar specific response handler. + */ +Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, { + /** + * @cfg {Function} successCallback The function which + * will be called after success request. + */ + successCallback: null, + + /** + * Call the successCallback callback function. + * @param {Object} response Object contained the response data. + */ + doExport: function (response) { + this.successCallback(response); + }, + + /** + * Call the successCallback callback function. + * @param {Object} response Object contained the response data. + */ + doLoad: function (response) { + this.successCallback(response); + }, + + /** + * Call the successCallback callback function. + * @param {Object} response Object contained the response data. + */ + doImport: function (response) { + this.successCallback(response); + }, + + /** + * Call the successCallback callback function. + * @param {Object} response Object contained the response data. + */ + doImportattachment: function (response) { + this.successCallback(response); + }, + + /** + * In case exception happened on server, server will return + * exception response with the code of exception. + * @param {Object} response Object contained the response data. + */ + doError: function (response) { + alert("error response code: " + response.error.info.code); + } +}); + Ext.reg('calendarimporter.calendarresponsehandler', Zarafa.plugins.calendarimporter.data.ResponseHandler); \ No newline at end of file diff --git a/js/data/timezones.js b/js/data/timezones.js index d4d869d..15b3601 100644 --- a/js/data/timezones.js +++ b/js/data/timezones.js @@ -1,767 +1,767 @@ -/** - * timezones.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/** - * Timezone class - * - * This class can handle all our timezone operations and conversions. - */ -Ext.namespace("Zarafa.plugins.calendarimporter.data"); - -Zarafa.plugins.calendarimporter.data.Timezones = Ext.extend(Object, { - - store: [ - ['Pacific/Midway', '(UTC -11:00) Midway, Niue, Pago Pago', -660], - ['Pacific/Fakaofo', '(UTC -10:00) Adak, Fakaofo, Honolulu, Johnston, Rarotonga, Tahiti', -600], - ['Pacific/Marquesas', '(UTC -09:30) Marquesas', -570], - ['America/Anchorage', '(UTC -09:00) Gambier, Anchorage, Juneau, Nome, Sitka, Yakutat', -540], - ['America/Dawson', '(UTC -08:00) Dawson, Los Angeles, Tijuana, Vancouver, Whitehorse, Santa Isabel, Metlakatla, Pitcairn', -480], - ['America/Dawson_Creek', '(UTC -07:00) Dawson Creek, Hermosillo, Phoenix, Chihuahua, Mazatlan, Boise, Cambridge Bay, Denver, Edmonton, Inuvik, Ojinaga, Shiprock, Yellowknife', -420], - ['America/Chicago', '(UTC -06:00) Beulah, Center, Chicago, Knox, Matamoros, Menominee, New Salem, Rainy River, Rankin Inlet, Resolute, Tell City, Winnipeg', -360], - ['America/Belize', '(UTC -06:00) Belize, Costa Rica, El Salvador, Galapagos, Guatemala, Managua, Regina, Swift Current, Tegucigalpa', -360], - ['Pacific/Easter', '(UTC -06:00) Easter', -360], - ['America/Bahia_Banderas', '(UTC -06:00) Bahia Banderas, Cancun, Merida, Mexico City, Monterrey', -360], - ['America/Detroit', '(UTC -05:00) Detroit, Grand Turk, Indianapolis, Iqaluit, Louisville, Marengo, Monticello, Montreal, Nassau, New York, Nipigon, Pangnirtung, Petersburg, Thunder Bay, Toronto, Vevay, Vincennes, Winamac', -300], - ['America/Atikokan', '(UTC -05:00) Atikokan, Bogota, Cayman, Guayaquil, Jamaica, Lima, Panama, Port-au-Prince', -300], - ['America/Havana', '(UTC -05:00) Havana', -300], - ['America/Caracas', '(UTC -04:30) Caracas', -270], - ['America/Glace_Bay', '(UTC -04:00) Bermuda, Glace Bay, Goose Bay, Halifax, Moncton, Thule', -240], - ['Atlantic/Stanley', '(UTC -04:00) Stanley', -240], - ['America/Santiago', '(UTC -04:00) Palmer, Santiago', -240], - ['America/Anguilla', '(UTC -04:00) Anguilla, Antigua, Aruba, Barbados, Blanc-Sablon, Boa Vista, Curacao, Dominica, Eirunepe, Grenada, Guadeloupe, Guyana, Kralendijk, La Paz, Lower Princes, Manaus, Marigot, Martinique, Montserrat, Port of Spain, Porto Velho, Puerto Rico, Rio Branco, Santo Domingo, St Barthelemy, St Kitts, St Lucia, St Thomas, St Vincent, Tortola', -240], - ['America/Campo_Grande', '(UTC -04:00) Campo Grande, Cuiaba', -240], - ['America/Asuncion', '(UTC -04:00) Asuncion', -240], - ['America/St_Johns', '(UTC -03:30) St Johns', -210], - ['America/Sao_Paulo', '(UTC -03:00) Sao Paulo', -180], - ['America/Araguaina', '(UTC -03:00) Araguaina, Bahia, Belem, Buenos Aires, Catamarca, Cayenne, Cordoba, Fortaleza, Jujuy, La Rioja, Maceio, Mendoza, Paramaribo, Recife, Rio Gallegos, Rothera, Salta, San Juan, Santarem, Tucuman, Ushuaia', -180], - ['America/Montevideo', '(UTC -03:00) Montevideo', -180], - ['America/Godthab', '(UTC -03:00) Godthab', -180], - ['America/Argentina/San_Luis', '(UTC -03:00) San Luis', -180], - ['America/Miquelon', '(UTC -03:00) Miquelon', -180], - ['America/Noronha', '(UTC -02:00) Noronha, South Georgia', -120], - ['Atlantic/Cape_Verde', '(UTC -01:00) Cape Verde', -60], - ['America/Scoresbysund', '(UTC -01:00) Azores, Scoresbysund', -60], - ['Atlantic/Canary', '(UTC) Canary, Dublin, Faroe, Guernsey, Isle of Man, Jersey, Lisbon, London, Madeira', 0], - ['Africa/Abidjan', '(UTC) Abidjan, Accra, Bamako, Banjul, Bissau, Casablanca, Conakry, Dakar, Danmarkshavn, El Aaiun, Freetown, Lome, Monrovia, Nouakchott, Ouagadougou, Reykjavik, Sao Tome, St Helena', 0], - ['Africa/Algiers', '(UTC +01:00) Algiers, Bangui, Brazzaville, Douala, Kinshasa, Lagos, Libreville, Luanda, Malabo, Ndjamena, Niamey, Porto-Novo, Tunis', 60], - ['Europe/Vienna', '(UTC +01:00) Amsterdam, Andorra, Belgrade, Berlin, Bratislava, Brussels, Budapest, Ceuta, Copenhagen, Gibraltar, Ljubljana, Longyearbyen, Luxembourg, Madrid, Malta, Monaco, Oslo, Paris, Podgorica, Prague, Rome, San Marino, Sarajevo, Skopje, Stockholm, Tirane, Vaduz, Vatican, Vienna, Warsaw, Zagreb, Zurich', 60], - ['Africa/Windhoek', '(UTC +01:00) Windhoek', 60], - ['Asia/Damascus', '(UTC +02:00) Damascus', 120], - ['Asia/Beirut', '(UTC +02:00) Beirut', 120], - ['Asia/Jerusalem', '(UTC +02:00) Jerusalem', 120], - ['Asia/Nicosia', '(UTC +02:00) Athens, Bucharest, Chisinau, Helsinki, Istanbul, Mariehamn, Nicosia, Riga, Sofia, Tallinn, Vilnius', 120], - ['Africa/Blantyre', '(UTC +02:00) Blantyre, Bujumbura, Cairo, Gaborone, Gaza, Harare, Hebron, Johannesburg, Kigali, Lubumbashi, Lusaka, Maputo, Maseru, Mbabane, Tripoli', 120], - ['Asia/Amman', '(UTC +02:00) Amman', 120], - ['Africa/Addis_Ababa', '(UTC +03:00) Addis Ababa, Aden, Antananarivo, Asmara, Baghdad, Bahrain, Comoro, Dar es Salaam, Djibouti, Juba, Kaliningrad, Kampala, Khartoum, Kiev, Kuwait, Mayotte, Minsk, Mogadishu, Nairobi, Qatar, Riyadh, Simferopol, Syowa, Uzhgorod, Zaporozhye', 180], - ['Asia/Tehran', '(UTC +03:30) Tehran', 210], - ['Asia/Yerevan', '(UTC +04:00) Yerevan', 240], - ['Asia/Dubai', '(UTC +04:00) Dubai, Mahe, Mauritius, Moscow, Muscat, Reunion, Samara, Tbilisi, Volgograd', 240], - ['Asia/Baku', '(UTC +04:00) Baku', 240], - ['Asia/Kabul', '(UTC +04:30) Kabul', 270], - ['Antarctica/Mawson', '(UTC +05:00) Aqtau, Aqtobe, Ashgabat, Dushanbe, Karachi, Kerguelen, Maldives, Mawson, Oral, Samarkand, Tashkent', 300], - ['Asia/Colombo', '(UTC +05:30) Colombo, Kolkata', 330], - ['Asia/Kathmandu', '(UTC +05:45) Kathmandu', 345], - ['Antarctica/Vostok', '(UTC +06:00) Almaty, Bishkek, Chagos, Dhaka, Qyzylorda, Thimphu, Vostok, Yekaterinburg', 360], - ['Asia/Rangoon', '(UTC +06:30) Cocos, Rangoon', 390], - ['Antarctica/Davis', '(UTC +07:00) Bangkok, Christmas, Davis, Ho Chi Minh, Hovd, Jakarta, Novokuznetsk, Novosibirsk, Omsk, Phnom Penh, Pontianak, Vientiane', 420], - ['Antarctica/Casey', '(UTC +08:00) Brunei, Casey, Choibalsan, Chongqing, Harbin, Hong Kong, Kashgar, Krasnoyarsk, Kuala Lumpur, Kuching, Macau, Makassar, Manila, Perth, Shanghai, Singapore, Taipei, Ulaanbaatar, Urumqi', 480], - ['Australia/Eucla', '(UTC +08:45) Eucla', 525], - ['Asia/Dili', '(UTC +09:00) Dili, Irkutsk, Jayapura, Palau, Pyongyang, Seoul, Tokyo', 540], - ['Australia/Adelaide', '(UTC +09:30) Adelaide, Broken Hill', 570], - ['Australia/Darwin', '(UTC +09:30) Darwin', 570], - ['Antarctica/DumontDUrville', '(UTC +10:00) Brisbane, Chuuk, DumontDUrville, Guam, Lindeman, Port Moresby, Saipan, Yakutsk', 600], - ['Australia/Currie', '(UTC +10:00) Currie, Hobart, Melbourne, Sydney', 600], - ['Australia/Lord_Howe', '(UTC +10:30) Lord Howe', 630], - ['Antarctica/Macquarie', '(UTC +11:00) Efate, Guadalcanal, Kosrae, Macquarie, Noumea, Pohnpei, Sakhalin, Vladivostok', 660], - ['Pacific/Norfolk', '(UTC +11:30) Norfolk', 690], - ['Antarctica/McMurdo', '(UTC +12:00) Auckland, McMurdo, South Pole', 720], - ['Asia/Anadyr', '(UTC +12:00) Anadyr, Fiji, Funafuti, Kamchatka, Kwajalein, Magadan, Majuro, Nauru, Tarawa, Wake, Wallis', 720], - ['Pacific/Chatham', '(UTC +12:45) Chatham', 765], - ['Pacific/Enderbury', '(UTC +13:00) Enderbury, Tongatapu', 780], - ['Pacific/Apia', '(UTC +13:00) Apia', 780], - ['Pacific/Kiritimati', '(UTC +14:00) Kiritimati', 840] - ], - - /* map all citys to the above timezones */ - map: { - /*-11:00*/ - 'Etc/GMT+11': 'Pacific/Midway', - 'Pacific/Midway': 'Pacific/Midway', - 'Pacific/Niue': 'Pacific/Midway', - 'Pacific/Pago_Pago': 'Pacific/Midway', - 'Pacific/Samoa': 'Pacific/Midway', - 'US/Samoa': 'Pacific/Midway', - /*-10:00*/ - 'America/Adak': 'Pacific/Fakaofo', - 'America/Atka': 'Pacific/Fakaofo', - 'Etc/GMT+10': 'Pacific/Fakaofo', - 'HST': 'Pacific/Fakaofo', - 'Pacific/Honolulu': 'Pacific/Fakaofo', - 'Pacific/Johnston': 'Pacific/Fakaofo', - 'Pacific/Rarotonga': 'Pacific/Fakaofo', - 'Pacific/Tahiti': 'Pacific/Fakaofo', - 'SystemV/HST10': 'Pacific/Fakaofo', - 'US/Aleutian': 'Pacific/Fakaofo', - 'US/Hawaii': 'Pacific/Fakaofo', - /*-9:30*/ - 'Pacific/Marquesas': 'Pacific/Marquesas', - /*-9:00*/ - 'AST': 'America/Anchorage', - 'America/Anchorage': 'America/Anchorage', - 'America/Juneau': 'America/Anchorage', - 'America/Nome': 'America/Anchorage', - 'America/Sitka': 'America/Anchorage', - 'America/Yakutat': 'America/Anchorage', - 'Etc/GMT+9': 'America/Anchorage', - 'Pacific/Gambier': 'America/Anchorage', - 'SystemV/YST9': 'America/Anchorage', - 'SystemV/YST9YDT': 'America/Anchorage', - 'US/Alaska': 'America/Anchorage', - /*-8:00*/ - 'America/Dawson': 'America/Dawson', - 'America/Ensenada': 'America/Dawson', - 'America/Los_Angeles': 'America/Dawson', - 'America/Metlakatla': 'America/Dawson', - 'America/Santa_Isabel': 'America/Dawson', - 'America/Tijuana': 'America/Dawson', - 'America/Vancouver': 'America/Dawson', - 'America/Whitehorse': 'America/Dawson', - 'Canada/Pacific': 'America/Dawson', - 'Canada/Yukon': 'America/Dawson', - 'Etc/GMT+8': 'America/Dawson', - 'Mexico/BajaNorte': 'America/Dawson', - 'PST': 'America/Dawson', - 'PST8PDT': 'America/Dawson', - 'Pacific/Pitcairn': 'America/Dawson', - 'SystemV/PST8': 'America/Dawson', - 'SystemV/PST8PDT': 'America/Dawson', - 'US/Pacific': 'America/Dawson', - 'US/Pacific-New': 'America/Dawson', - /*-7:00*/ - 'America/Boise': 'America/Dawson_Creek', - 'America/Cambridge_Bay': 'America/Dawson_Creek', - 'America/Chihuahua': 'America/Dawson_Creek', - 'America/Creston': 'America/Dawson_Creek', - 'America/Dawson_Creek': 'America/Dawson_Creek', - 'America/Denver': 'America/Dawson_Creek', - 'America/Edmonton': 'America/Dawson_Creek', - 'America/Hermosillo': 'America/Dawson_Creek', - 'America/Inuvik': 'America/Dawson_Creek', - 'America/Mazatlan': 'America/Dawson_Creek', - 'America/Ojinaga': 'America/Dawson_Creek', - 'America/Phoenix': 'America/Dawson_Creek', - 'America/Shiprock': 'America/Dawson_Creek', - 'America/Yellowknife': 'America/Dawson_Creek', - 'Canada/Mountain': 'America/Dawson_Creek', - 'Etc/GMT+7': 'America/Dawson_Creek', - 'MST': 'America/Dawson_Creek', - 'MST7MDT': 'America/Dawson_Creek', - 'Mexico/BajaSur': 'America/Dawson_Creek', - 'Navajo': 'America/Dawson_Creek', - 'PNT': 'America/Dawson_Creek', - 'SystemV/MST7': 'America/Dawson_Creek', - 'SystemV/MST7MDT': 'America/Dawson_Creek', - 'US/Arizona': 'America/Dawson_Creek', - 'US/Mountain': 'America/Dawson_Creek', - /*-6:00*/ - 'America/Bahia_Banderas': 'America/Chicago', - 'America/Belize': 'America/Chicago', - 'America/Cancun': 'America/Chicago', - 'America/Chicago': 'America/Chicago', - 'America/Costa_Rica': 'America/Chicago', - 'America/El_Salvador': 'America/Chicago', - 'America/Guatemala': 'America/Chicago', - 'America/Indiana/Knox': 'America/Chicago', - 'America/Indiana/Tell_City': 'America/Chicago', - 'America/Knox_IN': 'America/Chicago', - 'America/Managua': 'America/Chicago', - 'America/Matamoros': 'America/Chicago', - 'America/Menominee': 'America/Chicago', - 'America/Merida': 'America/Chicago', - 'America/Mexico_City': 'America/Chicago', - 'America/Monterrey': 'America/Chicago', - 'America/North_Dakota/Beulah': 'America/Chicago', - 'America/North_Dakota/Center': 'America/Chicago', - 'America/North_Dakota/New_Salem': 'America/Chicago', - 'America/Rainy_River': 'America/Chicago', - 'America/Rankin_Inlet': 'America/Chicago', - 'America/Regina': 'America/Chicago', - 'America/Resolute': 'America/Chicago', - 'America/Swift_Current': 'America/Chicago', - 'America/Tegucigalpa': 'America/Chicago', - 'America/Winnipeg': 'America/Chicago', - 'CST': 'America/Chicago', - 'CST6CDT': 'America/Chicago', - 'Canada/Central': 'America/Chicago', - 'Canada/East-Saskatchewan': 'America/Chicago', - 'Canada/Saskatchewan': 'America/Chicago', - 'Chile/EasterIsland': 'America/Chicago', - 'Etc/GMT+6': 'America/Chicago', - 'Mexico/General': 'America/Chicago', - 'Pacific/Easter': 'America/Chicago', - 'Pacific/Galapagos': 'America/Chicago', - 'SystemV/CST6': 'America/Chicago', - 'SystemV/CST6CDT': 'America/Chicago', - 'US/Central': 'America/Chicago', - 'US/Indiana-Starke': 'America/Chicago', - /*-5:00*/ - 'America/Atikokan': 'America/Detroit', - 'America/Bogota': 'America/Detroit', - 'America/Cayman': 'America/Detroit', - 'America/Coral_Harbour': 'America/Detroit', - 'America/Detroit': 'America/Detroit', - 'America/Fort_Wayne': 'America/Detroit', - 'America/Grand_Turk': 'America/Detroit', - 'America/Guayaquil': 'America/Detroit', - 'America/Havana': 'America/Detroit', - 'America/Indiana/Indianapolis': 'America/Detroit', - 'America/Indiana/Marengo': 'America/Detroit', - 'America/Indiana/Petersburg': 'America/Detroit', - 'America/Indiana/Vevay': 'America/Detroit', - 'America/Indiana/Vincennes': 'America/Detroit', - 'America/Indiana/Winamac': 'America/Detroit', - 'America/Indianapolis': 'America/Detroit', - 'America/Iqaluit': 'America/Detroit', - 'America/Jamaica': 'America/Detroit', - 'America/Kentucky/Louisville': 'America/Detroit', - 'America/Kentucky/Monticello': 'America/Detroit', - 'America/Lima': 'America/Detroit', - 'America/Louisville': 'America/Detroit', - 'America/Montreal': 'America/Detroit', - 'America/Nassau': 'America/Detroit', - 'America/New_York': 'America/Detroit', - 'America/Nipigon': 'America/Detroit', - 'America/Panama': 'America/Detroit', - 'America/Pangnirtung': 'America/Detroit', - 'America/Port-au-Prince': 'America/Detroit', - 'America/Thunder_Bay': 'America/Detroit', - 'America/Toronto': 'America/Detroit', - 'Canada/Eastern': 'America/Detroit', - 'Cuba': 'America/Detroit', - 'EST': 'America/Detroit', - 'EST5EDT': 'America/Detroit', - 'Etc/GMT+5': 'America/Detroit', - 'IET': 'America/Detroit', - 'Jamaica': 'America/Detroit', - 'SystemV/EST5': 'America/Detroit', - 'SystemV/EST5EDT': 'America/Detroit', - 'US/East-Indiana': 'America/Detroit', - 'US/Eastern': 'America/Detroit', - 'US/Michigan': 'America/Detroit', - /*-4:30*/ - 'America/Caracas': 'America/Caracas', - /*-4:00*/ - 'America/Anguilla': 'America/Santiago', - 'America/Antigua': 'America/Santiago', - 'America/Argentina/San_Luis': 'America/Santiago', - 'America/Aruba': 'America/Santiago', - 'America/Asuncion': 'America/Santiago', - 'America/Barbados': 'America/Santiago', - 'America/Blanc-Sablon': 'America/Santiago', - 'America/Boa_Vista': 'America/Santiago', - 'America/Campo_Grande': 'America/Santiago', - 'America/Cuiaba': 'America/Santiago', - 'America/Curacao': 'America/Santiago', - 'America/Dominica': 'America/Santiago', - 'America/Eirunepe': 'America/Santiago', - 'America/Glace_Bay': 'America/Santiago', - 'America/Goose_Bay': 'America/Santiago', - 'America/Grenada': 'America/Santiago', - 'America/Guadeloupe': 'America/Santiago', - 'America/Guyana': 'America/Santiago', - 'America/Halifax': 'America/Santiago', - 'America/Kralendijk': 'America/Santiago', - 'America/La_Paz': 'America/Santiago', - 'America/Lower_Princes': 'America/Santiago', - 'America/Manaus': 'America/Santiago', - 'America/Marigot': 'America/Santiago', - 'America/Martinique': 'America/Santiago', - 'America/Moncton': 'America/Santiago', - 'America/Montserrat': 'America/Santiago', - 'America/Port_of_Spain': 'America/Santiago', - 'America/Porto_Acre': 'America/Santiago', - 'America/Porto_Velho': 'America/Santiago', - 'America/Puerto_Rico': 'America/Santiago', - 'America/Rio_Branco': 'America/Santiago', - 'America/Santiago': 'America/Santiago', - 'America/Santo_Domingo': 'America/Santiago', - 'America/St_Barthelemy': 'America/Santiago', - 'America/St_Kitts': 'America/Santiago', - 'America/St_Lucia': 'America/Santiago', - 'America/St_Thomas': 'America/Santiago', - 'America/St_Vincent': 'America/Santiago', - 'America/Thule': 'America/Santiago', - 'America/Tortola': 'America/Santiago', - 'America/Virgin': 'America/Santiago', - 'Antarctica/Palmer': 'America/Santiago', - 'Atlantic/Bermuda': 'America/Santiago', - 'Brazil/Acre': 'America/Santiago', - 'Brazil/West': 'America/Santiago', - 'Canada/Atlantic': 'America/Santiago', - 'Chile/Continental': 'America/Santiago', - 'Etc/GMT+4': 'America/Santiago', - 'PRT': 'America/Santiago', - 'SystemV/AST4': 'America/Santiago', - 'SystemV/AST4ADT': 'America/Santiago', - /*-3:30*/ - 'America/St_Johns': 'America/St_Johns', - 'CNT': '', - 'Canada/Newfoundland': '', - /*-3:00*/ - 'AGT': 'America/Sao_Paulo', - 'America/Araguaina': 'America/Sao_Paulo', - 'America/Argentina/Buenos_Aires': 'America/Sao_Paulo', - 'America/Argentina/Catamarca': 'America/Sao_Paulo', - 'America/Argentina/ComodRivadavia': 'America/Sao_Paulo', - 'America/Argentina/Cordoba': 'America/Sao_Paulo', - 'America/Argentina/Jujuy': 'America/Sao_Paulo', - 'America/Argentina/La_Rioja': 'America/Sao_Paulo', - 'America/Argentina/Mendoza': 'America/Sao_Paulo', - 'America/Argentina/Rio_Gallegos': 'America/Sao_Paulo', - 'America/Argentina/Salta': 'America/Sao_Paulo', - 'America/Argentina/San_Juan': 'America/Sao_Paulo', - 'America/Argentina/Tucuman': 'America/Sao_Paulo', - 'America/Argentina/Ushuaia': 'America/Sao_Paulo', - 'America/Bahia': 'America/Sao_Paulo', - 'America/Belem': 'America/Sao_Paulo', - 'America/Buenos_Aires': 'America/Sao_Paulo', - 'America/Catamarca': 'America/Sao_Paulo', - 'America/Cayenne': 'America/Sao_Paulo', - 'America/Cordoba': 'America/Sao_Paulo', - 'America/Fortaleza': 'America/Sao_Paulo', - 'America/Godthab': 'America/Sao_Paulo', - 'America/Jujuy': 'America/Sao_Paulo', - 'America/Maceio': 'America/Sao_Paulo', - 'America/Mendoza': 'America/Sao_Paulo', - 'America/Miquelon': 'America/Sao_Paulo', - 'America/Montevideo': 'America/Sao_Paulo', - 'America/Paramaribo': 'America/Sao_Paulo', - 'America/Recife': 'America/Sao_Paulo', - 'America/Rosario': 'America/Sao_Paulo', - 'America/Santarem': 'America/Sao_Paulo', - 'America/Sao_Paulo': 'America/Sao_Paulo', - 'Antarctica/Rothera': 'America/Sao_Paulo', - 'Atlantic/Stanley': 'America/Sao_Paulo', - 'BET': 'America/Sao_Paulo', - 'Brazil/East': 'America/Sao_Paulo', - 'Etc/GMT+3': 'America/Sao_Paulo', - /*-2:00*/ - 'America/Noronha': 'America/Noronha', - 'Atlantic/South_Georgia': 'America/Noronha', - 'Brazil/DeNoronha': 'America/Noronha', - 'Etc/GMT+2': 'America/Noronha', - /*-1:00*/ - 'America/Scoresbysund': 'Atlantic/Cape_Verde', - 'Atlantic/Azores': 'Atlantic/Cape_Verde', - 'Atlantic/Cape_Verde': 'Atlantic/Cape_Verde', - 'Etc/GMT+1': 'Atlantic/Cape_Verde', - /*+0:00*/ - 'Africa/Abidjan': 'Africa/Abidjan', - 'Africa/Accra': 'Africa/Abidjan', - 'Africa/Bamako': 'Africa/Abidjan', - 'Africa/Banjul': 'Africa/Abidjan', - 'Africa/Bissau': 'Africa/Abidjan', - 'Africa/Casablanca': 'Africa/Abidjan', - 'Africa/Conakry': 'Africa/Abidjan', - 'Africa/Dakar': 'Africa/Abidjan', - 'Africa/El_Aaiun': 'Africa/Abidjan', - 'Africa/Freetown': 'Africa/Abidjan', - 'Africa/Lome': 'Africa/Abidjan', - 'Africa/Monrovia': 'Africa/Abidjan', - 'Africa/Nouakchott': 'Africa/Abidjan', - 'Africa/Ouagadougou': 'Africa/Abidjan', - 'Africa/Sao_Tome': 'Africa/Abidjan', - 'Africa/Timbuktu': 'Africa/Abidjan', - 'America/Danmarkshavn': 'Africa/Abidjan', - 'Atlantic/Canary': 'Africa/Abidjan', - 'Atlantic/Faeroe': 'Africa/Abidjan', - 'Atlantic/Faroe': 'Africa/Abidjan', - 'Atlantic/Madeira': 'Africa/Abidjan', - 'Atlantic/Reykjavik': 'Africa/Abidjan', - 'Atlantic/St_Helena': 'Africa/Abidjan', - 'Eire': 'Africa/Abidjan', - 'Etc/GMT': 'Africa/Abidjan', - 'Etc/GMT+0': 'Africa/Abidjan', - 'Etc/GMT-0': 'Africa/Abidjan', - 'Etc/GMT0': 'Africa/Abidjan', - 'Etc/Greenwich': 'Africa/Abidjan', - 'Etc/UCT': 'Africa/Abidjan', - 'Etc/UTC': 'Africa/Abidjan', - 'Etc/Universal': 'Africa/Abidjan', - 'Etc/Zulu': 'Africa/Abidjan', - 'Europe/Belfast': 'Africa/Abidjan', - 'Europe/Dublin': 'Africa/Abidjan', - 'Europe/Guernsey': 'Africa/Abidjan', - 'Europe/Isle_of_Man': 'Africa/Abidjan', - 'Europe/Jersey': 'Africa/Abidjan', - 'Europe/Lisbon': 'Africa/Abidjan', - 'Europe/London': 'Africa/Abidjan', - 'GB': 'Africa/Abidjan', - 'GB-Eire': 'Africa/Abidjan', - 'GMT': 'Africa/Abidjan', - 'GMT0': 'Africa/Abidjan', - 'Greenwich': 'Africa/Abidjan', - 'Iceland': 'Africa/Abidjan', - 'Portugal': 'Africa/Abidjan', - 'UCT': 'Africa/Abidjan', - 'UTC': 'Africa/Abidjan', - 'Universal': 'Africa/Abidjan', - 'WET': 'Africa/Abidjan', - 'Zulu': 'Africa/Abidjan', - /*+1:00*/ - 'Africa/Algiers': 'Europe/Vienna', - 'Africa/Bangui': 'Europe/Vienna', - 'Africa/Brazzaville': 'Europe/Vienna', - 'Africa/Ceuta': 'Europe/Vienna', - 'Africa/Douala': 'Europe/Vienna', - 'Africa/Kinshasa': 'Europe/Vienna', - 'Africa/Lagos': 'Europe/Vienna', - 'Africa/Libreville': 'Europe/Vienna', - 'Africa/Luanda': 'Europe/Vienna', - 'Africa/Malabo': 'Europe/Vienna', - 'Africa/Ndjamena': 'Europe/Vienna', - 'Africa/Niamey': 'Europe/Vienna', - 'Africa/Porto-Novo': 'Europe/Vienna', - 'Africa/Tunis': 'Europe/Vienna', - 'Africa/Windhoek': 'Europe/Vienna', - 'Arctic/Longyearbyen': 'Europe/Vienna', - 'Atlantic/Jan_Mayen': 'Europe/Vienna', - 'CET': 'Europe/Vienna', - 'ECT': 'Europe/Vienna', - 'Etc/GMT-1': 'Europe/Vienna', - 'Europe/Amsterdam': 'Europe/Vienna', - 'Europe/Andorra': 'Europe/Vienna', - 'Europe/Belgrade': 'Europe/Vienna', - 'Europe/Berlin': 'Europe/Vienna', - 'Europe/Bratislava': 'Europe/Vienna', - 'Europe/Brussels': 'Europe/Vienna', - 'Europe/Budapest': 'Europe/Vienna', - 'Europe/Copenhagen': 'Europe/Vienna', - 'Europe/Gibraltar': 'Europe/Vienna', - 'Europe/Ljubljana': 'Europe/Vienna', - 'Europe/Luxembourg': 'Europe/Vienna', - 'Europe/Madrid': 'Europe/Vienna', - 'Europe/Malta': 'Europe/Vienna', - 'Europe/Monaco': 'Europe/Vienna', - 'Europe/Oslo': 'Europe/Vienna', - 'Europe/Paris': 'Europe/Vienna', - 'Europe/Podgorica': 'Europe/Vienna', - 'Europe/Prague': 'Europe/Vienna', - 'Europe/Rome': 'Europe/Vienna', - 'Europe/San_Marino': 'Europe/Vienna', - 'Europe/Sarajevo': 'Europe/Vienna', - 'Europe/Skopje': 'Europe/Vienna', - 'Europe/Stockholm': 'Europe/Vienna', - 'Europe/Tirane': 'Europe/Vienna', - 'Europe/Vaduz': 'Europe/Vienna', - 'Europe/Vatican': 'Europe/Vienna', - 'Europe/Vienna': 'Europe/Vienna', - 'Europe/Warsaw': 'Europe/Vienna', - 'Europe/Zagreb': 'Europe/Vienna', - 'Europe/Zurich': 'Europe/Vienna', - 'MET': 'Europe/Vienna', - 'Poland': 'Europe/Vienna', - /*+2:00*/ - 'ART': 'Asia/Jerusalem', - 'Africa/Blantyre': 'Asia/Jerusalem', - 'Africa/Bujumbura': 'Asia/Jerusalem', - 'Africa/Cairo': 'Asia/Jerusalem', - 'Africa/Gaborone': 'Asia/Jerusalem', - 'Africa/Harare': 'Asia/Jerusalem', - 'Africa/Johannesburg': 'Asia/Jerusalem', - 'Africa/Kigali': 'Asia/Jerusalem', - 'Africa/Lubumbashi': 'Asia/Jerusalem', - 'Africa/Lusaka': 'Asia/Jerusalem', - 'Africa/Maputo': 'Asia/Jerusalem', - 'Africa/Maseru': 'Asia/Jerusalem', - 'Africa/Mbabane': 'Asia/Jerusalem', - 'Africa/Tripoli': 'Asia/Jerusalem', - 'Asia/Amman': 'Asia/Jerusalem', - 'Asia/Beirut': 'Asia/Jerusalem', - 'Asia/Damascus': 'Asia/Jerusalem', - 'Asia/Gaza': 'Asia/Jerusalem', - 'Asia/Hebron': 'Asia/Jerusalem', - 'Asia/Istanbul': 'Asia/Jerusalem', - 'Asia/Jerusalem': 'Asia/Jerusalem', - 'Asia/Nicosia': 'Asia/Jerusalem', - 'Asia/Tel_Aviv': 'Asia/Jerusalem', - 'CAT': 'Asia/Jerusalem', - 'EET': 'Asia/Jerusalem', - 'Egypt': 'Asia/Jerusalem', - 'Etc/GMT-2': 'Asia/Jerusalem', - 'Europe/Athens': 'Asia/Jerusalem', - 'Europe/Bucharest': 'Asia/Jerusalem', - 'Europe/Chisinau': 'Asia/Jerusalem', - 'Europe/Helsinki': 'Asia/Jerusalem', - 'Europe/Istanbul': 'Asia/Jerusalem', - 'Europe/Kiev': 'Asia/Jerusalem', - 'Europe/Mariehamn': 'Asia/Jerusalem', - 'Europe/Nicosia': 'Asia/Jerusalem', - 'Europe/Riga': 'Asia/Jerusalem', - 'Europe/Simferopol': 'Asia/Jerusalem', - 'Europe/Sofia': 'Asia/Jerusalem', - 'Europe/Tallinn': 'Asia/Jerusalem', - 'Europe/Tiraspol': 'Asia/Jerusalem', - 'Europe/Uzhgorod': 'Asia/Jerusalem', - 'Europe/Vilnius': 'Asia/Jerusalem', - 'Europe/Zaporozhye': 'Asia/Jerusalem', - 'Israel': 'Asia/Jerusalem', - 'Libya': 'Asia/Jerusalem', - 'Turkey': 'Asia/Jerusalem', - /*+3:00*/ - 'Africa/Addis_Ababa': 'Africa/Addis_Ababa', - 'Africa/Asmara': 'Africa/Addis_Ababa', - 'Africa/Asmera': 'Africa/Addis_Ababa', - 'Africa/Dar_es_Salaam': 'Africa/Addis_Ababa', - 'Africa/Djibouti': 'Africa/Addis_Ababa', - 'Africa/Juba': 'Africa/Addis_Ababa', - 'Africa/Kampala': 'Africa/Addis_Ababa', - 'Africa/Khartoum': 'Africa/Addis_Ababa', - 'Africa/Mogadishu': 'Africa/Addis_Ababa', - 'Africa/Nairobi': 'Africa/Addis_Ababa', - 'Antarctica/Syowa': 'Africa/Addis_Ababa', - 'Asia/Aden': 'Africa/Addis_Ababa', - 'Asia/Baghdad': 'Africa/Addis_Ababa', - 'Asia/Bahrain': 'Africa/Addis_Ababa', - 'Asia/Kuwait': 'Africa/Addis_Ababa', - 'Asia/Qatar': 'Africa/Addis_Ababa', - 'Asia/Riyadh': 'Africa/Addis_Ababa', - 'EAT': 'Africa/Addis_Ababa', - 'Etc/GMT-3': 'Africa/Addis_Ababa', - 'Europe/Kaliningrad': 'Africa/Addis_Ababa', - 'Europe/Minsk': 'Africa/Addis_Ababa', - 'Indian/Antananarivo': 'Africa/Addis_Ababa', - 'Indian/Comoro': 'Africa/Addis_Ababa', - 'Indian/Mayotte': 'Africa/Addis_Ababa', - /*+3:30*/ - 'Asia/Tehran': 'Asia/Tehran', - 'Iran': 'Asia/Tehran', - /*+4:00*/ - 'Asia/Baku': 'Asia/Dubai', - 'Asia/Dubai': 'Asia/Dubai', - 'Asia/Muscat': 'Asia/Dubai', - 'Asia/Tbilisi': 'Asia/Dubai', - 'Asia/Yerevan': 'Asia/Dubai', - 'Etc/GMT-4': 'Asia/Dubai', - 'Europe/Moscow': 'Asia/Dubai', - 'Europe/Samara': 'Asia/Dubai', - 'Europe/Volgograd': 'Asia/Dubai', - 'Indian/Mahe': 'Asia/Dubai', - 'Indian/Mauritius': 'Asia/Dubai', - 'Indian/Reunion': 'Asia/Dubai', - 'NET': 'Asia/Dubai', - 'W-SU': 'Asia/Dubai', - /*+4:30*/ - 'Asia/Kabul': 'Asia/Kabul', - /*+5:00*/ - 'Antarctica/Mawson': 'Antarctica/Mawson', - 'Asia/Aqtau': 'Antarctica/Mawson', - 'Asia/Aqtobe': 'Antarctica/Mawson', - 'Asia/Ashgabat': 'Antarctica/Mawson', - 'Asia/Ashkhabad': 'Antarctica/Mawson', - 'Asia/Dushanbe': 'Antarctica/Mawson', - 'Asia/Karachi': 'Antarctica/Mawson', - 'Asia/Oral': 'Antarctica/Mawson', - 'Asia/Samarkand': 'Antarctica/Mawson', - 'Asia/Tashkent': 'Antarctica/Mawson', - 'Etc/GMT-5': 'Antarctica/Mawson', - 'Indian/Kerguelen': 'Antarctica/Mawson', - 'Indian/Maldives': 'Antarctica/Mawson', - 'PLT': 'Antarctica/Mawson', - /*+5:30*/ - 'Asia/Calcutta': 'Asia/Colombo', - 'Asia/Colombo': 'Asia/Colombo', - 'Asia/Kolkata': 'Asia/Colombo', - 'IST': 'Asia/Colombo', - /*+6:00*/ - 'Antarctica/Vostok': 'Antarctica/Vostok', - 'Asia/Almaty': 'Antarctica/Vostok', - 'Asia/Bishkek': 'Antarctica/Vostok', - 'Asia/Dacca': 'Antarctica/Vostok', - 'Asia/Dhaka': 'Antarctica/Vostok', - 'Asia/Qyzylorda': 'Antarctica/Vostok', - 'Asia/Thimbu': 'Antarctica/Vostok', - 'Asia/Thimphu': 'Antarctica/Vostok', - 'Asia/Yekaterinburg': 'Antarctica/Vostok', - 'BST': 'Antarctica/Vostok', - 'Etc/GMT-6': 'Antarctica/Vostok', - 'Indian/Chagos': 'Antarctica/Vostok', - /*+6:30*/ - 'Asia/Rangoon': 'Asia/Rangoon', - 'Indian/Cocos': 'Asia/Rangoon', - /*+7:00*/ - 'Antarctica/Davis': 'Antarctica/Davis', - 'Asia/Bangkok': 'Antarctica/Davis', - 'Asia/Ho_Chi_Minh': 'Antarctica/Davis', - 'Asia/Hovd': 'Antarctica/Davis', - 'Asia/Jakarta': 'Antarctica/Davis', - 'Asia/Novokuznetsk': 'Antarctica/Davis', - 'Asia/Novosibirsk': 'Antarctica/Davis', - 'Asia/Omsk': 'Antarctica/Davis', - 'Asia/Phnom_Penh': 'Antarctica/Davis', - 'Asia/Pontianak': 'Antarctica/Davis', - 'Asia/Saigon': 'Antarctica/Davis', - 'Asia/Vientiane': 'Antarctica/Davis', - 'Etc/GMT-7': 'Antarctica/Davis', - 'Indian/Christmas': 'Antarctica/Davis', - 'VST': 'Antarctica/Davis', - /*+8:00*/ - 'Antarctica/Casey': 'Antarctica/Casey', - 'Asia/Brunei': 'Antarctica/Casey', - 'Asia/Choibalsan': 'Antarctica/Casey', - 'Asia/Chongqing': 'Antarctica/Casey', - 'Asia/Chungking': 'Antarctica/Casey', - 'Asia/Harbin': 'Antarctica/Casey', - 'Asia/Hong_Kong': 'Antarctica/Casey', - 'Asia/Kashgar': 'Antarctica/Casey', - 'Asia/Krasnoyarsk': 'Antarctica/Casey', - 'Asia/Kuala_Lumpur': 'Antarctica/Casey', - 'Asia/Kuching': 'Antarctica/Casey', - 'Asia/Macao': 'Antarctica/Casey', - 'Asia/Macau': 'Antarctica/Casey', - 'Asia/Makassar': 'Antarctica/Casey', - 'Asia/Manila': 'Antarctica/Casey', - 'Asia/Shanghai': 'Antarctica/Casey', - 'Asia/Singapore': 'Antarctica/Casey', - 'Asia/Taipei': 'Antarctica/Casey', - 'Asia/Ujung_Pandang': 'Antarctica/Casey', - 'Asia/Ulaanbaatar': 'Antarctica/Casey', - 'Asia/Ulan_Bator': 'Antarctica/Casey', - 'Asia/Urumqi': 'Antarctica/Casey', - 'Australia/Perth': 'Antarctica/Casey', - 'Australia/West': 'Antarctica/Casey', - 'CTT': 'Antarctica/Casey', - 'Etc/GMT-8': 'Antarctica/Casey', - 'Hongkong': 'Antarctica/Casey', - 'PRC': 'Antarctica/Casey', - 'Singapore': 'Antarctica/Casey', - /*+9:00*/ - 'Asia/Dili': 'Asia/Dili', - 'Asia/Irkutsk': 'Asia/Dili', - 'Asia/Jayapura': 'Asia/Dili', - 'Asia/Pyongyang': 'Asia/Dili', - 'Asia/Seoul': 'Asia/Dili', - 'Asia/Tokyo': 'Asia/Dili', - 'Etc/GMT-9': 'Asia/Dili', - 'JST': 'Asia/Dili', - 'Japan': 'Asia/Dili', - 'Pacific/Palau': 'Asia/Dili', - 'ROK': 'Asia/Dili', - /*+9:30*/ - 'ACT': 'Australia/Darwin', - 'Australia/Adelaide': 'Australia/Darwin', - 'Australia/Broken_Hill': 'Australia/Darwin', - 'Australia/Darwin': 'Australia/Darwin', - 'Australia/North': 'Australia/Darwin', - 'Australia/South': 'Australia/Darwin', - 'Australia/Yancowinna': 'Australia/Darwin', - /*+10:00*/ - 'AET': 'Australia/Currie', - 'Antarctica/DumontDUrville': 'Australia/Currie', - 'Asia/Yakutsk': 'Australia/Currie', - 'Australia/ACT': 'Australia/Currie', - 'Australia/Brisbane': 'Australia/Currie', - 'Australia/Canberra': 'Australia/Currie', - 'Australia/Currie': 'Australia/Currie', - 'Australia/Hobart': 'Australia/Currie', - 'Australia/Lindeman': 'Australia/Currie', - 'Australia/Melbourne': 'Australia/Currie', - 'Australia/NSW': 'Australia/Currie', - 'Australia/Queensland': 'Australia/Currie', - 'Australia/Sydney': 'Australia/Currie', - 'Australia/Tasmania': 'Australia/Currie', - 'Australia/Victoria': 'Australia/Currie', - 'Etc/GMT-10': 'Australia/Currie', - 'Pacific/Chuuk': 'Australia/Currie', - 'Pacific/Guam': 'Australia/Currie', - 'Pacific/Port_Moresby': 'Australia/Currie', - 'Pacific/Saipan': 'Australia/Currie', - 'Pacific/Truk': 'Australia/Currie', - 'Pacific/Yap': 'Australia/Currie', - /*+10:30*/ - 'Australia/LHI': 'Australia/Lord_Howe', - 'Australia/Lord_Howe': 'Australia/Lord_Howe', - /*+11:00*/ - 'Antarctica/Macquarie': 'Antarctica/Macquarie', - 'Asia/Sakhalin': 'Antarctica/Macquarie', - 'Asia/Vladivostok': 'Antarctica/Macquarie', - 'Etc/GMT-11': 'Antarctica/Macquarie', - 'Pacific/Efate': 'Antarctica/Macquarie', - 'Pacific/Guadalcanal': 'Antarctica/Macquarie', - 'Pacific/Kosrae': 'Antarctica/Macquarie', - 'Pacific/Noumea': 'Antarctica/Macquarie', - 'Pacific/Pohnpei': 'Antarctica/Macquarie', - 'Pacific/Ponape': 'Antarctica/Macquarie', - 'SST': 'Antarctica/Macquarie', - /*+11:30*/ - 'Pacific/Norfolk': 'Pacific/Norfolk', - /*+12:00*/ - 'Antarctica/McMurdo': 'Antarctica/McMurdo', - 'Antarctica/South_Pole': 'Antarctica/McMurdo', - 'Asia/Anadyr': 'Antarctica/McMurdo', - 'Asia/Kamchatka': 'Antarctica/McMurdo', - 'Asia/Magadan': 'Antarctica/McMurdo', - 'Etc/GMT-12': 'Antarctica/McMurdo', - 'Kwajalein': 'Antarctica/McMurdo', - 'NST': 'Antarctica/McMurdo', - 'NZ': 'Antarctica/McMurdo', - 'Pacific/Auckland': 'Antarctica/McMurdo', - 'Pacific/Fiji': 'Antarctica/McMurdo', - 'Pacific/Funafuti': 'Antarctica/McMurdo', - 'Pacific/Kwajalein': 'Antarctica/McMurdo', - 'Pacific/Majuro': 'Antarctica/McMurdo', - 'Pacific/Nauru': 'Antarctica/McMurdo', - 'Pacific/Tarawa': 'Antarctica/McMurdo', - 'Pacific/Wake': 'Antarctica/McMurdo', - 'Pacific/Wallis': 'Antarctica/McMurdo', - /*+13:00*/ - 'Etc/GMT-13': 'Pacific/Enderbury', - 'MIT': 'Pacific/Enderbury', - 'Pacific/Apia': 'Pacific/Enderbury', - 'Pacific/Enderbury': 'Pacific/Enderbury', - 'Pacific/Tongatapu': 'Pacific/Enderbury', - /*+14:00*/ - 'Etc/GMT-14': 'Pacific/Kiritimati', - 'Pacific/Fakaofo': 'Pacific/Kiritimati', - 'Pacific/Kiritimati': 'Pacific/Kiritimati' - }, - - /* return unmapped timezone... */ - unMap: function (timezone) { - return this.map[timezone] !== undefined ? this.map[timezone] : timezone; - }, - - getOffset: function (timezone) { - /* find timezone, this needs to be optimized ;) */ - timezone = this.unMap(timezone); - var i = 0; - for (i = 0; i < this.store.length; i++) { - if (this.store[i][0] == timezone) { - return (this.store[i][2] * 60000); - } - } - - return 0; // no offset found... - } -}); - +/** + * timezones.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/** + * Timezone class + * + * This class can handle all our timezone operations and conversions. + */ +Ext.namespace("Zarafa.plugins.calendarimporter.data"); + +Zarafa.plugins.calendarimporter.data.Timezones = Ext.extend(Object, { + + store: [ + ['Pacific/Midway', '(UTC -11:00) Midway, Niue, Pago Pago', -660], + ['Pacific/Fakaofo', '(UTC -10:00) Adak, Fakaofo, Honolulu, Johnston, Rarotonga, Tahiti', -600], + ['Pacific/Marquesas', '(UTC -09:30) Marquesas', -570], + ['America/Anchorage', '(UTC -09:00) Gambier, Anchorage, Juneau, Nome, Sitka, Yakutat', -540], + ['America/Dawson', '(UTC -08:00) Dawson, Los Angeles, Tijuana, Vancouver, Whitehorse, Santa Isabel, Metlakatla, Pitcairn', -480], + ['America/Dawson_Creek', '(UTC -07:00) Dawson Creek, Hermosillo, Phoenix, Chihuahua, Mazatlan, Boise, Cambridge Bay, Denver, Edmonton, Inuvik, Ojinaga, Shiprock, Yellowknife', -420], + ['America/Chicago', '(UTC -06:00) Beulah, Center, Chicago, Knox, Matamoros, Menominee, New Salem, Rainy River, Rankin Inlet, Resolute, Tell City, Winnipeg', -360], + ['America/Belize', '(UTC -06:00) Belize, Costa Rica, El Salvador, Galapagos, Guatemala, Managua, Regina, Swift Current, Tegucigalpa', -360], + ['Pacific/Easter', '(UTC -06:00) Easter', -360], + ['America/Bahia_Banderas', '(UTC -06:00) Bahia Banderas, Cancun, Merida, Mexico City, Monterrey', -360], + ['America/Detroit', '(UTC -05:00) Detroit, Grand Turk, Indianapolis, Iqaluit, Louisville, Marengo, Monticello, Montreal, Nassau, New York, Nipigon, Pangnirtung, Petersburg, Thunder Bay, Toronto, Vevay, Vincennes, Winamac', -300], + ['America/Atikokan', '(UTC -05:00) Atikokan, Bogota, Cayman, Guayaquil, Jamaica, Lima, Panama, Port-au-Prince', -300], + ['America/Havana', '(UTC -05:00) Havana', -300], + ['America/Caracas', '(UTC -04:30) Caracas', -270], + ['America/Glace_Bay', '(UTC -04:00) Bermuda, Glace Bay, Goose Bay, Halifax, Moncton, Thule', -240], + ['Atlantic/Stanley', '(UTC -04:00) Stanley', -240], + ['America/Santiago', '(UTC -04:00) Palmer, Santiago', -240], + ['America/Anguilla', '(UTC -04:00) Anguilla, Antigua, Aruba, Barbados, Blanc-Sablon, Boa Vista, Curacao, Dominica, Eirunepe, Grenada, Guadeloupe, Guyana, Kralendijk, La Paz, Lower Princes, Manaus, Marigot, Martinique, Montserrat, Port of Spain, Porto Velho, Puerto Rico, Rio Branco, Santo Domingo, St Barthelemy, St Kitts, St Lucia, St Thomas, St Vincent, Tortola', -240], + ['America/Campo_Grande', '(UTC -04:00) Campo Grande, Cuiaba', -240], + ['America/Asuncion', '(UTC -04:00) Asuncion', -240], + ['America/St_Johns', '(UTC -03:30) St Johns', -210], + ['America/Sao_Paulo', '(UTC -03:00) Sao Paulo', -180], + ['America/Araguaina', '(UTC -03:00) Araguaina, Bahia, Belem, Buenos Aires, Catamarca, Cayenne, Cordoba, Fortaleza, Jujuy, La Rioja, Maceio, Mendoza, Paramaribo, Recife, Rio Gallegos, Rothera, Salta, San Juan, Santarem, Tucuman, Ushuaia', -180], + ['America/Montevideo', '(UTC -03:00) Montevideo', -180], + ['America/Godthab', '(UTC -03:00) Godthab', -180], + ['America/Argentina/San_Luis', '(UTC -03:00) San Luis', -180], + ['America/Miquelon', '(UTC -03:00) Miquelon', -180], + ['America/Noronha', '(UTC -02:00) Noronha, South Georgia', -120], + ['Atlantic/Cape_Verde', '(UTC -01:00) Cape Verde', -60], + ['America/Scoresbysund', '(UTC -01:00) Azores, Scoresbysund', -60], + ['Atlantic/Canary', '(UTC) Canary, Dublin, Faroe, Guernsey, Isle of Man, Jersey, Lisbon, London, Madeira', 0], + ['Africa/Abidjan', '(UTC) Abidjan, Accra, Bamako, Banjul, Bissau, Casablanca, Conakry, Dakar, Danmarkshavn, El Aaiun, Freetown, Lome, Monrovia, Nouakchott, Ouagadougou, Reykjavik, Sao Tome, St Helena', 0], + ['Africa/Algiers', '(UTC +01:00) Algiers, Bangui, Brazzaville, Douala, Kinshasa, Lagos, Libreville, Luanda, Malabo, Ndjamena, Niamey, Porto-Novo, Tunis', 60], + ['Europe/Vienna', '(UTC +01:00) Amsterdam, Andorra, Belgrade, Berlin, Bratislava, Brussels, Budapest, Ceuta, Copenhagen, Gibraltar, Ljubljana, Longyearbyen, Luxembourg, Madrid, Malta, Monaco, Oslo, Paris, Podgorica, Prague, Rome, San Marino, Sarajevo, Skopje, Stockholm, Tirane, Vaduz, Vatican, Vienna, Warsaw, Zagreb, Zurich', 60], + ['Africa/Windhoek', '(UTC +01:00) Windhoek', 60], + ['Asia/Damascus', '(UTC +02:00) Damascus', 120], + ['Asia/Beirut', '(UTC +02:00) Beirut', 120], + ['Asia/Jerusalem', '(UTC +02:00) Jerusalem', 120], + ['Asia/Nicosia', '(UTC +02:00) Athens, Bucharest, Chisinau, Helsinki, Istanbul, Mariehamn, Nicosia, Riga, Sofia, Tallinn, Vilnius', 120], + ['Africa/Blantyre', '(UTC +02:00) Blantyre, Bujumbura, Cairo, Gaborone, Gaza, Harare, Hebron, Johannesburg, Kigali, Lubumbashi, Lusaka, Maputo, Maseru, Mbabane, Tripoli', 120], + ['Asia/Amman', '(UTC +02:00) Amman', 120], + ['Africa/Addis_Ababa', '(UTC +03:00) Addis Ababa, Aden, Antananarivo, Asmara, Baghdad, Bahrain, Comoro, Dar es Salaam, Djibouti, Juba, Kaliningrad, Kampala, Khartoum, Kiev, Kuwait, Mayotte, Minsk, Mogadishu, Nairobi, Qatar, Riyadh, Simferopol, Syowa, Uzhgorod, Zaporozhye', 180], + ['Asia/Tehran', '(UTC +03:30) Tehran', 210], + ['Asia/Yerevan', '(UTC +04:00) Yerevan', 240], + ['Asia/Dubai', '(UTC +04:00) Dubai, Mahe, Mauritius, Moscow, Muscat, Reunion, Samara, Tbilisi, Volgograd', 240], + ['Asia/Baku', '(UTC +04:00) Baku', 240], + ['Asia/Kabul', '(UTC +04:30) Kabul', 270], + ['Antarctica/Mawson', '(UTC +05:00) Aqtau, Aqtobe, Ashgabat, Dushanbe, Karachi, Kerguelen, Maldives, Mawson, Oral, Samarkand, Tashkent', 300], + ['Asia/Colombo', '(UTC +05:30) Colombo, Kolkata', 330], + ['Asia/Kathmandu', '(UTC +05:45) Kathmandu', 345], + ['Antarctica/Vostok', '(UTC +06:00) Almaty, Bishkek, Chagos, Dhaka, Qyzylorda, Thimphu, Vostok, Yekaterinburg', 360], + ['Asia/Rangoon', '(UTC +06:30) Cocos, Rangoon', 390], + ['Antarctica/Davis', '(UTC +07:00) Bangkok, Christmas, Davis, Ho Chi Minh, Hovd, Jakarta, Novokuznetsk, Novosibirsk, Omsk, Phnom Penh, Pontianak, Vientiane', 420], + ['Antarctica/Casey', '(UTC +08:00) Brunei, Casey, Choibalsan, Chongqing, Harbin, Hong Kong, Kashgar, Krasnoyarsk, Kuala Lumpur, Kuching, Macau, Makassar, Manila, Perth, Shanghai, Singapore, Taipei, Ulaanbaatar, Urumqi', 480], + ['Australia/Eucla', '(UTC +08:45) Eucla', 525], + ['Asia/Dili', '(UTC +09:00) Dili, Irkutsk, Jayapura, Palau, Pyongyang, Seoul, Tokyo', 540], + ['Australia/Adelaide', '(UTC +09:30) Adelaide, Broken Hill', 570], + ['Australia/Darwin', '(UTC +09:30) Darwin', 570], + ['Antarctica/DumontDUrville', '(UTC +10:00) Brisbane, Chuuk, DumontDUrville, Guam, Lindeman, Port Moresby, Saipan, Yakutsk', 600], + ['Australia/Currie', '(UTC +10:00) Currie, Hobart, Melbourne, Sydney', 600], + ['Australia/Lord_Howe', '(UTC +10:30) Lord Howe', 630], + ['Antarctica/Macquarie', '(UTC +11:00) Efate, Guadalcanal, Kosrae, Macquarie, Noumea, Pohnpei, Sakhalin, Vladivostok', 660], + ['Pacific/Norfolk', '(UTC +11:30) Norfolk', 690], + ['Antarctica/McMurdo', '(UTC +12:00) Auckland, McMurdo, South Pole', 720], + ['Asia/Anadyr', '(UTC +12:00) Anadyr, Fiji, Funafuti, Kamchatka, Kwajalein, Magadan, Majuro, Nauru, Tarawa, Wake, Wallis', 720], + ['Pacific/Chatham', '(UTC +12:45) Chatham', 765], + ['Pacific/Enderbury', '(UTC +13:00) Enderbury, Tongatapu', 780], + ['Pacific/Apia', '(UTC +13:00) Apia', 780], + ['Pacific/Kiritimati', '(UTC +14:00) Kiritimati', 840] + ], + + /* map all citys to the above timezones */ + map: { + /*-11:00*/ + 'Etc/GMT+11': 'Pacific/Midway', + 'Pacific/Midway': 'Pacific/Midway', + 'Pacific/Niue': 'Pacific/Midway', + 'Pacific/Pago_Pago': 'Pacific/Midway', + 'Pacific/Samoa': 'Pacific/Midway', + 'US/Samoa': 'Pacific/Midway', + /*-10:00*/ + 'America/Adak': 'Pacific/Fakaofo', + 'America/Atka': 'Pacific/Fakaofo', + 'Etc/GMT+10': 'Pacific/Fakaofo', + 'HST': 'Pacific/Fakaofo', + 'Pacific/Honolulu': 'Pacific/Fakaofo', + 'Pacific/Johnston': 'Pacific/Fakaofo', + 'Pacific/Rarotonga': 'Pacific/Fakaofo', + 'Pacific/Tahiti': 'Pacific/Fakaofo', + 'SystemV/HST10': 'Pacific/Fakaofo', + 'US/Aleutian': 'Pacific/Fakaofo', + 'US/Hawaii': 'Pacific/Fakaofo', + /*-9:30*/ + 'Pacific/Marquesas': 'Pacific/Marquesas', + /*-9:00*/ + 'AST': 'America/Anchorage', + 'America/Anchorage': 'America/Anchorage', + 'America/Juneau': 'America/Anchorage', + 'America/Nome': 'America/Anchorage', + 'America/Sitka': 'America/Anchorage', + 'America/Yakutat': 'America/Anchorage', + 'Etc/GMT+9': 'America/Anchorage', + 'Pacific/Gambier': 'America/Anchorage', + 'SystemV/YST9': 'America/Anchorage', + 'SystemV/YST9YDT': 'America/Anchorage', + 'US/Alaska': 'America/Anchorage', + /*-8:00*/ + 'America/Dawson': 'America/Dawson', + 'America/Ensenada': 'America/Dawson', + 'America/Los_Angeles': 'America/Dawson', + 'America/Metlakatla': 'America/Dawson', + 'America/Santa_Isabel': 'America/Dawson', + 'America/Tijuana': 'America/Dawson', + 'America/Vancouver': 'America/Dawson', + 'America/Whitehorse': 'America/Dawson', + 'Canada/Pacific': 'America/Dawson', + 'Canada/Yukon': 'America/Dawson', + 'Etc/GMT+8': 'America/Dawson', + 'Mexico/BajaNorte': 'America/Dawson', + 'PST': 'America/Dawson', + 'PST8PDT': 'America/Dawson', + 'Pacific/Pitcairn': 'America/Dawson', + 'SystemV/PST8': 'America/Dawson', + 'SystemV/PST8PDT': 'America/Dawson', + 'US/Pacific': 'America/Dawson', + 'US/Pacific-New': 'America/Dawson', + /*-7:00*/ + 'America/Boise': 'America/Dawson_Creek', + 'America/Cambridge_Bay': 'America/Dawson_Creek', + 'America/Chihuahua': 'America/Dawson_Creek', + 'America/Creston': 'America/Dawson_Creek', + 'America/Dawson_Creek': 'America/Dawson_Creek', + 'America/Denver': 'America/Dawson_Creek', + 'America/Edmonton': 'America/Dawson_Creek', + 'America/Hermosillo': 'America/Dawson_Creek', + 'America/Inuvik': 'America/Dawson_Creek', + 'America/Mazatlan': 'America/Dawson_Creek', + 'America/Ojinaga': 'America/Dawson_Creek', + 'America/Phoenix': 'America/Dawson_Creek', + 'America/Shiprock': 'America/Dawson_Creek', + 'America/Yellowknife': 'America/Dawson_Creek', + 'Canada/Mountain': 'America/Dawson_Creek', + 'Etc/GMT+7': 'America/Dawson_Creek', + 'MST': 'America/Dawson_Creek', + 'MST7MDT': 'America/Dawson_Creek', + 'Mexico/BajaSur': 'America/Dawson_Creek', + 'Navajo': 'America/Dawson_Creek', + 'PNT': 'America/Dawson_Creek', + 'SystemV/MST7': 'America/Dawson_Creek', + 'SystemV/MST7MDT': 'America/Dawson_Creek', + 'US/Arizona': 'America/Dawson_Creek', + 'US/Mountain': 'America/Dawson_Creek', + /*-6:00*/ + 'America/Bahia_Banderas': 'America/Chicago', + 'America/Belize': 'America/Chicago', + 'America/Cancun': 'America/Chicago', + 'America/Chicago': 'America/Chicago', + 'America/Costa_Rica': 'America/Chicago', + 'America/El_Salvador': 'America/Chicago', + 'America/Guatemala': 'America/Chicago', + 'America/Indiana/Knox': 'America/Chicago', + 'America/Indiana/Tell_City': 'America/Chicago', + 'America/Knox_IN': 'America/Chicago', + 'America/Managua': 'America/Chicago', + 'America/Matamoros': 'America/Chicago', + 'America/Menominee': 'America/Chicago', + 'America/Merida': 'America/Chicago', + 'America/Mexico_City': 'America/Chicago', + 'America/Monterrey': 'America/Chicago', + 'America/North_Dakota/Beulah': 'America/Chicago', + 'America/North_Dakota/Center': 'America/Chicago', + 'America/North_Dakota/New_Salem': 'America/Chicago', + 'America/Rainy_River': 'America/Chicago', + 'America/Rankin_Inlet': 'America/Chicago', + 'America/Regina': 'America/Chicago', + 'America/Resolute': 'America/Chicago', + 'America/Swift_Current': 'America/Chicago', + 'America/Tegucigalpa': 'America/Chicago', + 'America/Winnipeg': 'America/Chicago', + 'CST': 'America/Chicago', + 'CST6CDT': 'America/Chicago', + 'Canada/Central': 'America/Chicago', + 'Canada/East-Saskatchewan': 'America/Chicago', + 'Canada/Saskatchewan': 'America/Chicago', + 'Chile/EasterIsland': 'America/Chicago', + 'Etc/GMT+6': 'America/Chicago', + 'Mexico/General': 'America/Chicago', + 'Pacific/Easter': 'America/Chicago', + 'Pacific/Galapagos': 'America/Chicago', + 'SystemV/CST6': 'America/Chicago', + 'SystemV/CST6CDT': 'America/Chicago', + 'US/Central': 'America/Chicago', + 'US/Indiana-Starke': 'America/Chicago', + /*-5:00*/ + 'America/Atikokan': 'America/Detroit', + 'America/Bogota': 'America/Detroit', + 'America/Cayman': 'America/Detroit', + 'America/Coral_Harbour': 'America/Detroit', + 'America/Detroit': 'America/Detroit', + 'America/Fort_Wayne': 'America/Detroit', + 'America/Grand_Turk': 'America/Detroit', + 'America/Guayaquil': 'America/Detroit', + 'America/Havana': 'America/Detroit', + 'America/Indiana/Indianapolis': 'America/Detroit', + 'America/Indiana/Marengo': 'America/Detroit', + 'America/Indiana/Petersburg': 'America/Detroit', + 'America/Indiana/Vevay': 'America/Detroit', + 'America/Indiana/Vincennes': 'America/Detroit', + 'America/Indiana/Winamac': 'America/Detroit', + 'America/Indianapolis': 'America/Detroit', + 'America/Iqaluit': 'America/Detroit', + 'America/Jamaica': 'America/Detroit', + 'America/Kentucky/Louisville': 'America/Detroit', + 'America/Kentucky/Monticello': 'America/Detroit', + 'America/Lima': 'America/Detroit', + 'America/Louisville': 'America/Detroit', + 'America/Montreal': 'America/Detroit', + 'America/Nassau': 'America/Detroit', + 'America/New_York': 'America/Detroit', + 'America/Nipigon': 'America/Detroit', + 'America/Panama': 'America/Detroit', + 'America/Pangnirtung': 'America/Detroit', + 'America/Port-au-Prince': 'America/Detroit', + 'America/Thunder_Bay': 'America/Detroit', + 'America/Toronto': 'America/Detroit', + 'Canada/Eastern': 'America/Detroit', + 'Cuba': 'America/Detroit', + 'EST': 'America/Detroit', + 'EST5EDT': 'America/Detroit', + 'Etc/GMT+5': 'America/Detroit', + 'IET': 'America/Detroit', + 'Jamaica': 'America/Detroit', + 'SystemV/EST5': 'America/Detroit', + 'SystemV/EST5EDT': 'America/Detroit', + 'US/East-Indiana': 'America/Detroit', + 'US/Eastern': 'America/Detroit', + 'US/Michigan': 'America/Detroit', + /*-4:30*/ + 'America/Caracas': 'America/Caracas', + /*-4:00*/ + 'America/Anguilla': 'America/Santiago', + 'America/Antigua': 'America/Santiago', + 'America/Argentina/San_Luis': 'America/Santiago', + 'America/Aruba': 'America/Santiago', + 'America/Asuncion': 'America/Santiago', + 'America/Barbados': 'America/Santiago', + 'America/Blanc-Sablon': 'America/Santiago', + 'America/Boa_Vista': 'America/Santiago', + 'America/Campo_Grande': 'America/Santiago', + 'America/Cuiaba': 'America/Santiago', + 'America/Curacao': 'America/Santiago', + 'America/Dominica': 'America/Santiago', + 'America/Eirunepe': 'America/Santiago', + 'America/Glace_Bay': 'America/Santiago', + 'America/Goose_Bay': 'America/Santiago', + 'America/Grenada': 'America/Santiago', + 'America/Guadeloupe': 'America/Santiago', + 'America/Guyana': 'America/Santiago', + 'America/Halifax': 'America/Santiago', + 'America/Kralendijk': 'America/Santiago', + 'America/La_Paz': 'America/Santiago', + 'America/Lower_Princes': 'America/Santiago', + 'America/Manaus': 'America/Santiago', + 'America/Marigot': 'America/Santiago', + 'America/Martinique': 'America/Santiago', + 'America/Moncton': 'America/Santiago', + 'America/Montserrat': 'America/Santiago', + 'America/Port_of_Spain': 'America/Santiago', + 'America/Porto_Acre': 'America/Santiago', + 'America/Porto_Velho': 'America/Santiago', + 'America/Puerto_Rico': 'America/Santiago', + 'America/Rio_Branco': 'America/Santiago', + 'America/Santiago': 'America/Santiago', + 'America/Santo_Domingo': 'America/Santiago', + 'America/St_Barthelemy': 'America/Santiago', + 'America/St_Kitts': 'America/Santiago', + 'America/St_Lucia': 'America/Santiago', + 'America/St_Thomas': 'America/Santiago', + 'America/St_Vincent': 'America/Santiago', + 'America/Thule': 'America/Santiago', + 'America/Tortola': 'America/Santiago', + 'America/Virgin': 'America/Santiago', + 'Antarctica/Palmer': 'America/Santiago', + 'Atlantic/Bermuda': 'America/Santiago', + 'Brazil/Acre': 'America/Santiago', + 'Brazil/West': 'America/Santiago', + 'Canada/Atlantic': 'America/Santiago', + 'Chile/Continental': 'America/Santiago', + 'Etc/GMT+4': 'America/Santiago', + 'PRT': 'America/Santiago', + 'SystemV/AST4': 'America/Santiago', + 'SystemV/AST4ADT': 'America/Santiago', + /*-3:30*/ + 'America/St_Johns': 'America/St_Johns', + 'CNT': '', + 'Canada/Newfoundland': '', + /*-3:00*/ + 'AGT': 'America/Sao_Paulo', + 'America/Araguaina': 'America/Sao_Paulo', + 'America/Argentina/Buenos_Aires': 'America/Sao_Paulo', + 'America/Argentina/Catamarca': 'America/Sao_Paulo', + 'America/Argentina/ComodRivadavia': 'America/Sao_Paulo', + 'America/Argentina/Cordoba': 'America/Sao_Paulo', + 'America/Argentina/Jujuy': 'America/Sao_Paulo', + 'America/Argentina/La_Rioja': 'America/Sao_Paulo', + 'America/Argentina/Mendoza': 'America/Sao_Paulo', + 'America/Argentina/Rio_Gallegos': 'America/Sao_Paulo', + 'America/Argentina/Salta': 'America/Sao_Paulo', + 'America/Argentina/San_Juan': 'America/Sao_Paulo', + 'America/Argentina/Tucuman': 'America/Sao_Paulo', + 'America/Argentina/Ushuaia': 'America/Sao_Paulo', + 'America/Bahia': 'America/Sao_Paulo', + 'America/Belem': 'America/Sao_Paulo', + 'America/Buenos_Aires': 'America/Sao_Paulo', + 'America/Catamarca': 'America/Sao_Paulo', + 'America/Cayenne': 'America/Sao_Paulo', + 'America/Cordoba': 'America/Sao_Paulo', + 'America/Fortaleza': 'America/Sao_Paulo', + 'America/Godthab': 'America/Sao_Paulo', + 'America/Jujuy': 'America/Sao_Paulo', + 'America/Maceio': 'America/Sao_Paulo', + 'America/Mendoza': 'America/Sao_Paulo', + 'America/Miquelon': 'America/Sao_Paulo', + 'America/Montevideo': 'America/Sao_Paulo', + 'America/Paramaribo': 'America/Sao_Paulo', + 'America/Recife': 'America/Sao_Paulo', + 'America/Rosario': 'America/Sao_Paulo', + 'America/Santarem': 'America/Sao_Paulo', + 'America/Sao_Paulo': 'America/Sao_Paulo', + 'Antarctica/Rothera': 'America/Sao_Paulo', + 'Atlantic/Stanley': 'America/Sao_Paulo', + 'BET': 'America/Sao_Paulo', + 'Brazil/East': 'America/Sao_Paulo', + 'Etc/GMT+3': 'America/Sao_Paulo', + /*-2:00*/ + 'America/Noronha': 'America/Noronha', + 'Atlantic/South_Georgia': 'America/Noronha', + 'Brazil/DeNoronha': 'America/Noronha', + 'Etc/GMT+2': 'America/Noronha', + /*-1:00*/ + 'America/Scoresbysund': 'Atlantic/Cape_Verde', + 'Atlantic/Azores': 'Atlantic/Cape_Verde', + 'Atlantic/Cape_Verde': 'Atlantic/Cape_Verde', + 'Etc/GMT+1': 'Atlantic/Cape_Verde', + /*+0:00*/ + 'Africa/Abidjan': 'Africa/Abidjan', + 'Africa/Accra': 'Africa/Abidjan', + 'Africa/Bamako': 'Africa/Abidjan', + 'Africa/Banjul': 'Africa/Abidjan', + 'Africa/Bissau': 'Africa/Abidjan', + 'Africa/Casablanca': 'Africa/Abidjan', + 'Africa/Conakry': 'Africa/Abidjan', + 'Africa/Dakar': 'Africa/Abidjan', + 'Africa/El_Aaiun': 'Africa/Abidjan', + 'Africa/Freetown': 'Africa/Abidjan', + 'Africa/Lome': 'Africa/Abidjan', + 'Africa/Monrovia': 'Africa/Abidjan', + 'Africa/Nouakchott': 'Africa/Abidjan', + 'Africa/Ouagadougou': 'Africa/Abidjan', + 'Africa/Sao_Tome': 'Africa/Abidjan', + 'Africa/Timbuktu': 'Africa/Abidjan', + 'America/Danmarkshavn': 'Africa/Abidjan', + 'Atlantic/Canary': 'Africa/Abidjan', + 'Atlantic/Faeroe': 'Africa/Abidjan', + 'Atlantic/Faroe': 'Africa/Abidjan', + 'Atlantic/Madeira': 'Africa/Abidjan', + 'Atlantic/Reykjavik': 'Africa/Abidjan', + 'Atlantic/St_Helena': 'Africa/Abidjan', + 'Eire': 'Africa/Abidjan', + 'Etc/GMT': 'Africa/Abidjan', + 'Etc/GMT+0': 'Africa/Abidjan', + 'Etc/GMT-0': 'Africa/Abidjan', + 'Etc/GMT0': 'Africa/Abidjan', + 'Etc/Greenwich': 'Africa/Abidjan', + 'Etc/UCT': 'Africa/Abidjan', + 'Etc/UTC': 'Africa/Abidjan', + 'Etc/Universal': 'Africa/Abidjan', + 'Etc/Zulu': 'Africa/Abidjan', + 'Europe/Belfast': 'Africa/Abidjan', + 'Europe/Dublin': 'Africa/Abidjan', + 'Europe/Guernsey': 'Africa/Abidjan', + 'Europe/Isle_of_Man': 'Africa/Abidjan', + 'Europe/Jersey': 'Africa/Abidjan', + 'Europe/Lisbon': 'Africa/Abidjan', + 'Europe/London': 'Africa/Abidjan', + 'GB': 'Africa/Abidjan', + 'GB-Eire': 'Africa/Abidjan', + 'GMT': 'Africa/Abidjan', + 'GMT0': 'Africa/Abidjan', + 'Greenwich': 'Africa/Abidjan', + 'Iceland': 'Africa/Abidjan', + 'Portugal': 'Africa/Abidjan', + 'UCT': 'Africa/Abidjan', + 'UTC': 'Africa/Abidjan', + 'Universal': 'Africa/Abidjan', + 'WET': 'Africa/Abidjan', + 'Zulu': 'Africa/Abidjan', + /*+1:00*/ + 'Africa/Algiers': 'Europe/Vienna', + 'Africa/Bangui': 'Europe/Vienna', + 'Africa/Brazzaville': 'Europe/Vienna', + 'Africa/Ceuta': 'Europe/Vienna', + 'Africa/Douala': 'Europe/Vienna', + 'Africa/Kinshasa': 'Europe/Vienna', + 'Africa/Lagos': 'Europe/Vienna', + 'Africa/Libreville': 'Europe/Vienna', + 'Africa/Luanda': 'Europe/Vienna', + 'Africa/Malabo': 'Europe/Vienna', + 'Africa/Ndjamena': 'Europe/Vienna', + 'Africa/Niamey': 'Europe/Vienna', + 'Africa/Porto-Novo': 'Europe/Vienna', + 'Africa/Tunis': 'Europe/Vienna', + 'Africa/Windhoek': 'Europe/Vienna', + 'Arctic/Longyearbyen': 'Europe/Vienna', + 'Atlantic/Jan_Mayen': 'Europe/Vienna', + 'CET': 'Europe/Vienna', + 'ECT': 'Europe/Vienna', + 'Etc/GMT-1': 'Europe/Vienna', + 'Europe/Amsterdam': 'Europe/Vienna', + 'Europe/Andorra': 'Europe/Vienna', + 'Europe/Belgrade': 'Europe/Vienna', + 'Europe/Berlin': 'Europe/Vienna', + 'Europe/Bratislava': 'Europe/Vienna', + 'Europe/Brussels': 'Europe/Vienna', + 'Europe/Budapest': 'Europe/Vienna', + 'Europe/Copenhagen': 'Europe/Vienna', + 'Europe/Gibraltar': 'Europe/Vienna', + 'Europe/Ljubljana': 'Europe/Vienna', + 'Europe/Luxembourg': 'Europe/Vienna', + 'Europe/Madrid': 'Europe/Vienna', + 'Europe/Malta': 'Europe/Vienna', + 'Europe/Monaco': 'Europe/Vienna', + 'Europe/Oslo': 'Europe/Vienna', + 'Europe/Paris': 'Europe/Vienna', + 'Europe/Podgorica': 'Europe/Vienna', + 'Europe/Prague': 'Europe/Vienna', + 'Europe/Rome': 'Europe/Vienna', + 'Europe/San_Marino': 'Europe/Vienna', + 'Europe/Sarajevo': 'Europe/Vienna', + 'Europe/Skopje': 'Europe/Vienna', + 'Europe/Stockholm': 'Europe/Vienna', + 'Europe/Tirane': 'Europe/Vienna', + 'Europe/Vaduz': 'Europe/Vienna', + 'Europe/Vatican': 'Europe/Vienna', + 'Europe/Vienna': 'Europe/Vienna', + 'Europe/Warsaw': 'Europe/Vienna', + 'Europe/Zagreb': 'Europe/Vienna', + 'Europe/Zurich': 'Europe/Vienna', + 'MET': 'Europe/Vienna', + 'Poland': 'Europe/Vienna', + /*+2:00*/ + 'ART': 'Asia/Jerusalem', + 'Africa/Blantyre': 'Asia/Jerusalem', + 'Africa/Bujumbura': 'Asia/Jerusalem', + 'Africa/Cairo': 'Asia/Jerusalem', + 'Africa/Gaborone': 'Asia/Jerusalem', + 'Africa/Harare': 'Asia/Jerusalem', + 'Africa/Johannesburg': 'Asia/Jerusalem', + 'Africa/Kigali': 'Asia/Jerusalem', + 'Africa/Lubumbashi': 'Asia/Jerusalem', + 'Africa/Lusaka': 'Asia/Jerusalem', + 'Africa/Maputo': 'Asia/Jerusalem', + 'Africa/Maseru': 'Asia/Jerusalem', + 'Africa/Mbabane': 'Asia/Jerusalem', + 'Africa/Tripoli': 'Asia/Jerusalem', + 'Asia/Amman': 'Asia/Jerusalem', + 'Asia/Beirut': 'Asia/Jerusalem', + 'Asia/Damascus': 'Asia/Jerusalem', + 'Asia/Gaza': 'Asia/Jerusalem', + 'Asia/Hebron': 'Asia/Jerusalem', + 'Asia/Istanbul': 'Asia/Jerusalem', + 'Asia/Jerusalem': 'Asia/Jerusalem', + 'Asia/Nicosia': 'Asia/Jerusalem', + 'Asia/Tel_Aviv': 'Asia/Jerusalem', + 'CAT': 'Asia/Jerusalem', + 'EET': 'Asia/Jerusalem', + 'Egypt': 'Asia/Jerusalem', + 'Etc/GMT-2': 'Asia/Jerusalem', + 'Europe/Athens': 'Asia/Jerusalem', + 'Europe/Bucharest': 'Asia/Jerusalem', + 'Europe/Chisinau': 'Asia/Jerusalem', + 'Europe/Helsinki': 'Asia/Jerusalem', + 'Europe/Istanbul': 'Asia/Jerusalem', + 'Europe/Kiev': 'Asia/Jerusalem', + 'Europe/Mariehamn': 'Asia/Jerusalem', + 'Europe/Nicosia': 'Asia/Jerusalem', + 'Europe/Riga': 'Asia/Jerusalem', + 'Europe/Simferopol': 'Asia/Jerusalem', + 'Europe/Sofia': 'Asia/Jerusalem', + 'Europe/Tallinn': 'Asia/Jerusalem', + 'Europe/Tiraspol': 'Asia/Jerusalem', + 'Europe/Uzhgorod': 'Asia/Jerusalem', + 'Europe/Vilnius': 'Asia/Jerusalem', + 'Europe/Zaporozhye': 'Asia/Jerusalem', + 'Israel': 'Asia/Jerusalem', + 'Libya': 'Asia/Jerusalem', + 'Turkey': 'Asia/Jerusalem', + /*+3:00*/ + 'Africa/Addis_Ababa': 'Africa/Addis_Ababa', + 'Africa/Asmara': 'Africa/Addis_Ababa', + 'Africa/Asmera': 'Africa/Addis_Ababa', + 'Africa/Dar_es_Salaam': 'Africa/Addis_Ababa', + 'Africa/Djibouti': 'Africa/Addis_Ababa', + 'Africa/Juba': 'Africa/Addis_Ababa', + 'Africa/Kampala': 'Africa/Addis_Ababa', + 'Africa/Khartoum': 'Africa/Addis_Ababa', + 'Africa/Mogadishu': 'Africa/Addis_Ababa', + 'Africa/Nairobi': 'Africa/Addis_Ababa', + 'Antarctica/Syowa': 'Africa/Addis_Ababa', + 'Asia/Aden': 'Africa/Addis_Ababa', + 'Asia/Baghdad': 'Africa/Addis_Ababa', + 'Asia/Bahrain': 'Africa/Addis_Ababa', + 'Asia/Kuwait': 'Africa/Addis_Ababa', + 'Asia/Qatar': 'Africa/Addis_Ababa', + 'Asia/Riyadh': 'Africa/Addis_Ababa', + 'EAT': 'Africa/Addis_Ababa', + 'Etc/GMT-3': 'Africa/Addis_Ababa', + 'Europe/Kaliningrad': 'Africa/Addis_Ababa', + 'Europe/Minsk': 'Africa/Addis_Ababa', + 'Indian/Antananarivo': 'Africa/Addis_Ababa', + 'Indian/Comoro': 'Africa/Addis_Ababa', + 'Indian/Mayotte': 'Africa/Addis_Ababa', + /*+3:30*/ + 'Asia/Tehran': 'Asia/Tehran', + 'Iran': 'Asia/Tehran', + /*+4:00*/ + 'Asia/Baku': 'Asia/Dubai', + 'Asia/Dubai': 'Asia/Dubai', + 'Asia/Muscat': 'Asia/Dubai', + 'Asia/Tbilisi': 'Asia/Dubai', + 'Asia/Yerevan': 'Asia/Dubai', + 'Etc/GMT-4': 'Asia/Dubai', + 'Europe/Moscow': 'Asia/Dubai', + 'Europe/Samara': 'Asia/Dubai', + 'Europe/Volgograd': 'Asia/Dubai', + 'Indian/Mahe': 'Asia/Dubai', + 'Indian/Mauritius': 'Asia/Dubai', + 'Indian/Reunion': 'Asia/Dubai', + 'NET': 'Asia/Dubai', + 'W-SU': 'Asia/Dubai', + /*+4:30*/ + 'Asia/Kabul': 'Asia/Kabul', + /*+5:00*/ + 'Antarctica/Mawson': 'Antarctica/Mawson', + 'Asia/Aqtau': 'Antarctica/Mawson', + 'Asia/Aqtobe': 'Antarctica/Mawson', + 'Asia/Ashgabat': 'Antarctica/Mawson', + 'Asia/Ashkhabad': 'Antarctica/Mawson', + 'Asia/Dushanbe': 'Antarctica/Mawson', + 'Asia/Karachi': 'Antarctica/Mawson', + 'Asia/Oral': 'Antarctica/Mawson', + 'Asia/Samarkand': 'Antarctica/Mawson', + 'Asia/Tashkent': 'Antarctica/Mawson', + 'Etc/GMT-5': 'Antarctica/Mawson', + 'Indian/Kerguelen': 'Antarctica/Mawson', + 'Indian/Maldives': 'Antarctica/Mawson', + 'PLT': 'Antarctica/Mawson', + /*+5:30*/ + 'Asia/Calcutta': 'Asia/Colombo', + 'Asia/Colombo': 'Asia/Colombo', + 'Asia/Kolkata': 'Asia/Colombo', + 'IST': 'Asia/Colombo', + /*+6:00*/ + 'Antarctica/Vostok': 'Antarctica/Vostok', + 'Asia/Almaty': 'Antarctica/Vostok', + 'Asia/Bishkek': 'Antarctica/Vostok', + 'Asia/Dacca': 'Antarctica/Vostok', + 'Asia/Dhaka': 'Antarctica/Vostok', + 'Asia/Qyzylorda': 'Antarctica/Vostok', + 'Asia/Thimbu': 'Antarctica/Vostok', + 'Asia/Thimphu': 'Antarctica/Vostok', + 'Asia/Yekaterinburg': 'Antarctica/Vostok', + 'BST': 'Antarctica/Vostok', + 'Etc/GMT-6': 'Antarctica/Vostok', + 'Indian/Chagos': 'Antarctica/Vostok', + /*+6:30*/ + 'Asia/Rangoon': 'Asia/Rangoon', + 'Indian/Cocos': 'Asia/Rangoon', + /*+7:00*/ + 'Antarctica/Davis': 'Antarctica/Davis', + 'Asia/Bangkok': 'Antarctica/Davis', + 'Asia/Ho_Chi_Minh': 'Antarctica/Davis', + 'Asia/Hovd': 'Antarctica/Davis', + 'Asia/Jakarta': 'Antarctica/Davis', + 'Asia/Novokuznetsk': 'Antarctica/Davis', + 'Asia/Novosibirsk': 'Antarctica/Davis', + 'Asia/Omsk': 'Antarctica/Davis', + 'Asia/Phnom_Penh': 'Antarctica/Davis', + 'Asia/Pontianak': 'Antarctica/Davis', + 'Asia/Saigon': 'Antarctica/Davis', + 'Asia/Vientiane': 'Antarctica/Davis', + 'Etc/GMT-7': 'Antarctica/Davis', + 'Indian/Christmas': 'Antarctica/Davis', + 'VST': 'Antarctica/Davis', + /*+8:00*/ + 'Antarctica/Casey': 'Antarctica/Casey', + 'Asia/Brunei': 'Antarctica/Casey', + 'Asia/Choibalsan': 'Antarctica/Casey', + 'Asia/Chongqing': 'Antarctica/Casey', + 'Asia/Chungking': 'Antarctica/Casey', + 'Asia/Harbin': 'Antarctica/Casey', + 'Asia/Hong_Kong': 'Antarctica/Casey', + 'Asia/Kashgar': 'Antarctica/Casey', + 'Asia/Krasnoyarsk': 'Antarctica/Casey', + 'Asia/Kuala_Lumpur': 'Antarctica/Casey', + 'Asia/Kuching': 'Antarctica/Casey', + 'Asia/Macao': 'Antarctica/Casey', + 'Asia/Macau': 'Antarctica/Casey', + 'Asia/Makassar': 'Antarctica/Casey', + 'Asia/Manila': 'Antarctica/Casey', + 'Asia/Shanghai': 'Antarctica/Casey', + 'Asia/Singapore': 'Antarctica/Casey', + 'Asia/Taipei': 'Antarctica/Casey', + 'Asia/Ujung_Pandang': 'Antarctica/Casey', + 'Asia/Ulaanbaatar': 'Antarctica/Casey', + 'Asia/Ulan_Bator': 'Antarctica/Casey', + 'Asia/Urumqi': 'Antarctica/Casey', + 'Australia/Perth': 'Antarctica/Casey', + 'Australia/West': 'Antarctica/Casey', + 'CTT': 'Antarctica/Casey', + 'Etc/GMT-8': 'Antarctica/Casey', + 'Hongkong': 'Antarctica/Casey', + 'PRC': 'Antarctica/Casey', + 'Singapore': 'Antarctica/Casey', + /*+9:00*/ + 'Asia/Dili': 'Asia/Dili', + 'Asia/Irkutsk': 'Asia/Dili', + 'Asia/Jayapura': 'Asia/Dili', + 'Asia/Pyongyang': 'Asia/Dili', + 'Asia/Seoul': 'Asia/Dili', + 'Asia/Tokyo': 'Asia/Dili', + 'Etc/GMT-9': 'Asia/Dili', + 'JST': 'Asia/Dili', + 'Japan': 'Asia/Dili', + 'Pacific/Palau': 'Asia/Dili', + 'ROK': 'Asia/Dili', + /*+9:30*/ + 'ACT': 'Australia/Darwin', + 'Australia/Adelaide': 'Australia/Darwin', + 'Australia/Broken_Hill': 'Australia/Darwin', + 'Australia/Darwin': 'Australia/Darwin', + 'Australia/North': 'Australia/Darwin', + 'Australia/South': 'Australia/Darwin', + 'Australia/Yancowinna': 'Australia/Darwin', + /*+10:00*/ + 'AET': 'Australia/Currie', + 'Antarctica/DumontDUrville': 'Australia/Currie', + 'Asia/Yakutsk': 'Australia/Currie', + 'Australia/ACT': 'Australia/Currie', + 'Australia/Brisbane': 'Australia/Currie', + 'Australia/Canberra': 'Australia/Currie', + 'Australia/Currie': 'Australia/Currie', + 'Australia/Hobart': 'Australia/Currie', + 'Australia/Lindeman': 'Australia/Currie', + 'Australia/Melbourne': 'Australia/Currie', + 'Australia/NSW': 'Australia/Currie', + 'Australia/Queensland': 'Australia/Currie', + 'Australia/Sydney': 'Australia/Currie', + 'Australia/Tasmania': 'Australia/Currie', + 'Australia/Victoria': 'Australia/Currie', + 'Etc/GMT-10': 'Australia/Currie', + 'Pacific/Chuuk': 'Australia/Currie', + 'Pacific/Guam': 'Australia/Currie', + 'Pacific/Port_Moresby': 'Australia/Currie', + 'Pacific/Saipan': 'Australia/Currie', + 'Pacific/Truk': 'Australia/Currie', + 'Pacific/Yap': 'Australia/Currie', + /*+10:30*/ + 'Australia/LHI': 'Australia/Lord_Howe', + 'Australia/Lord_Howe': 'Australia/Lord_Howe', + /*+11:00*/ + 'Antarctica/Macquarie': 'Antarctica/Macquarie', + 'Asia/Sakhalin': 'Antarctica/Macquarie', + 'Asia/Vladivostok': 'Antarctica/Macquarie', + 'Etc/GMT-11': 'Antarctica/Macquarie', + 'Pacific/Efate': 'Antarctica/Macquarie', + 'Pacific/Guadalcanal': 'Antarctica/Macquarie', + 'Pacific/Kosrae': 'Antarctica/Macquarie', + 'Pacific/Noumea': 'Antarctica/Macquarie', + 'Pacific/Pohnpei': 'Antarctica/Macquarie', + 'Pacific/Ponape': 'Antarctica/Macquarie', + 'SST': 'Antarctica/Macquarie', + /*+11:30*/ + 'Pacific/Norfolk': 'Pacific/Norfolk', + /*+12:00*/ + 'Antarctica/McMurdo': 'Antarctica/McMurdo', + 'Antarctica/South_Pole': 'Antarctica/McMurdo', + 'Asia/Anadyr': 'Antarctica/McMurdo', + 'Asia/Kamchatka': 'Antarctica/McMurdo', + 'Asia/Magadan': 'Antarctica/McMurdo', + 'Etc/GMT-12': 'Antarctica/McMurdo', + 'Kwajalein': 'Antarctica/McMurdo', + 'NST': 'Antarctica/McMurdo', + 'NZ': 'Antarctica/McMurdo', + 'Pacific/Auckland': 'Antarctica/McMurdo', + 'Pacific/Fiji': 'Antarctica/McMurdo', + 'Pacific/Funafuti': 'Antarctica/McMurdo', + 'Pacific/Kwajalein': 'Antarctica/McMurdo', + 'Pacific/Majuro': 'Antarctica/McMurdo', + 'Pacific/Nauru': 'Antarctica/McMurdo', + 'Pacific/Tarawa': 'Antarctica/McMurdo', + 'Pacific/Wake': 'Antarctica/McMurdo', + 'Pacific/Wallis': 'Antarctica/McMurdo', + /*+13:00*/ + 'Etc/GMT-13': 'Pacific/Enderbury', + 'MIT': 'Pacific/Enderbury', + 'Pacific/Apia': 'Pacific/Enderbury', + 'Pacific/Enderbury': 'Pacific/Enderbury', + 'Pacific/Tongatapu': 'Pacific/Enderbury', + /*+14:00*/ + 'Etc/GMT-14': 'Pacific/Kiritimati', + 'Pacific/Fakaofo': 'Pacific/Kiritimati', + 'Pacific/Kiritimati': 'Pacific/Kiritimati' + }, + + /* return unmapped timezone... */ + unMap: function (timezone) { + return this.map[timezone] !== undefined ? this.map[timezone] : timezone; + }, + + getOffset: function (timezone) { + /* find timezone, this needs to be optimized ;) */ + timezone = this.unMap(timezone); + var i = 0; + for (i = 0; i < this.store.length; i++) { + if (this.store[i][0] == timezone) { + return (this.store[i][2] * 60000); + } + } + + return 0; // no offset found... + } +}); + Zarafa.plugins.calendarimporter.data.Timezones = new Zarafa.plugins.calendarimporter.data.Timezones(); \ No newline at end of file diff --git a/js/dialogs/ImportContentPanel.js b/js/dialogs/ImportContentPanel.js index 37fe4b1..a18aeee 100644 --- a/js/dialogs/ImportContentPanel.js +++ b/js/dialogs/ImportContentPanel.js @@ -1,66 +1,66 @@ -/** - * ImportContentPanel.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/** - * ImportContentPanel - * - * Container for the importpanel. - */ -Ext.namespace("Zarafa.plugins.calendarimporter.dialogs"); - -/** - * @class Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel - * @extends Zarafa.core.ui.ContentPanel - * - * The content panel which shows the hierarchy tree of Owncloud account files. - * @xtype calendarimportercontentpanel - */ -Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, { - - /** - * @constructor - * @param config Configuration structure - */ - constructor: function (config) { - config = config || {}; - Ext.applyIf(config, { - layout: 'fit', - title: dgettext('plugin_calendarimporter', 'Import Calendar File'), - closeOnSave: true, - width: 800, - height: 700, - //Add panel - items: [ - { - xtype: 'calendarimporter.importpanel', - filename: config.filename, - folder: config.folder - } - ] - }); - - Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel.superclass.constructor.call(this, config); - } - -}); - +/** + * ImportContentPanel.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/** + * ImportContentPanel + * + * Container for the importpanel. + */ +Ext.namespace("Zarafa.plugins.calendarimporter.dialogs"); + +/** + * @class Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel + * @extends Zarafa.core.ui.ContentPanel + * + * The content panel which shows the hierarchy tree of Owncloud account files. + * @xtype calendarimportercontentpanel + */ +Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, { + + /** + * @constructor + * @param config Configuration structure + */ + constructor: function (config) { + config = config || {}; + Ext.applyIf(config, { + layout: 'fit', + title: dgettext('plugin_calendarimporter', 'Import Calendar File'), + closeOnSave: true, + width: 800, + height: 700, + //Add panel + items: [ + { + xtype: 'calendarimporter.importpanel', + filename: config.filename, + folder: config.folder + } + ] + }); + + Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel.superclass.constructor.call(this, config); + } + +}); + Ext.reg('calendarimporter.contentpanel', Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel); \ No newline at end of file diff --git a/js/external/Ext.util.base64.js b/js/external/Ext.util.base64.js index d6b9352..1f091ed 100644 --- a/js/external/Ext.util.base64.js +++ b/js/external/Ext.util.base64.js @@ -1,47 +1,47 @@ -Ext.util.base64 = { - base64s : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", - - encode: function(decStr){ - if (typeof btoa === 'function') { - return btoa(decStr); - } - var base64s = this.base64s; - var bits; - var dual; - var i = 0; - var encOut = ""; - while(decStr.length >= i + 3){ - bits = (decStr.charCodeAt(i++) & 0xff) <<16 | (decStr.charCodeAt(i++) & 0xff) <<8 | decStr.charCodeAt(i++) & 0xff; - encOut += base64s.charAt((bits & 0x00fc0000) >>18) + base64s.charAt((bits & 0x0003f000) >>12) + base64s.charAt((bits & 0x00000fc0) >> 6) + base64s.charAt((bits & 0x0000003f)); - } - if(decStr.length -i > 0 && decStr.length -i < 3){ - dual = Boolean(decStr.length -i -1); - bits = ((decStr.charCodeAt(i++) & 0xff) <<16) | (dual ? (decStr.charCodeAt(i) & 0xff) <<8 : 0); - encOut += base64s.charAt((bits & 0x00fc0000) >>18) + base64s.charAt((bits & 0x0003f000) >>12) + (dual ? base64s.charAt((bits & 0x00000fc0) >>6) : '=') + '='; - } - return(encOut); - }, - - decode: function(encStr){ - if (typeof atob === 'function') { - return atob(encStr); - } - var base64s = this.base64s; - var bits; - var decOut = ""; - var i = 0; - for(; i>16, (bits & 0xff00) >>8, bits & 0xff); - } - if(encStr.charCodeAt(i -2) == 61){ - return(decOut.substring(0, decOut.length -2)); - } - else if(encStr.charCodeAt(i -1) == 61){ - return(decOut.substring(0, decOut.length -1)); - } - else { - return(decOut); - } - } +Ext.util.base64 = { + base64s : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + + encode: function(decStr){ + if (typeof btoa === 'function') { + return btoa(decStr); + } + var base64s = this.base64s; + var bits; + var dual; + var i = 0; + var encOut = ""; + while(decStr.length >= i + 3){ + bits = (decStr.charCodeAt(i++) & 0xff) <<16 | (decStr.charCodeAt(i++) & 0xff) <<8 | decStr.charCodeAt(i++) & 0xff; + encOut += base64s.charAt((bits & 0x00fc0000) >>18) + base64s.charAt((bits & 0x0003f000) >>12) + base64s.charAt((bits & 0x00000fc0) >> 6) + base64s.charAt((bits & 0x0000003f)); + } + if(decStr.length -i > 0 && decStr.length -i < 3){ + dual = Boolean(decStr.length -i -1); + bits = ((decStr.charCodeAt(i++) & 0xff) <<16) | (dual ? (decStr.charCodeAt(i) & 0xff) <<8 : 0); + encOut += base64s.charAt((bits & 0x00fc0000) >>18) + base64s.charAt((bits & 0x0003f000) >>12) + (dual ? base64s.charAt((bits & 0x00000fc0) >>6) : '=') + '='; + } + return(encOut); + }, + + decode: function(encStr){ + if (typeof atob === 'function') { + return atob(encStr); + } + var base64s = this.base64s; + var bits; + var decOut = ""; + var i = 0; + for(; i>16, (bits & 0xff00) >>8, bits & 0xff); + } + if(encStr.charCodeAt(i -2) == 61){ + return(decOut.substring(0, decOut.length -2)); + } + else if(encStr.charCodeAt(i -1) == 61){ + return(decOut.substring(0, decOut.length -1)); + } + else { + return(decOut); + } + } } \ No newline at end of file diff --git a/js/plugin.calendarimporter.js b/js/plugin.calendarimporter.js index a5838f1..eec6411 100644 --- a/js/plugin.calendarimporter.js +++ b/js/plugin.calendarimporter.js @@ -1,306 +1,306 @@ -/** - * plugin.calendarimporter.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace - -Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin - - /** - * @constructor - * @param {Object} config Configuration object - * - */ - constructor: function (config) { - config = config || {}; - - Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config); - }, - - /** - * initialises insertion point for plugin - * @protected - */ - initPlugin: function () { - Zarafa.plugins.calendarimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments); - - /* our panel */ - Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.dialogs.importevents'); - - /* directly import received icals */ - this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton); - - /* add settings widget */ - this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsWidget); - - /* export a calendar entry via rightclick */ - this.registerInsertionPoint('context.calendar.contextmenu.actions', this.createItemExportInsertionPoint, this); - - /* ical sync stuff */ - if (container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_sync") === true) { - /* edit panel */ - Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.settings.dialogs.calsyncedit'); - - /* enable the settings widget */ - this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsCalSyncWidget); - } - }, - - /** - * This method hooks to the contact context menu and allows users to export users to vcf. - * - * @param include - * @param btn - * @returns {Object} - */ - createItemExportInsertionPoint: function (include, btn) { - return { - text: dgettext('plugin_calendarimporter', 'Export Event'), - handler: this.exportToICS.createDelegate(this, [btn]), - scope: this, - iconCls: 'icon_calendarimporter_export' - }; - }, - - /** - * Generates a request to download the selected records as vCard. - * @param {Ext.Button} btn - */ - exportToICS: function (btn) { - if (btn.records.length == 0) { - return; // skip if no records where given! - } - - var recordIds = []; - - for (var i = 0; i < btn.records.length; i++) { - recordIds.push(btn.records[i].get("entryid")); - } - - Zarafa.plugins.calendarimporter.data.Actions.exportToICS(btn.records[0].get("store_entryid"), recordIds, undefined); - }, - - /** - * Creates the button - * - * @return {Object} Configuration object for a {@link Ext.Button button} - * - */ - createSettingsWidget: function () { - return [{ - xtype: 'calendarimporter.settingswidget' - }]; - }, - - /** - * Creates the button - * - * @return {Object} Configuration object for a {@link Ext.Button button} - * - */ - createSettingsCalSyncWidget: function () { - return [{ - xtype: 'calendarimporter.settingscalsyncwidget' - }]; - }, - - /** - * Insert import button in all attachment suggestions - - * @return {Object} Configuration object for a {@link Ext.Button button} - */ - createAttachmentImportButton: function (include, btn) { - return { - text: dgettext('plugin_calendarimporter', 'Import to Calendar'), - handler: this.getAttachmentFileName.createDelegate(this, [btn]), - scope: this, - iconCls: 'icon_calendarimporter_button', - beforeShow: function (item, record) { - var extension = record.data.name.split('.').pop().toLowerCase(); - - if (record.data.filetype == "text/calendar" || extension == "ics" || extension == "ifb" || extension == "ical" || extension == "ifbf") { - item.setVisible(true); - } else { - item.setVisible(false); - } - } - }; - }, - - /** - * Callback for getAttachmentFileName - */ - gotAttachmentFileName: function (response) { - if (response.status == true) { - this.scope.openImportDialog(response.tmpname); - } else { - Zarafa.common.dialogs.MessageBox.show({ - title: dgettext('plugin_calendarimporter', 'Error'), - msg: response["message"], - icon: Zarafa.common.dialogs.MessageBox.ERROR, - buttons: Zarafa.common.dialogs.MessageBox.OK - }); - } - }, - - /** - * Clickhandler for the button - */ - getAttachmentFileName: function (btn, callback) { - Zarafa.common.dialogs.MessageBox.show({ - title: dgettext('plugin_calendarimporter', 'Please wait'), - msg: dgettext('plugin_calendarimporter', 'Loading attachment...'), - progressText: dgettext('plugin_calendarimporter', 'Initializing...'), - width: 300, - progress: true, - closable: false - }); - - // progress bar... ;) - var f = function (v) { - return function () { - if (v == 100) { - Zarafa.common.dialogs.MessageBox.hide(); - } else { - // # TRANSLATORS: {0} will be replaced by the percentage value (0-100) - Zarafa.common.dialogs.MessageBox.updateProgress(v / 100, String.format(dgettext('plugin_calendarimporter', '{0}% loaded'), Math.round(v))); - } - }; - }; - - for (var i = 1; i < 101; i++) { - setTimeout(f(i), 20 * i); - } - - /* store the attachment to a temporary folder and prepare it for uploading */ - var attachmentRecord = btn.records; - var attachmentStore = attachmentRecord.store; - - var store = attachmentStore.getParentRecord().get('store_entryid'); - var entryid = attachmentStore.getAttachmentParentRecordEntryId(); - var attachNum = new Array(1); - if (attachmentRecord.get('attach_num') != -1) { - attachNum[0] = attachmentRecord.get('attach_num'); - } else { - attachNum[0] = attachmentRecord.get('tmpname'); - } - var dialog_attachments = attachmentStore.getId(); - var filename = attachmentRecord.data.name; - - var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({ - successCallback: this.gotAttachmentFileName, - scope: this - }); - - // request attachment preperation - container.getRequest().singleRequest( - 'calendarmodule', - 'importattachment', - { - entryid: entryid, - store: store, - attachNum: attachNum, - dialog_attachments: dialog_attachments, - filename: filename - }, - responseHandler - ); - }, - - /** - * Open the import dialog. - * @param {String} filename - */ - openImportDialog: function (filename) { - var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']; - var config = { - filename: filename, - modal: true - }; - - Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config); - }, - - /** - * Bid for the type of shared component - * and the given record. - * This will bid on calendar.dialogs.importevents - * @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for. - * @param {Ext.data.Record} record Optionally passed record. - * @return {Number} The bid for the shared component - */ - bidSharedComponent: function (type, record) { - var bid = -1; - switch (type) { - case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: - bid = 2; - break; - case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: - bid = 2; - break; - case Zarafa.core.data.SharedComponentType['common.contextmenu']: - if (record instanceof Zarafa.core.data.MAPIRecord) { - if (record.get('object_type') == Zarafa.core.mapi.ObjectType.MAPI_FOLDER && record.get('container_class') == "IPF.Appointment") { - bid = 2; - } - } - break; - } - return bid; - }, - - /** - * Will return the reference to the shared component. - * Based on the type of component requested a component is returned. - * @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for. - * @param {Ext.data.Record} record Optionally passed record. - * @return {Ext.Component} Component - */ - getSharedComponent: function (type, record) { - var component; - switch (type) { - case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: - component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel; - break; - case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: - component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel; - break; - case Zarafa.core.data.SharedComponentType['common.contextmenu']: - component = Zarafa.plugins.calendarimporter.ui.ContextMenu; - break; - } - - return component; - } -}); - - -/*############################################################################################################################* - * STARTUP - *############################################################################################################################*/ -Zarafa.onReady(function () { - container.registerPlugin(new Zarafa.core.PluginMetaData({ - name: 'calendarimporter', - displayName: dgettext('plugin_calendarimporter', 'Calendarimporter Plugin'), - about: Zarafa.plugins.calendarimporter.ABOUT, - pluginConstructor: Zarafa.plugins.calendarimporter.ImportPlugin - })); -}); +/** + * plugin.calendarimporter.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace + +Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin + + /** + * @constructor + * @param {Object} config Configuration object + * + */ + constructor: function (config) { + config = config || {}; + + Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config); + }, + + /** + * initialises insertion point for plugin + * @protected + */ + initPlugin: function () { + Zarafa.plugins.calendarimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments); + + /* our panel */ + Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.dialogs.importevents'); + + /* directly import received icals */ + this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton); + + /* add settings widget */ + this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsWidget); + + /* export a calendar entry via rightclick */ + this.registerInsertionPoint('context.calendar.contextmenu.actions', this.createItemExportInsertionPoint, this); + + /* ical sync stuff */ + if (container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_sync") === true) { + /* edit panel */ + Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.settings.dialogs.calsyncedit'); + + /* enable the settings widget */ + this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsCalSyncWidget); + } + }, + + /** + * This method hooks to the contact context menu and allows users to export users to vcf. + * + * @param include + * @param btn + * @returns {Object} + */ + createItemExportInsertionPoint: function (include, btn) { + return { + text: dgettext('plugin_calendarimporter', 'Export Event'), + handler: this.exportToICS.createDelegate(this, [btn]), + scope: this, + iconCls: 'icon_calendarimporter_export' + }; + }, + + /** + * Generates a request to download the selected records as vCard. + * @param {Ext.Button} btn + */ + exportToICS: function (btn) { + if (btn.records.length == 0) { + return; // skip if no records where given! + } + + var recordIds = []; + + for (var i = 0; i < btn.records.length; i++) { + recordIds.push(btn.records[i].get("entryid")); + } + + Zarafa.plugins.calendarimporter.data.Actions.exportToICS(btn.records[0].get("store_entryid"), recordIds, undefined); + }, + + /** + * Creates the button + * + * @return {Object} Configuration object for a {@link Ext.Button button} + * + */ + createSettingsWidget: function () { + return [{ + xtype: 'calendarimporter.settingswidget' + }]; + }, + + /** + * Creates the button + * + * @return {Object} Configuration object for a {@link Ext.Button button} + * + */ + createSettingsCalSyncWidget: function () { + return [{ + xtype: 'calendarimporter.settingscalsyncwidget' + }]; + }, + + /** + * Insert import button in all attachment suggestions + + * @return {Object} Configuration object for a {@link Ext.Button button} + */ + createAttachmentImportButton: function (include, btn) { + return { + text: dgettext('plugin_calendarimporter', 'Import to Calendar'), + handler: this.getAttachmentFileName.createDelegate(this, [btn]), + scope: this, + iconCls: 'icon_calendarimporter_button', + beforeShow: function (item, record) { + var extension = record.data.name.split('.').pop().toLowerCase(); + + if (record.data.filetype == "text/calendar" || extension == "ics" || extension == "ifb" || extension == "ical" || extension == "ifbf") { + item.setVisible(true); + } else { + item.setVisible(false); + } + } + }; + }, + + /** + * Callback for getAttachmentFileName + */ + gotAttachmentFileName: function (response) { + if (response.status == true) { + this.scope.openImportDialog(response.tmpname); + } else { + Zarafa.common.dialogs.MessageBox.show({ + title: dgettext('plugin_calendarimporter', 'Error'), + msg: response["message"], + icon: Zarafa.common.dialogs.MessageBox.ERROR, + buttons: Zarafa.common.dialogs.MessageBox.OK + }); + } + }, + + /** + * Clickhandler for the button + */ + getAttachmentFileName: function (btn, callback) { + Zarafa.common.dialogs.MessageBox.show({ + title: dgettext('plugin_calendarimporter', 'Please wait'), + msg: dgettext('plugin_calendarimporter', 'Loading attachment...'), + progressText: dgettext('plugin_calendarimporter', 'Initializing...'), + width: 300, + progress: true, + closable: false + }); + + // progress bar... ;) + var f = function (v) { + return function () { + if (v == 100) { + Zarafa.common.dialogs.MessageBox.hide(); + } else { + // # TRANSLATORS: {0} will be replaced by the percentage value (0-100) + Zarafa.common.dialogs.MessageBox.updateProgress(v / 100, String.format(dgettext('plugin_calendarimporter', '{0}% loaded'), Math.round(v))); + } + }; + }; + + for (var i = 1; i < 101; i++) { + setTimeout(f(i), 20 * i); + } + + /* store the attachment to a temporary folder and prepare it for uploading */ + var attachmentRecord = btn.records; + var attachmentStore = attachmentRecord.store; + + var store = attachmentStore.getParentRecord().get('store_entryid'); + var entryid = attachmentStore.getAttachmentParentRecordEntryId(); + var attachNum = new Array(1); + if (attachmentRecord.get('attach_num') != -1) { + attachNum[0] = attachmentRecord.get('attach_num'); + } else { + attachNum[0] = attachmentRecord.get('tmpname'); + } + var dialog_attachments = attachmentStore.getId(); + var filename = attachmentRecord.data.name; + + var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({ + successCallback: this.gotAttachmentFileName, + scope: this + }); + + // request attachment preperation + container.getRequest().singleRequest( + 'calendarmodule', + 'importattachment', + { + entryid: entryid, + store: store, + attachNum: attachNum, + dialog_attachments: dialog_attachments, + filename: filename + }, + responseHandler + ); + }, + + /** + * Open the import dialog. + * @param {String} filename + */ + openImportDialog: function (filename) { + var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']; + var config = { + filename: filename, + modal: true + }; + + Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config); + }, + + /** + * Bid for the type of shared component + * and the given record. + * This will bid on calendar.dialogs.importevents + * @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for. + * @param {Ext.data.Record} record Optionally passed record. + * @return {Number} The bid for the shared component + */ + bidSharedComponent: function (type, record) { + var bid = -1; + switch (type) { + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: + bid = 2; + break; + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: + bid = 2; + break; + case Zarafa.core.data.SharedComponentType['common.contextmenu']: + if (record instanceof Zarafa.core.data.MAPIRecord) { + if (record.get('object_type') == Zarafa.core.mapi.ObjectType.MAPI_FOLDER && record.get('container_class') == "IPF.Appointment") { + bid = 2; + } + } + break; + } + return bid; + }, + + /** + * Will return the reference to the shared component. + * Based on the type of component requested a component is returned. + * @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for. + * @param {Ext.data.Record} record Optionally passed record. + * @return {Ext.Component} Component + */ + getSharedComponent: function (type, record) { + var component; + switch (type) { + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: + component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel; + break; + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: + component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel; + break; + case Zarafa.core.data.SharedComponentType['common.contextmenu']: + component = Zarafa.plugins.calendarimporter.ui.ContextMenu; + break; + } + + return component; + } +}); + + +/*############################################################################################################################* + * STARTUP + *############################################################################################################################*/ +Zarafa.onReady(function () { + container.registerPlugin(new Zarafa.core.PluginMetaData({ + name: 'calendarimporter', + displayName: dgettext('plugin_calendarimporter', 'Calendarimporter Plugin'), + about: Zarafa.plugins.calendarimporter.ABOUT, + pluginConstructor: Zarafa.plugins.calendarimporter.ImportPlugin + })); +}); diff --git a/js/settings/SettingsCalSyncWidget.js b/js/settings/SettingsCalSyncWidget.js index 4f7a19c..058266d 100644 --- a/js/settings/SettingsCalSyncWidget.js +++ b/js/settings/SettingsCalSyncWidget.js @@ -1,136 +1,136 @@ -/** - * SettingsCalSyncWidget.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace('Zarafa.plugins.calendarimporter.settings'); - -/** - * @class Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget - * @extends Zarafa.settings.ui.SettingsWidget - * @xtype calendarimporter.settingscalsyncwidget - * - */ -Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { - /** - * @cfg {Zarafa.settings.SettingsContext} settingsContext - */ - settingsContext: undefined, - - /** - * @constructor - * @param {Object} config Configuration object - */ - constructor: function (config) { - config = config || {}; - - var store = new Ext.data.JsonStore({ - fields: [ - {name: 'id', type: 'int'}, - {name: 'icsurl'}, - {name: 'user'}, - {name: 'pass'}, - {name: 'intervall', type: 'int'}, - {name: 'calendar'}, - {name: 'calendarname'}, - {name: 'lastsync'} - ], - sortInfo: { - field: 'id', - direction: 'ASC' - }, - autoDestroy: true - }); - - Ext.applyIf(config, { - height: 400, - title: dgettext('plugin_calendarimporter', 'Calendar Sync settings'), - xtype: 'calendarimporter.settingscalsyncwidget', - layout: { - // override from SettingsWidget - type: 'fit' - }, - items: [{ - xtype: 'calendarimporter.calsyncpanel', - store: store, - ref: 'calsyncPanel' - }] - }); - - Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget.superclass.constructor.call(this, config); - }, - - /** - * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when - * it has been called with {@link zarafa.settings.ui.SettingsCategory#update}. - * This is used to load the latest version of the settings from the - * {@link Zarafa.settings.SettingsModel} into the UI of this category. - * @param {Zarafa.settings.SettingsModel} settingsModel The settings to load - */ - update: function (settingsModel) { - this.model = settingsModel; - - // Convert the signatures into Store data - var icslinks = settingsModel.get('zarafa/v1/contexts/calendar/icssync', true); - var syncArray = []; - for (var key in icslinks) { - if (icslinks.hasOwnProperty(key)) { // skip inherited props - syncArray.push(Ext.apply({}, icslinks[key], {id: key})); - } - } - - // Load all icslinks into the GridPanel - var store = this.calsyncPanel.calsyncGrid.getStore(); - store.loadData(syncArray); - }, - - /** - * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when - * it has been called with {@link zarafa.settings.ui.SettingsCategory#updateSettings}. - * This is used to update the settings from the UI into the {@link Zarafa.settings.SettingsModel settings model}. - * @param {Zarafa.settings.SettingsModel} settingsModel The settings to update - */ - updateSettings: function (settingsModel) { - settingsModel.beginEdit(); - - // Start reading the Grid store and convert the contents back into - // an object which can be pushed to the settings. - var icslinks = this.calsyncPanel.calsyncGrid.getStore().getRange(); - var icslinkData = {}; - for (var i = 0, len = icslinks.length; i < len; i++) { - var icslink = icslinks[i]; - - icslinkData[icslink.get('id')] = { - 'icsurl': icslink.get('icsurl'), - 'intervall': icslink.get('intervall'), - 'user': icslink.get('user'), - 'pass': icslink.get('pass'), - 'lastsync': icslink.get('lastsync'), - 'calendar': icslink.get('calendar'), - 'calendarname': Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(icslink.get('calendar')).display_name - }; - } - settingsModel.set('zarafa/v1/contexts/calendar/icssync', icslinkData); - - settingsModel.endEdit(); - } -}); - +/** + * SettingsCalSyncWidget.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace('Zarafa.plugins.calendarimporter.settings'); + +/** + * @class Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget + * @extends Zarafa.settings.ui.SettingsWidget + * @xtype calendarimporter.settingscalsyncwidget + * + */ +Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { + /** + * @cfg {Zarafa.settings.SettingsContext} settingsContext + */ + settingsContext: undefined, + + /** + * @constructor + * @param {Object} config Configuration object + */ + constructor: function (config) { + config = config || {}; + + var store = new Ext.data.JsonStore({ + fields: [ + {name: 'id', type: 'int'}, + {name: 'icsurl'}, + {name: 'user'}, + {name: 'pass'}, + {name: 'intervall', type: 'int'}, + {name: 'calendar'}, + {name: 'calendarname'}, + {name: 'lastsync'} + ], + sortInfo: { + field: 'id', + direction: 'ASC' + }, + autoDestroy: true + }); + + Ext.applyIf(config, { + height: 400, + title: dgettext('plugin_calendarimporter', 'Calendar Sync settings'), + xtype: 'calendarimporter.settingscalsyncwidget', + layout: { + // override from SettingsWidget + type: 'fit' + }, + items: [{ + xtype: 'calendarimporter.calsyncpanel', + store: store, + ref: 'calsyncPanel' + }] + }); + + Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget.superclass.constructor.call(this, config); + }, + + /** + * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when + * it has been called with {@link zarafa.settings.ui.SettingsCategory#update}. + * This is used to load the latest version of the settings from the + * {@link Zarafa.settings.SettingsModel} into the UI of this category. + * @param {Zarafa.settings.SettingsModel} settingsModel The settings to load + */ + update: function (settingsModel) { + this.model = settingsModel; + + // Convert the signatures into Store data + var icslinks = settingsModel.get('zarafa/v1/contexts/calendar/icssync', true); + var syncArray = []; + for (var key in icslinks) { + if (icslinks.hasOwnProperty(key)) { // skip inherited props + syncArray.push(Ext.apply({}, icslinks[key], {id: key})); + } + } + + // Load all icslinks into the GridPanel + var store = this.calsyncPanel.calsyncGrid.getStore(); + store.loadData(syncArray); + }, + + /** + * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when + * it has been called with {@link zarafa.settings.ui.SettingsCategory#updateSettings}. + * This is used to update the settings from the UI into the {@link Zarafa.settings.SettingsModel settings model}. + * @param {Zarafa.settings.SettingsModel} settingsModel The settings to update + */ + updateSettings: function (settingsModel) { + settingsModel.beginEdit(); + + // Start reading the Grid store and convert the contents back into + // an object which can be pushed to the settings. + var icslinks = this.calsyncPanel.calsyncGrid.getStore().getRange(); + var icslinkData = {}; + for (var i = 0, len = icslinks.length; i < len; i++) { + var icslink = icslinks[i]; + + icslinkData[icslink.get('id')] = { + 'icsurl': icslink.get('icsurl'), + 'intervall': icslink.get('intervall'), + 'user': icslink.get('user'), + 'pass': icslink.get('pass'), + 'lastsync': icslink.get('lastsync'), + 'calendar': icslink.get('calendar'), + 'calendarname': Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(icslink.get('calendar')).display_name + }; + } + settingsModel.set('zarafa/v1/contexts/calendar/icssync', icslinkData); + + settingsModel.endEdit(); + } +}); + Ext.reg('calendarimporter.settingscalsyncwidget', Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget); \ No newline at end of file diff --git a/js/settings/SettingsWidget.js b/js/settings/SettingsWidget.js index c087fcc..d85909f 100644 --- a/js/settings/SettingsWidget.js +++ b/js/settings/SettingsWidget.js @@ -1,230 +1,230 @@ -/** - * SettingsWidget.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace('Zarafa.plugins.calendarimporter.settings'); - -/** - * @class Zarafa.plugins.calendarimporter.settings.SettingsWidget - * @extends Zarafa.settings.ui.SettingsWidget - * @xtype calendarimporter.settingswidget - * - */ -Zarafa.plugins.calendarimporter.settings.SettingsWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { - /** - * @cfg {Zarafa.settings.SettingsContext} settingsContext - */ - settingsContext: undefined, - - /** - * @constructor - * @param {Object} config Configuration object - */ - constructor: function (config) { - config = config || {}; - - Ext.applyIf(config, { - title: dgettext('plugin_calendarimporter', 'Calendar Import/Export plugin settings'), - xtype: 'calendarimporter.settingswidget', - items: [ - { - xtype: 'checkbox', - name: 'zarafa/v1/plugins/calendarimporter/enable_sync', - ref: 'enableSync', - fieldLabel: dgettext('plugin_calendarimporter', 'Enable ical sync'), - lazyInit: false - }, - this.createSelectBox(), - this.createTimezoneBox() - ] - }); - - Zarafa.plugins.calendarimporter.settings.SettingsWidget.superclass.constructor.call(this, config); - }, - - createSelectBox: function () { - var myStore = Zarafa.plugins.calendarimporter.data.Actions.getAllCalendarFolders(true); - - return { - xtype: "selectbox", - ref: 'defaultCalendar', - editable: false, - name: "zarafa/v1/plugins/calendarimporter/default_calendar", - value: Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByName(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_calendar")).entryid, - width: 100, - fieldLabel: dgettext('plugin_calendarimporter', 'Default calender'), - store: myStore, - mode: 'local', - labelSeperator: ":", - border: false, - anchor: "100%", - scope: this, - allowBlank: false - } - }, - - createTimezoneBox: function () { - return { - xtype: "selectbox", - ref: 'defaultTimezone', - editable: false, - name: "zarafa/v1/plugins/calendarimporter/default_timezone", - value: Zarafa.plugins.calendarimporter.data.Timezones.unMap(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_timezone")), - width: 100, - fieldLabel: dgettext('plugin_calendarimporter', 'Default timezone'), - store: Zarafa.plugins.calendarimporter.data.Timezones.store, - labelSeperator: ":", - mode: 'local', - border: false, - anchor: "100%", - scope: this, - allowBlank: false - } - }, - - /** - * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when - * it has been called with {@link zarafa.settings.ui.SettingsCategory#update}. - * This is used to load the latest version of the settings from the - * {@link Zarafa.settings.SettingsModel} into the UI of this category. - * @param {Zarafa.settings.SettingsModel} settingsModel The settings to load - */ - update: function (settingsModel) { - this.enableSync.setValue(settingsModel.get(this.enableSync.name)); - this.defaultCalendar.setValue(Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByName(settingsModel.get(this.defaultCalendar.name)).entryid); - this.defaultTimezone.setValue(settingsModel.get(this.defaultTimezone.name)); - }, - - /** - * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when - * it has been called with {@link zarafa.settings.ui.SettingsCategory#updateSettings}. - * This is used to update the settings from the UI into the {@link Zarafa.settings.SettingsModel settings model}. - * @param {Zarafa.settings.SettingsModel} settingsModel The settings to update - */ - updateSettings: function (settingsModel) { - // check if the user changed a value - var changed = false; - - if (settingsModel.get(this.enableSync.name) != this.enableSync.getValue()) { - changed = true; - } else if (settingsModel.get(this.defaultCalendar.name) != Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.defaultCalendar.getValue()).display_name) { - changed = true; - } else if (settingsModel.get(this.defaultTimezone.name) != this.defaultTimezone.getValue()) { - changed = true; - } - - if (changed) { - // Really save changes - settingsModel.set(this.enableSync.name, this.enableSync.getValue()); - settingsModel.set(this.defaultCalendar.name, Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.defaultCalendar.getValue()).display_name); // store name - settingsModel.set(this.defaultTimezone.name, this.defaultTimezone.getValue()); - - this.onUpdateSettings(); - } - }, - - /** - * Called after the {@link Zarafa.settings.SettingsModel} fires the {@link Zarafa.settings.SettingsModel#save save} - * event to indicate the settings were successfully saved and it will forcefully realod the webapp. - * settings which were saved to the server. - * @private - */ - onUpdateSettings: function () { - var message = _('Your WebApp needs to be reloaded to make the changes visible!'); - message += '

'; - message += _('WebApp will automatically restart in order for these changes to take effect'); - message += '
'; - - Zarafa.common.dialogs.MessageBox.addCustomButtons({ - title: _('Restart WebApp'), - msg: message, - icon: Ext.MessageBox.QUESTION, - fn: this.restartWebapp, - customButton: [{ - text: _('Restart'), - name: 'restart' - }, { - text: _('Cancel'), - name: 'cancel' - }], - scope: this - }); - - }, - - /** - * Event handler for {@link #onResetSettings}. This will check if the user - * wishes to reset the default settings or not. - * @param {String} button The button which user pressed. - * @private - */ - restartWebapp: function (button) { - if (button === 'restart') { - var contextModel = this.ownerCt.settingsContext.getModel(); - var realModel = contextModel.getRealSettingsModel(); - - realModel.save(); - - this.loadMask = new Zarafa.common.ui.LoadMask(Ext.getBody(), { - msg: '' + _('Webapp is reloading, Please wait.') + '' - }); - this.loadMask.show(); - - this.mon(realModel, 'save', this.onSettingsSave, this); - this.mon(realModel, 'exception', this.onSettingsException, this); - } - - }, - - /** - * Called when the {@link Zarafa.settings.} fires the {@link Zarafa.settings.SettingsModel#save save} - * event to indicate the settings were successfully saved and it will forcefully realod the webapp. - * @param {Zarafa.settings.SettingsModel} model The model which fired the event. - * @param {Object} parameters The key-value object containing the action and the corresponding - * settings which were saved to the server. - * @private - */ - onSettingsSave: function (model, parameters) { - this.mun(model, 'save', this.onSettingsSave, this); - Zarafa.core.Util.reloadWebapp(); - }, - - /** - * Called when the {@link Zarafa.settings.SettingsModel} fires the {@link Zarafa.settings.SettingsModel#exception exception} - * event to indicate the settings were not successfully saved. - * @param {Zarafa.settings.SettingsModel} model The settings model which fired the event - * @param {String} type The value of this parameter will be either 'response' or 'remote'. - * @param {String} action Name of the action (see {@link Ext.data.Api#actions}). - * @param {Object} options The object containing a 'path' and 'value' field indicating - * respectively the Setting and corresponding value for the setting which was being saved. - * @param {Object} response The response object as received from the PHP-side - * @private - */ - onSettingsException: function (model, type, action, options, response) { - this.loadMask.hide(); - - // Remove event handlers - this.mun(model, 'save', this.onSettingsSave, this); - this.mun(model, 'exception', this.onSettingsException, this); - } -}); - -Ext.reg('calendarimporter.settingswidget', Zarafa.plugins.calendarimporter.settings.SettingsWidget); +/** + * SettingsWidget.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace('Zarafa.plugins.calendarimporter.settings'); + +/** + * @class Zarafa.plugins.calendarimporter.settings.SettingsWidget + * @extends Zarafa.settings.ui.SettingsWidget + * @xtype calendarimporter.settingswidget + * + */ +Zarafa.plugins.calendarimporter.settings.SettingsWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { + /** + * @cfg {Zarafa.settings.SettingsContext} settingsContext + */ + settingsContext: undefined, + + /** + * @constructor + * @param {Object} config Configuration object + */ + constructor: function (config) { + config = config || {}; + + Ext.applyIf(config, { + title: dgettext('plugin_calendarimporter', 'Calendar Import/Export plugin settings'), + xtype: 'calendarimporter.settingswidget', + items: [ + { + xtype: 'checkbox', + name: 'zarafa/v1/plugins/calendarimporter/enable_sync', + ref: 'enableSync', + fieldLabel: dgettext('plugin_calendarimporter', 'Enable ical sync'), + lazyInit: false + }, + this.createSelectBox(), + this.createTimezoneBox() + ] + }); + + Zarafa.plugins.calendarimporter.settings.SettingsWidget.superclass.constructor.call(this, config); + }, + + createSelectBox: function () { + var myStore = Zarafa.plugins.calendarimporter.data.Actions.getAllCalendarFolders(true); + + return { + xtype: "selectbox", + ref: 'defaultCalendar', + editable: false, + name: "zarafa/v1/plugins/calendarimporter/default_calendar", + value: Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByName(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_calendar")).entryid, + width: 100, + fieldLabel: dgettext('plugin_calendarimporter', 'Default calender'), + store: myStore, + mode: 'local', + labelSeperator: ":", + border: false, + anchor: "100%", + scope: this, + allowBlank: false + } + }, + + createTimezoneBox: function () { + return { + xtype: "selectbox", + ref: 'defaultTimezone', + editable: false, + name: "zarafa/v1/plugins/calendarimporter/default_timezone", + value: Zarafa.plugins.calendarimporter.data.Timezones.unMap(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_timezone")), + width: 100, + fieldLabel: dgettext('plugin_calendarimporter', 'Default timezone'), + store: Zarafa.plugins.calendarimporter.data.Timezones.store, + labelSeperator: ":", + mode: 'local', + border: false, + anchor: "100%", + scope: this, + allowBlank: false + } + }, + + /** + * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when + * it has been called with {@link zarafa.settings.ui.SettingsCategory#update}. + * This is used to load the latest version of the settings from the + * {@link Zarafa.settings.SettingsModel} into the UI of this category. + * @param {Zarafa.settings.SettingsModel} settingsModel The settings to load + */ + update: function (settingsModel) { + this.enableSync.setValue(settingsModel.get(this.enableSync.name)); + this.defaultCalendar.setValue(Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByName(settingsModel.get(this.defaultCalendar.name)).entryid); + this.defaultTimezone.setValue(settingsModel.get(this.defaultTimezone.name)); + }, + + /** + * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when + * it has been called with {@link zarafa.settings.ui.SettingsCategory#updateSettings}. + * This is used to update the settings from the UI into the {@link Zarafa.settings.SettingsModel settings model}. + * @param {Zarafa.settings.SettingsModel} settingsModel The settings to update + */ + updateSettings: function (settingsModel) { + // check if the user changed a value + var changed = false; + + if (settingsModel.get(this.enableSync.name) != this.enableSync.getValue()) { + changed = true; + } else if (settingsModel.get(this.defaultCalendar.name) != Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.defaultCalendar.getValue()).display_name) { + changed = true; + } else if (settingsModel.get(this.defaultTimezone.name) != this.defaultTimezone.getValue()) { + changed = true; + } + + if (changed) { + // Really save changes + settingsModel.set(this.enableSync.name, this.enableSync.getValue()); + settingsModel.set(this.defaultCalendar.name, Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.defaultCalendar.getValue()).display_name); // store name + settingsModel.set(this.defaultTimezone.name, this.defaultTimezone.getValue()); + + this.onUpdateSettings(); + } + }, + + /** + * Called after the {@link Zarafa.settings.SettingsModel} fires the {@link Zarafa.settings.SettingsModel#save save} + * event to indicate the settings were successfully saved and it will forcefully realod the webapp. + * settings which were saved to the server. + * @private + */ + onUpdateSettings: function () { + var message = _('Your WebApp needs to be reloaded to make the changes visible!'); + message += '

'; + message += _('WebApp will automatically restart in order for these changes to take effect'); + message += '
'; + + Zarafa.common.dialogs.MessageBox.addCustomButtons({ + title: _('Restart WebApp'), + msg: message, + icon: Ext.MessageBox.QUESTION, + fn: this.restartWebapp, + customButton: [{ + text: _('Restart'), + name: 'restart' + }, { + text: _('Cancel'), + name: 'cancel' + }], + scope: this + }); + + }, + + /** + * Event handler for {@link #onResetSettings}. This will check if the user + * wishes to reset the default settings or not. + * @param {String} button The button which user pressed. + * @private + */ + restartWebapp: function (button) { + if (button === 'restart') { + var contextModel = this.ownerCt.settingsContext.getModel(); + var realModel = contextModel.getRealSettingsModel(); + + realModel.save(); + + this.loadMask = new Zarafa.common.ui.LoadMask(Ext.getBody(), { + msg: '' + _('Webapp is reloading, Please wait.') + '' + }); + this.loadMask.show(); + + this.mon(realModel, 'save', this.onSettingsSave, this); + this.mon(realModel, 'exception', this.onSettingsException, this); + } + + }, + + /** + * Called when the {@link Zarafa.settings.} fires the {@link Zarafa.settings.SettingsModel#save save} + * event to indicate the settings were successfully saved and it will forcefully realod the webapp. + * @param {Zarafa.settings.SettingsModel} model The model which fired the event. + * @param {Object} parameters The key-value object containing the action and the corresponding + * settings which were saved to the server. + * @private + */ + onSettingsSave: function (model, parameters) { + this.mun(model, 'save', this.onSettingsSave, this); + Zarafa.core.Util.reloadWebapp(); + }, + + /** + * Called when the {@link Zarafa.settings.SettingsModel} fires the {@link Zarafa.settings.SettingsModel#exception exception} + * event to indicate the settings were not successfully saved. + * @param {Zarafa.settings.SettingsModel} model The settings model which fired the event + * @param {String} type The value of this parameter will be either 'response' or 'remote'. + * @param {String} action Name of the action (see {@link Ext.data.Api#actions}). + * @param {Object} options The object containing a 'path' and 'value' field indicating + * respectively the Setting and corresponding value for the setting which was being saved. + * @param {Object} response The response object as received from the PHP-side + * @private + */ + onSettingsException: function (model, type, action, options, response) { + this.loadMask.hide(); + + // Remove event handlers + this.mun(model, 'save', this.onSettingsSave, this); + this.mun(model, 'exception', this.onSettingsException, this); + } +}); + +Ext.reg('calendarimporter.settingswidget', Zarafa.plugins.calendarimporter.settings.SettingsWidget); diff --git a/js/settings/dialogs/CalSyncEditContentPanel.js b/js/settings/dialogs/CalSyncEditContentPanel.js index cfb7fe0..41709f1 100644 --- a/js/settings/dialogs/CalSyncEditContentPanel.js +++ b/js/settings/dialogs/CalSyncEditContentPanel.js @@ -1,60 +1,60 @@ -/** - * CalSyncEditContentPanel.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs'); - -/** - * @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel - * @extends Zarafa.core.ui.ContentPanel - * @xtype calendarimporter.calsynceditcontentpanel - * - * {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel CalSyncEditContentPanel} will be used to edit ics sync entries. - */ -Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, { - /** - * @constructor - * @param config Configuration structure - */ - constructor: function (config) { - config = config || {}; - - // Add in some standard configuration data. - Ext.applyIf(config, { - // Override from Ext.Component - xtype: 'calendarimporter.calsynceditcontentpanel', - layout: 'fit', - model: true, - autoSave: false, - width: 400, - height: 400, - title: dgettext('plugin_calendarimporter', 'ICAL Sync'), - items: [{ - xtype: 'calendarimporter.calsynceditpanel', - item: config.item - }] - }); - - Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel.superclass.constructor.call(this, config); - } -}); - -Ext.reg('calendarimporter.calsynceditcontentpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel); +/** + * CalSyncEditContentPanel.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs'); + +/** + * @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel + * @extends Zarafa.core.ui.ContentPanel + * @xtype calendarimporter.calsynceditcontentpanel + * + * {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel CalSyncEditContentPanel} will be used to edit ics sync entries. + */ +Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, { + /** + * @constructor + * @param config Configuration structure + */ + constructor: function (config) { + config = config || {}; + + // Add in some standard configuration data. + Ext.applyIf(config, { + // Override from Ext.Component + xtype: 'calendarimporter.calsynceditcontentpanel', + layout: 'fit', + model: true, + autoSave: false, + width: 400, + height: 400, + title: dgettext('plugin_calendarimporter', 'ICAL Sync'), + items: [{ + xtype: 'calendarimporter.calsynceditpanel', + item: config.item + }] + }); + + Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel.superclass.constructor.call(this, config); + } +}); + +Ext.reg('calendarimporter.calsynceditcontentpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel); diff --git a/js/settings/dialogs/CalSyncEditPanel.js b/js/settings/dialogs/CalSyncEditPanel.js index 175961b..b53f599 100644 --- a/js/settings/dialogs/CalSyncEditPanel.js +++ b/js/settings/dialogs/CalSyncEditPanel.js @@ -1,223 +1,223 @@ -/** - * CalSyncEditPanel.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs'); - -/** - * @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel - * @extends Ext.form.FormPanel - * @xtype calendarimporter.calsynceditpanel - * - * Will generate UI for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel}. - */ -Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel = Ext.extend(Ext.form.FormPanel, { - - /** - * the id of the currently edited item - */ - currentItem: undefined, - - /** - * @constructor - * @param config Configuration structure - */ - constructor: function (config) { - config = config || {}; - - if (config.item) - this.currentItem = config.item; - - Ext.applyIf(config, { - // Override from Ext.Component - xtype: 'calendarimporter.calsynceditpanel', - labelAlign: 'top', - defaultType: 'textfield', - items: this.createPanelItems(config), - buttons: [{ - text: _('Save'), - handler: this.doSave, - scope: this - }, - { - text: _('Cancel'), - handler: this.doClose, - scope: this - }] - }); - - Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel.superclass.constructor.call(this, config); - }, - - /** - * close the dialog - */ - doClose: function () { - this.dialog.close(); - }, - - /** - * save the data to the store - */ - doSave: function () { - var store = this.dialog.store; - var id = 0; - var record = undefined; - - if (!this.currentItem) { - record = new store.recordType({ - id: this.hashCode(this.icsurl.getValue()), - icsurl: this.icsurl.getValue(), - intervall: this.intervall.getValue(), - user: this.user.getValue(), - pass: Ext.util.base64.encode(this.pass.getValue()), - calendar: this.calendar.getValue(), - calendarname: Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name, - lastsync: "never" - }); - } - - if (this.icsurl.isValid()) { - if (record) { - store.add(record); - } else { - this.currentItem.set('icsurl', this.icsurl.getValue()); - this.currentItem.set('intervall', this.intervall.getValue()); - this.currentItem.set('user', this.user.getValue()); - this.currentItem.set('pass', Ext.util.base64.encode(this.pass.getValue())); - this.currentItem.set('calendar', this.calendar.getValue()); - this.currentItem.set('calendarname', Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name); - } - this.dialog.close(); - } - }, - - /** - * Function will create panel items for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel} - * @return {Array} array of items that should be added to panel. - * @private - */ - createPanelItems: function (config) { - var icsurl = ""; - var intervall = "15"; - var user = ""; - var pass = ""; - var calendarname = ""; - var calendar = Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByName(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_calendar")).entryid; - var myStore = Zarafa.plugins.calendarimporter.data.Actions.getAllCalendarFolders(true); - - if (config.item) { - icsurl = config.item.get('icsurl'); - intervall = config.item.get('intervall'); - user = config.item.get('user'); - pass = Ext.util.base64.decode(config.item.get('pass')); - calendar = config.item.get('calendar'); - calendarname = config.item.get('calendarname'); - } - - - return [{ - xtype: 'fieldset', - title: dgettext('plugin_calendarimporter', 'ICAL Information'), - defaultType: 'textfield', - layout: 'form', - flex: 1, - defaults: { - anchor: '100%', - flex: 1 - }, - items: [{ - fieldLabel: dgettext('plugin_calendarimporter', 'ICS Url'), - name: 'icsurl', - ref: '../icsurl', - value: icsurl, - allowBlank: false - }, - { - xtype: 'selectbox', - fieldLabel: dgettext('plugin_calendarimporter', 'Destination Calendar'), - name: 'calendar', - ref: '../calendar', - value: calendar, - editable: false, - store: myStore, - mode: 'local', - labelSeperator: ":", - border: false, - anchor: "100%", - scope: this, - allowBlank: false - }, - { - xtype: 'numberfield', - fieldLabel: dgettext('plugin_calendarimporter', 'Sync Intervall (minutes)'), - name: 'intervall', - ref: '../intervall', - value: intervall, - allowBlank: false - }] - }, - { - xtype: 'fieldset', - title: dgettext('plugin_calendarimporter', 'Authentication (optional)'), - defaultType: 'textfield', - layout: 'form', - defaults: { - anchor: '100%' - }, - items: [{ - fieldLabel: dgettext('plugin_calendarimporter', 'Username'), - name: 'user', - ref: '../user', - value: user, - allowBlank: true - }, - { - fieldLabel: dgettext('plugin_calendarimporter', 'Password'), - name: 'pass', - ref: '../pass', - value: pass, - inputType: 'password', - allowBlank: true - }] - }]; - }, - - /** - * Java String.hashCode() implementation - * @private - */ - hashCode: function (str) { - var hash = 0; - var chr = 0; - var i = 0; - - if (str.length == 0) return hash; - for (i = 0; i < str.length; i++) { - chr = str.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash = hash & hash; // Convert to 32bit integer - } - return Math.abs(hash); - } -}); - -Ext.reg('calendarimporter.calsynceditpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel); +/** + * CalSyncEditPanel.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs'); + +/** + * @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel + * @extends Ext.form.FormPanel + * @xtype calendarimporter.calsynceditpanel + * + * Will generate UI for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel}. + */ +Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel = Ext.extend(Ext.form.FormPanel, { + + /** + * the id of the currently edited item + */ + currentItem: undefined, + + /** + * @constructor + * @param config Configuration structure + */ + constructor: function (config) { + config = config || {}; + + if (config.item) + this.currentItem = config.item; + + Ext.applyIf(config, { + // Override from Ext.Component + xtype: 'calendarimporter.calsynceditpanel', + labelAlign: 'top', + defaultType: 'textfield', + items: this.createPanelItems(config), + buttons: [{ + text: _('Save'), + handler: this.doSave, + scope: this + }, + { + text: _('Cancel'), + handler: this.doClose, + scope: this + }] + }); + + Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel.superclass.constructor.call(this, config); + }, + + /** + * close the dialog + */ + doClose: function () { + this.dialog.close(); + }, + + /** + * save the data to the store + */ + doSave: function () { + var store = this.dialog.store; + var id = 0; + var record = undefined; + + if (!this.currentItem) { + record = new store.recordType({ + id: this.hashCode(this.icsurl.getValue()), + icsurl: this.icsurl.getValue(), + intervall: this.intervall.getValue(), + user: this.user.getValue(), + pass: Ext.util.base64.encode(this.pass.getValue()), + calendar: this.calendar.getValue(), + calendarname: Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name, + lastsync: "never" + }); + } + + if (this.icsurl.isValid()) { + if (record) { + store.add(record); + } else { + this.currentItem.set('icsurl', this.icsurl.getValue()); + this.currentItem.set('intervall', this.intervall.getValue()); + this.currentItem.set('user', this.user.getValue()); + this.currentItem.set('pass', Ext.util.base64.encode(this.pass.getValue())); + this.currentItem.set('calendar', this.calendar.getValue()); + this.currentItem.set('calendarname', Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name); + } + this.dialog.close(); + } + }, + + /** + * Function will create panel items for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel} + * @return {Array} array of items that should be added to panel. + * @private + */ + createPanelItems: function (config) { + var icsurl = ""; + var intervall = "15"; + var user = ""; + var pass = ""; + var calendarname = ""; + var calendar = Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByName(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_calendar")).entryid; + var myStore = Zarafa.plugins.calendarimporter.data.Actions.getAllCalendarFolders(true); + + if (config.item) { + icsurl = config.item.get('icsurl'); + intervall = config.item.get('intervall'); + user = config.item.get('user'); + pass = Ext.util.base64.decode(config.item.get('pass')); + calendar = config.item.get('calendar'); + calendarname = config.item.get('calendarname'); + } + + + return [{ + xtype: 'fieldset', + title: dgettext('plugin_calendarimporter', 'ICAL Information'), + defaultType: 'textfield', + layout: 'form', + flex: 1, + defaults: { + anchor: '100%', + flex: 1 + }, + items: [{ + fieldLabel: dgettext('plugin_calendarimporter', 'ICS Url'), + name: 'icsurl', + ref: '../icsurl', + value: icsurl, + allowBlank: false + }, + { + xtype: 'selectbox', + fieldLabel: dgettext('plugin_calendarimporter', 'Destination Calendar'), + name: 'calendar', + ref: '../calendar', + value: calendar, + editable: false, + store: myStore, + mode: 'local', + labelSeperator: ":", + border: false, + anchor: "100%", + scope: this, + allowBlank: false + }, + { + xtype: 'numberfield', + fieldLabel: dgettext('plugin_calendarimporter', 'Sync Intervall (minutes)'), + name: 'intervall', + ref: '../intervall', + value: intervall, + allowBlank: false + }] + }, + { + xtype: 'fieldset', + title: dgettext('plugin_calendarimporter', 'Authentication (optional)'), + defaultType: 'textfield', + layout: 'form', + defaults: { + anchor: '100%' + }, + items: [{ + fieldLabel: dgettext('plugin_calendarimporter', 'Username'), + name: 'user', + ref: '../user', + value: user, + allowBlank: true + }, + { + fieldLabel: dgettext('plugin_calendarimporter', 'Password'), + name: 'pass', + ref: '../pass', + value: pass, + inputType: 'password', + allowBlank: true + }] + }]; + }, + + /** + * Java String.hashCode() implementation + * @private + */ + hashCode: function (str) { + var hash = 0; + var chr = 0; + var i = 0; + + if (str.length == 0) return hash; + for (i = 0; i < str.length; i++) { + chr = str.charCodeAt(i); + hash = ((hash << 5) - hash) + chr; + hash = hash & hash; // Convert to 32bit integer + } + return Math.abs(hash); + } +}); + +Ext.reg('calendarimporter.calsynceditpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel); diff --git a/js/settings/ui/CalSyncGrid.js b/js/settings/ui/CalSyncGrid.js index 909dddc..092604e 100644 --- a/js/settings/ui/CalSyncGrid.js +++ b/js/settings/ui/CalSyncGrid.js @@ -1,180 +1,180 @@ -/** - * CalSyncGrid.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui'); - -/** - * @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid - * @extends Ext.grid.GridPanel - * @xtype calendarimporter.calsyncgrid - * - */ -Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.GridPanel, { - /** - * @constructor - * @param {Object} config Configuration structure - */ - constructor: function (config) { - config = config || {}; - - Ext.applyIf(config, { - xtype: 'calendarimporter.calsyncgrid', - border: true, - store: config.store, - viewConfig: { - forceFit: true, - emptyText: '
' + dgettext('plugin_calendarimporter', 'No ICAL sync entry exists') + '
' - }, - loadMask: this.initLoadMask(), - columns: this.initColumnModel(), - selModel: this.initSelectionModel(), - listeners: { - viewready: this.onViewReady, - rowdblclick: this.onRowDblClick, - scope: this - } - }); - - Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.constructor.call(this, config); - }, - - /** - * initialize events for the grid panel. - * @private - */ - initEvents: function () { - Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.initEvents.call(this); - - // select first icssync when store has finished loading - this.mon(this.store, 'load', this.onViewReady, this, {single: true}); - }, - - /** - * Render function - * @return {String} - * @private - */ - renderAuthColumn: function (value, p, record) { - return value ? "true" : "false"; - }, - - /** - * Render function - * @return {String} - * @private - */ - renderCalendarColumn: function (value, p, record) { - return Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(value).display_name; - }, - - /** - * Creates a column model object, used in {@link #colModel} config - * @return {Ext.grid.ColumnModel} column model object - * @private - */ - initColumnModel: function () { - return [{ - dataIndex: 'icsurl', - header: dgettext('plugin_calendarimporter', 'ICS File'), - renderer: Zarafa.common.ui.grid.Renderers.text - }, - { - dataIndex: 'calendarname', - header: dgettext('plugin_calendarimporter', 'Destination Calender'), - renderer: Zarafa.common.ui.grid.Renderers.text - }, - { - dataIndex: 'user', - header: dgettext('plugin_calendarimporter', 'Authentication'), - renderer: this.renderAuthColumn - }, - { - dataIndex: 'intervall', - header: dgettext('plugin_calendarimporter', 'Sync Intervall') - }, - { - dataIndex: 'lastsync', - header: dgettext('plugin_calendarimporter', 'Last Synchronisation'), - renderer: Zarafa.common.ui.grid.Renderers.text - }] - }, - - /** - * Creates a selection model object, used in {@link #selModel} config - * @return {Ext.grid.RowSelectionModel} selection model object - * @private - */ - initSelectionModel: function () { - return new Ext.grid.RowSelectionModel({ - singleSelect: true - }); - }, - - /** - * Initialize the {@link Ext.grid.GridPanel.loadMask} field - * - * @return {Ext.LoadMask} The configuration object for {@link Ext.LoadMask} - * @private - */ - initLoadMask: function () { - return { - msg: dgettext('plugin_calendarimporter', 'Loading ics sync entries...') - }; - }, - - /** - * Event handler which is fired when the gridPanel is ready. This will automatically - * select the first row in the grid. - * @private - */ - onViewReady: function () { - this.getSelectionModel().selectFirstRow(); - }, - - /** - * Function will be called to remove a ics sync entry. - */ - removeIcsSyncAs: function () { - var icsRecord = this.getSelectionModel().getSelected(); - if (!icsRecord) { - Ext.Msg.alert(dgettext('plugin_calendarimporter', 'Alert'), dgettext('plugin_calendarimporter', 'Please select a ics sync entry.')); - return; - } - - this.store.remove(icsRecord); - }, - - /** - * Event handler which is fired when the {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid} is double clicked. - * it will call generic function to handle the functionality. - * @private - */ - onRowDblClick: function (grid, rowIndex) { - Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, { - store: grid.getStore(), - item: grid.getStore().getAt(rowIndex), - manager: Ext.WindowMgr - }); - } -}); - -Ext.reg('calendarimporter.calsyncgrid', Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid); +/** + * CalSyncGrid.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui'); + +/** + * @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid + * @extends Ext.grid.GridPanel + * @xtype calendarimporter.calsyncgrid + * + */ +Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.GridPanel, { + /** + * @constructor + * @param {Object} config Configuration structure + */ + constructor: function (config) { + config = config || {}; + + Ext.applyIf(config, { + xtype: 'calendarimporter.calsyncgrid', + border: true, + store: config.store, + viewConfig: { + forceFit: true, + emptyText: '
' + dgettext('plugin_calendarimporter', 'No ICAL sync entry exists') + '
' + }, + loadMask: this.initLoadMask(), + columns: this.initColumnModel(), + selModel: this.initSelectionModel(), + listeners: { + viewready: this.onViewReady, + rowdblclick: this.onRowDblClick, + scope: this + } + }); + + Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.constructor.call(this, config); + }, + + /** + * initialize events for the grid panel. + * @private + */ + initEvents: function () { + Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.initEvents.call(this); + + // select first icssync when store has finished loading + this.mon(this.store, 'load', this.onViewReady, this, {single: true}); + }, + + /** + * Render function + * @return {String} + * @private + */ + renderAuthColumn: function (value, p, record) { + return value ? "true" : "false"; + }, + + /** + * Render function + * @return {String} + * @private + */ + renderCalendarColumn: function (value, p, record) { + return Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(value).display_name; + }, + + /** + * Creates a column model object, used in {@link #colModel} config + * @return {Ext.grid.ColumnModel} column model object + * @private + */ + initColumnModel: function () { + return [{ + dataIndex: 'icsurl', + header: dgettext('plugin_calendarimporter', 'ICS File'), + renderer: Zarafa.common.ui.grid.Renderers.text + }, + { + dataIndex: 'calendarname', + header: dgettext('plugin_calendarimporter', 'Destination Calender'), + renderer: Zarafa.common.ui.grid.Renderers.text + }, + { + dataIndex: 'user', + header: dgettext('plugin_calendarimporter', 'Authentication'), + renderer: this.renderAuthColumn + }, + { + dataIndex: 'intervall', + header: dgettext('plugin_calendarimporter', 'Sync Intervall') + }, + { + dataIndex: 'lastsync', + header: dgettext('plugin_calendarimporter', 'Last Synchronisation'), + renderer: Zarafa.common.ui.grid.Renderers.text + }] + }, + + /** + * Creates a selection model object, used in {@link #selModel} config + * @return {Ext.grid.RowSelectionModel} selection model object + * @private + */ + initSelectionModel: function () { + return new Ext.grid.RowSelectionModel({ + singleSelect: true + }); + }, + + /** + * Initialize the {@link Ext.grid.GridPanel.loadMask} field + * + * @return {Ext.LoadMask} The configuration object for {@link Ext.LoadMask} + * @private + */ + initLoadMask: function () { + return { + msg: dgettext('plugin_calendarimporter', 'Loading ics sync entries...') + }; + }, + + /** + * Event handler which is fired when the gridPanel is ready. This will automatically + * select the first row in the grid. + * @private + */ + onViewReady: function () { + this.getSelectionModel().selectFirstRow(); + }, + + /** + * Function will be called to remove a ics sync entry. + */ + removeIcsSyncAs: function () { + var icsRecord = this.getSelectionModel().getSelected(); + if (!icsRecord) { + Ext.Msg.alert(dgettext('plugin_calendarimporter', 'Alert'), dgettext('plugin_calendarimporter', 'Please select a ics sync entry.')); + return; + } + + this.store.remove(icsRecord); + }, + + /** + * Event handler which is fired when the {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid} is double clicked. + * it will call generic function to handle the functionality. + * @private + */ + onRowDblClick: function (grid, rowIndex) { + Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, { + store: grid.getStore(), + item: grid.getStore().getAt(rowIndex), + manager: Ext.WindowMgr + }); + } +}); + +Ext.reg('calendarimporter.calsyncgrid', Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid); diff --git a/js/settings/ui/CalSyncPanel.js b/js/settings/ui/CalSyncPanel.js index 4761e90..8e63856 100644 --- a/js/settings/ui/CalSyncPanel.js +++ b/js/settings/ui/CalSyncPanel.js @@ -1,172 +1,172 @@ -/** - * CalSyncPanel.js, Kopano calender to ics im/exporter - * - * Author: Christoph Haas - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui'); - -/** - * @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel - * @extends Ext.Panel - * @xtype calendarimporter.calsyncpanel - * Will generate UI for the {@link Zarafa.common.settings.SettingsSendAsWidget SettingsSendAsWidget}. - */ -Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, { - - // store - store: undefined, - - /** - * @constructor - * @param config Configuration structure - */ - constructor: function (config) { - config = config || {}; - if (config.store) - this.store = config.store; - - Ext.applyIf(config, { - // Override from Ext.Component - xtype: 'calendarimporter.calsyncpanel', - border: false, - layout: { - type: 'vbox', - align: 'stretch', - pack: 'start' - }, - items: this.createPanelItems(this.store) - }); - - Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.constructor.call(this, config); - }, - - /** - * Function will create panel items for {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel CalSyncPanel} - * @return {Array} array of items that should be added to panel. - * @private - */ - createPanelItems: function (store) { - return [{ - xtype: 'displayfield', - value: dgettext('plugin_calendarimporter', 'Setup calendars you want to subscribe to.'), - fieldClass: 'x-form-display-field' - }, { - xtype: 'container', - flex: 1, - layout: { - type: 'hbox', - align: 'stretch', - pack: 'start' - }, - items: [{ - xtype: 'calendarimporter.calsyncgrid', - ref: '../calsyncGrid', - store: store, - flex: 1 - }, { - xtype: 'container', - width: 160, - defaults: { - width: 140 - }, - layout: { - type: 'vbox', - align: 'center', - pack: 'start' - }, - items: [{ - xtype: 'button', - text: _('Add') + '...', - handler: this.onCalSyncAdd, - ref: '../../addButton', - scope: this - }, { - xtype: 'spacer', - height: 20 - }, { - xtype: 'button', - text: _('Remove') + '...', - disabled: true, - ref: '../../removeButton', - handler: this.onCalSyncRemove, - scope: this - }] - }] - }]; - }, - - /** - * initialize events for the panel. - * @private - */ - initEvents: function () { - Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.initEvents.call(this); - - // register event to enable/disable buttons - this.mon(this.calsyncGrid.getSelectionModel(), 'selectionchange', this.onGridSelectionChange, this); - }, - - /** - * Handler function will be called when user clicks on 'Add' button. - * @private - */ - onCalSyncAdd: function () { - Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, { - store: this.store, - item: undefined, - manager: Ext.WindowMgr - }); - }, - - /** - * Event handler will be called when selection in {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid} - * has been changed - * @param {Ext.grid.RowSelectionModel} selectionModel selection model that fired the event - */ - onGridSelectionChange: function (selectionModel) { - var noSelection = (selectionModel.hasSelection() === false); - - this.removeButton.setDisabled(noSelection); - }, - - /** - * Handler function will be called when user clicks on 'Remove' button. - * @private - */ - onCalSyncRemove: function () { - this.calsyncGrid.removeIcsSyncAs(); - }, - - /** - * Function will be used to reload data in the store. - */ - discardChanges: function () { - this.store.load(); - }, - - /** - * Function will be used to save changes in the store. - */ - saveChanges: function () { - this.store.save(); - } -}); - -Ext.reg('calendarimporter.calsyncpanel', Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel); +/** + * CalSyncPanel.js, Kopano calender to ics im/exporter + * + * Author: Christoph Haas + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui'); + +/** + * @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel + * @extends Ext.Panel + * @xtype calendarimporter.calsyncpanel + * Will generate UI for the {@link Zarafa.common.settings.SettingsSendAsWidget SettingsSendAsWidget}. + */ +Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, { + + // store + store: undefined, + + /** + * @constructor + * @param config Configuration structure + */ + constructor: function (config) { + config = config || {}; + if (config.store) + this.store = config.store; + + Ext.applyIf(config, { + // Override from Ext.Component + xtype: 'calendarimporter.calsyncpanel', + border: false, + layout: { + type: 'vbox', + align: 'stretch', + pack: 'start' + }, + items: this.createPanelItems(this.store) + }); + + Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.constructor.call(this, config); + }, + + /** + * Function will create panel items for {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel CalSyncPanel} + * @return {Array} array of items that should be added to panel. + * @private + */ + createPanelItems: function (store) { + return [{ + xtype: 'displayfield', + value: dgettext('plugin_calendarimporter', 'Setup calendars you want to subscribe to.'), + fieldClass: 'x-form-display-field' + }, { + xtype: 'container', + flex: 1, + layout: { + type: 'hbox', + align: 'stretch', + pack: 'start' + }, + items: [{ + xtype: 'calendarimporter.calsyncgrid', + ref: '../calsyncGrid', + store: store, + flex: 1 + }, { + xtype: 'container', + width: 160, + defaults: { + width: 140 + }, + layout: { + type: 'vbox', + align: 'center', + pack: 'start' + }, + items: [{ + xtype: 'button', + text: _('Add') + '...', + handler: this.onCalSyncAdd, + ref: '../../addButton', + scope: this + }, { + xtype: 'spacer', + height: 20 + }, { + xtype: 'button', + text: _('Remove') + '...', + disabled: true, + ref: '../../removeButton', + handler: this.onCalSyncRemove, + scope: this + }] + }] + }]; + }, + + /** + * initialize events for the panel. + * @private + */ + initEvents: function () { + Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.initEvents.call(this); + + // register event to enable/disable buttons + this.mon(this.calsyncGrid.getSelectionModel(), 'selectionchange', this.onGridSelectionChange, this); + }, + + /** + * Handler function will be called when user clicks on 'Add' button. + * @private + */ + onCalSyncAdd: function () { + Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, { + store: this.store, + item: undefined, + manager: Ext.WindowMgr + }); + }, + + /** + * Event handler will be called when selection in {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid} + * has been changed + * @param {Ext.grid.RowSelectionModel} selectionModel selection model that fired the event + */ + onGridSelectionChange: function (selectionModel) { + var noSelection = (selectionModel.hasSelection() === false); + + this.removeButton.setDisabled(noSelection); + }, + + /** + * Handler function will be called when user clicks on 'Remove' button. + * @private + */ + onCalSyncRemove: function () { + this.calsyncGrid.removeIcsSyncAs(); + }, + + /** + * Function will be used to reload data in the store. + */ + discardChanges: function () { + this.store.load(); + }, + + /** + * Function will be used to save changes in the store. + */ + saveChanges: function () { + this.store.save(); + } +}); + +Ext.reg('calendarimporter.calsyncpanel', Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel); diff --git a/manifest.xml b/manifest.xml index 09d3508..df0af10 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,52 +1,52 @@ - - - - - 2.2.1 - calendarimporter - ICS Calendar Importer/Exporter - Christoph Haas - http://www.sprinternet.at - Import or Export a ICS file to/from the Kopano calendar - - - languages - - - config.php - - - - - - php/plugin.calendarimporter.php - php/module.calendar.php - - - js/calendarimporter.js - js/calendarimporter-debug.js - - js/data/timezones.js - js/data/Actions.js - js/data/ResponseHandler.js - js/external/Ext.util.base64.js - js/ui/ContextMenu.js - js/dialogs/ImportContentPanel.js - js/dialogs/ImportPanel.js - js/dialogs/settings/SettingsWidget.js - js/dialogs/settings/SettingsCalSyncWidget.js - js/dialogs/settings/ui/CalSyncGrid.js - js/dialogs/settings/ui/CalSyncPanel.js - js/dialogs/settings/dialogs/CalSyncEditContentPanel.js - js/dialogs/settings/dialogs/CalSyncEditPanel.js - js/plugin.calendarimporter.js - - - resources/css/calendarimporter.css - resources/css/calendarimporter.css - resources/css/calendarimporter-main.css - - - - - + + + + + 2.2.1 + calendarimporter + ICS Calendar Importer/Exporter + Christoph Haas + http://www.sprinternet.at + Import or Export a ICS file to/from the Kopano calendar + + + languages + + + config.php + + + + + + php/plugin.calendarimporter.php + php/module.calendar.php + + + js/calendarimporter.js + js/calendarimporter-debug.js + + js/data/timezones.js + js/data/Actions.js + js/data/ResponseHandler.js + js/external/Ext.util.base64.js + js/ui/ContextMenu.js + js/dialogs/ImportContentPanel.js + js/dialogs/ImportPanel.js + js/dialogs/settings/SettingsWidget.js + js/dialogs/settings/SettingsCalSyncWidget.js + js/dialogs/settings/ui/CalSyncGrid.js + js/dialogs/settings/ui/CalSyncPanel.js + js/dialogs/settings/dialogs/CalSyncEditContentPanel.js + js/dialogs/settings/dialogs/CalSyncEditPanel.js + js/plugin.calendarimporter.js + + + resources/css/calendarimporter.css + resources/css/calendarimporter.css + resources/css/calendarimporter-main.css + + + + + diff --git a/php/download.php b/php/download.php index 12be79c..1ed00a4 100644 --- a/php/download.php +++ b/php/download.php @@ -1,75 +1,75 @@ - - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -namespace calendarimporter; - -class DownloadHandler -{ - /** - * Download the given vcf file. - * @return boolean - */ - public static function doDownload() - { - if (isset($_GET["token"])) { - $token = $_GET["token"]; - } else { - return false; - } - - if (isset($_GET["filename"])) { - $filename = $_GET["filename"]; - } else { - return false; - } - - // validate token - if (!preg_match('/^[a-zA-Z0-9]+$/', $token)) { // token is a md5 hash - return false; - } - - $file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics"; - - if (!file_exists($file)) { // invalid token - return false; - } - - // set headers here - header('Content-Disposition: attachment; filename="' . $filename . '"'); - - // no caching - header('Expires: 0'); // set expiration time - header('Content-Description: File Transfer'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Content-Length: ' . filesize($file)); - header('Content-Type: application/octet-stream'); - header('Pragma: public'); - flush(); - - // print the downloaded file - readfile($file); - ignore_user_abort(true); - unlink($file); - - return true; - } + + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +namespace calendarimporter; + +class DownloadHandler +{ + /** + * Download the given vcf file. + * @return boolean + */ + public static function doDownload() + { + if (isset($_GET["token"])) { + $token = $_GET["token"]; + } else { + return false; + } + + if (isset($_GET["filename"])) { + $filename = $_GET["filename"]; + } else { + return false; + } + + // validate token + if (!preg_match('/^[a-zA-Z0-9]+$/', $token)) { // token is a md5 hash + return false; + } + + $file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics"; + + if (!file_exists($file)) { // invalid token + return false; + } + + // set headers here + header('Content-Disposition: attachment; filename="' . $filename . '"'); + + // no caching + header('Expires: 0'); // set expiration time + header('Content-Description: File Transfer'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Content-Length: ' . filesize($file)); + header('Content-Type: application/octet-stream'); + header('Pragma: public'); + flush(); + + // print the downloaded file + readfile($file); + ignore_user_abort(true); + unlink($file); + + return true; + } } \ No newline at end of file diff --git a/php/module.calendar.php b/php/module.calendar.php index f930cb8..87b5c6a 100644 --- a/php/module.calendar.php +++ b/php/module.calendar.php @@ -1,770 +1,770 @@ - - * Copyright (C) 2012-2016 Christoph Haas - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -include_once(__DIR__ . "/vendor/autoload.php"); -include_once(__DIR__ . "/helper.php"); - -use Sabre\VObject; -use calendarimporter\Helper; - -class CalendarModule extends Module -{ - - private $DEBUG = false; // enable error_log debugging - - private $busyStates = null; - - private $labels = null; - - private $attendeeType = null; - - /** - * @constructor - * @param $id - * @param $data - */ - public function __construct($id, $data) - { - parent::__construct($id, $data); - - // init default timezone - date_default_timezone_set(PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE); - - // init mappings - $this->busyStates = array( - "FREE", - "TENTATIVE", - "BUSY", - "OOF" - ); - - $this->freeBusyStates = array( // http://www.kanzaki.com/docs/ical/fbtype.html - "FREE", - "BUSY-TENTATIVE", - "BUSY", - "BUSY-UNAVAILABLE" - ); - - $this->labels = array( - "NONE", - "IMPORTANT", - "WORK", - "PERSONAL", - "HOLIDAY", - "REQUIRED", - "TRAVEL REQUIRED", - "PREPARATION REQUIERED", - "BIRTHDAY", - "SPECIAL DATE", - "PHONE INTERVIEW" - ); - - $this->attendeeType = array( - "NON-PARTICIPANT", // needed as zarafa starts counting at 1 - "REQ-PARTICIPANT", - "OPT-PARTICIPANT", - "NON-PARTICIPANT" - ); - } - - /** - * Executes all the actions in the $data variable. - * Exception part is used for authentication errors also - * - * @return boolean true on success or false on failure. - */ - public function execute() - { - $result = false; - - if (!$this->DEBUG) { - /* disable error printing - otherwise json communication might break... */ - ini_set('display_errors', '0'); - } - - foreach ($this->data as $actionType => $actionData) { - if (isset($actionType)) { - try { - if ($this->DEBUG) { - error_log("exec: " . $actionType); - } - switch ($actionType) { - case "load": - $result = $this->loadCalendar($actionType, $actionData); - break; - case "export": - $result = $this->exportCalendar($actionType, $actionData); - break; - case "import": - $result = $this->importCalendar($actionType, $actionData); - break; - case "importattachment": - $result = $this->getAttachmentPath($actionType, $actionData); - break; - default: - $this->handleUnknownActionType($actionType); - } - - } catch (MAPIException $e) { - if ($this->DEBUG) { - error_log("mapi exception: " . $e->getMessage()); - } - } catch (Exception $e) { - if ($this->DEBUG) { - error_log("exception: " . $e->getMessage()); - } - } - } - } - - return $result; - } - - /** - * Get a property from the array. - * - * @param $props - * @param $propName - * @return string - */ - private function getProp($props, $propName) - { - if (isset($props["props"][$propName])) { - return $props["props"][$propName]; - } - return ""; - } - - /** - * Get a duration string form given minutes - * - * @param $minutes - * @param bool $pos - * @return string - */ - private function getDurationStringFromMinutes($minutes, $pos = false) - { - $pos = $pos === true ? "+" : "-"; - $str = $pos . "P"; - - - // variables for holding values - $min = intval($minutes); - $hours = 0; - $days = 0; - $weeks = 0; - - // calculations - if ($min >= 60) { - $hours = (int)($min / 60); - $min = $min % 60; - } - if ($hours >= 24) { - $days = (int)($hours / 24); - $hours = $hours % 60; - } - if ($days >= 7) { - $weeks = (int)($days / 7); - $days = $days % 7; - } - - // format result - if ($weeks) { - $str .= "{$weeks}W"; - } - if ($days) { - $str .= "{$days}D"; - } - if ($hours) { - $str .= "{$hours}H"; - } - if ($min) { - $str .= "{$min}M"; - } - - return $str; - } - - /** - * The main export function, creates the ics file for download - * - * @param $actionType - * @param $actionData - */ - private function exportCalendar($actionType, $actionData) - { - // Get store id - $storeId = false; - if (isset($actionData["storeid"])) { - $storeId = $actionData["storeid"]; - } - - // Get records - $records = array(); - if (isset($actionData["records"])) { - $records = $actionData["records"]; - } - - // Get folders - $folder = false; - if (isset($actionData["folder"])) { - $folder = $actionData["folder"]; - } - - $response = array(); - $error = false; - $error_msg = ""; - - // write csv - $token = Helper::randomstring(16); - $file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics"; - file_put_contents($file, ""); - - $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId)); - if ($store) { - // load folder first - if ($folder !== false) { - $mapiFolder = mapi_msgstore_openentry($store, hex2bin($folder)); - - $table = mapi_folder_getcontentstable($mapiFolder); - $list = mapi_table_queryallrows($table, array(PR_ENTRYID)); - - foreach ($list as $item) { - $records[] = bin2hex($item[PR_ENTRYID]); - } - } - - $vCalendar = new VObject\Component\VCalendar(); - - // Add static stuff to vCalendar - $vCalendar->add('METHOD', 'PUBLISH'); - $vCalendar->add('X-WR-CALDESC', 'Exported Kopano Calendar'); - $vCalendar->add('X-WR-TIMEZONE', date_default_timezone_get()); - - // TODO: add VTIMEZONE object to ical. - - for ($index = 0, $count = count($records); $index < $count; $index++) { - $message = mapi_msgstore_openentry($store, hex2bin($records[$index])); - - // get message properties. - $properties = $GLOBALS['properties']->getAppointmentProperties(); - $plaintext = true; - $messageProps = $GLOBALS['operations']->getMessageProps($store, $message, $properties, $plaintext); - - $vEvent = $vCalendar->add('VEVENT', [ - 'SUMMARY' => $this->getProp($messageProps, "subject"), - 'DTSTART' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "startdate")), - 'DTEND' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "duedate")), - 'CREATED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "creation_time")), - 'LAST-MODIFIED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "last_modification_time")), - 'PRIORITY' => intval($this->getProp($messageProps, "importance")), - 'X-MICROSOFT-CDO-INTENDEDSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid... - 'X-MICROSOFT-CDO-BUSYSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid... - 'FBTYPE' => $this->freeBusyStates[intval($this->getProp($messageProps, "busystatus"))], - 'X-ZARAFA-LABEL' => $this->labels[intval($this->getProp($messageProps, "label"))], - 'CLASS' => $this->getProp($messageProps, "private") ? "PRIVATE" : "PUBLIC", - 'COMMENT' => "eid:" . $records[$index] - ]); - - // Add organizer - $organizer = $this->getProp($messageProps, "sender_email_address"); - if(!empty($organizer)) { - $vEvent->add('ORGANIZER', 'mailto:' . $organizer); - $vEvent->ORGANIZER['CN'] = $this->getProp($messageProps, "sender_name"); - } - - // Add Attendees - if (isset($messageProps["recipients"]) && count($messageProps["recipients"]["item"]) > 0) { - foreach ($messageProps["recipients"]["item"] as $attendee) { - $att = $vEvent->add('ATTENDEE', "mailto:" . $this->getProp($attendee, "email_address")); - $att["CN"] = $this->getProp($attendee, "display_name"); - $att["ROLE"] = $this->attendeeType[intval($this->getProp($attendee, "recipient_type"))]; - } - } - - // Add alarms - $reminder = $this->getProp($messageProps, "reminder"); - if (!empty($reminder) && $this->getProp($messageProps, "reminder") == 1) { - $vAlarm = $vEvent->add('VALARM', [ - 'ACTION' => 'DISPLAY', - 'DESCRIPTION' => $this->getProp($messageProps, "subject") // reuse the event summary - ]); - - // Add trigger - $durationValue = $this->getDurationStringFromMinutes($this->getProp($messageProps, "reminder_minutes"), false); - $vAlarm->add('TRIGGER', $durationValue); // default trigger type is duration (see 4.8.6.3) - - /* - $valarm->add('TRIGGER', date_timestamp_set(new DateTime(), $this->getProp($messageProps, "reminder_time"))); // trigger type "DATE-TIME" - $valarm->TRIGGER['VALUE'] = 'DATE-TIME'; - */ - } - - // Add location - $location = $this->getProp($messageProps, "location"); - if (!empty($location)) { - $vEvent->add('LOCATION', $this->getProp($messageProps, "location")); - } - - // Add description - $body = $this->getProp($messageProps, "isHTML") ? $this->getProp($messageProps, "html_body") : $this->getProp($messageProps, "body"); - if (!empty($body)) { - $vEvent->add('DESCRIPTION', $body); - } - - // Add categories - $categories = $this->getProp($messageProps, "categories"); - if (!empty($categories)) { - $categoryArray = array_map('trim', explode(';', trim($categories, " ;"))); - - $vEvent->add('CATEGORIES', $categoryArray); - } - } - - // write combined ics file - file_put_contents($file, file_get_contents($file) . $vCalendar->serialize()); - } - - if (count($records) > 0) { - $response['status'] = true; - $response['download_token'] = $token; - // TRANSLATORS: Filename suffix for exported files - $response['filename'] = count($records) . dgettext("plugin_calendarimporter", "_events.ics"); - } else { - $response['status'] = false; - $response['message'] = dgettext("plugin_calendarimporter", "No events found. Export skipped!"); - } - - $this->addActionData($actionType, $response); - $GLOBALS["bus"]->addData($this->getResponseData()); - } - - /** - * The main import function, parses the uploaded ics file - * @param $actionType - * @param $actionData - */ - private function importCalendar($actionType, $actionData) - { - // Get uploaded vcf path - $icsFile = false; - if (isset($actionData["ics_filepath"])) { - $icsFile = $actionData["ics_filepath"]; - } - - // Get store id - $storeid = false; - if (isset($actionData["storeid"])) { - $storeid = $actionData["storeid"]; - } - - // Get folder entryid - $folderId = false; - if (isset($actionData["folderid"])) { - $folderId = $actionData["folderid"]; - } - - // Get uids - $uids = array(); - if (isset($actionData["uids"])) { - $uids = $actionData["uids"]; - } - - $response = array(); - $error = false; - $error_msg = ""; - - // parse the ics file a last time... - $parser = null; - try { - $parser = VObject\Reader::read( - fopen($icsFile, 'r') - ); - } catch (Exception $e) { - $error = true; - $error_msg = $e->getMessage(); - } - - $events = array(); - if (count($parser->VEVENT) > 0) { - $events = $this->parseCalendarToArray($parser); - $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid)); - $folder = mapi_msgstore_openentry($store, hex2bin($folderId)); - - $importAll = false; - if (count($uids) == count($events)) { - $importAll = true; - } - - $propValuesMAPI = array(); - $properties = $GLOBALS['properties']->getAppointmentProperties(); - // extend properties... - $properties["body"] = PR_BODY; - - $count = 0; - - // iterate through all events and import them :) - foreach ($events as $event) { - if (isset($event["startdate"]) && ($importAll || in_array($event["internal_fields"]["event_uid"], $uids))) { - - $message = mapi_folder_createmessage($folder); - - // parse the arraykeys - foreach ($event as $key => $value) { - if ($key !== "internal_fields") { - if (isset($properties[$key])) { - $propValuesMAPI[$properties[$key]] = $value; - } - } - } - - $propValuesMAPI[$properties["commonstart"]] = $propValuesMAPI[$properties["startdate"]]; - $propValuesMAPI[$properties["commonend"]] = $propValuesMAPI[$properties["duedate"]]; - $propValuesMAPI[$properties["duration"]] = ($propValuesMAPI[$properties["duedate"]] - $propValuesMAPI[$properties["startdate"]]) / 60; // Minutes needed - $propValuesMAPI[$properties["reminder"]] = false; // needed, overwritten if there is a timer - - $propValuesMAPI[$properties["message_class"]] = "IPM.Appointment"; - $propValuesMAPI[$properties["icon_index"]] = "1024"; - - // TODO: set attendees and alarms - - mapi_setprops($message, $propValuesMAPI); - mapi_savechanges($message); - if ($this->DEBUG) { - error_log("New event added: \"" . $event["subject"] . "\".\n"); - } - $count++; - } - } - - $response['status'] = true; - $response['count'] = $count; - $response['message'] = ""; - - } else { - $response['status'] = false; - $response['count'] = 0; - $response['message'] = $error ? $error_msg : dgettext("plugin_calendarimporter", "ICS file empty!"); - } - - $this->addActionData($actionType, $response); - $GLOBALS["bus"]->addData($this->getResponseData()); - } - - /** - * Store the file to a temporary directory, prepare it for oc upload - * @param $actionType - * @param $actionData - * @private - */ - private function getAttachmentPath($actionType, $actionData) - { - // Get store id - $storeId = false; - if (isset($actionData["store"])) { - $storeId = $actionData["store"]; - } - - // Get message entryid - $entryId = false; - if (isset($actionData["entryid"])) { - $entryId = $actionData["entryid"]; - } - - // Check which type isset - $openType = "attachment"; - - // Get number of attachment which should be opened. - $attachNum = false; - if (isset($actionData["attachNum"])) { - $attachNum = $actionData["attachNum"]; - } - - // Check if storeid and entryid isset - if ($storeId && $entryId) { - // Open the store - $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId)); - - if ($store) { - // Open the message - $message = mapi_msgstore_openentry($store, hex2bin($entryId)); - - if ($message) { - $attachment = false; - - // Check if attachNum isset - if ($attachNum) { - // Loop through the attachNums, message in message in message ... - for ($i = 0; $i < (count($attachNum) - 1); $i++) { - // Open the attachment - $tempAttach = mapi_message_openattach($message, (int)$attachNum[$i]); - if ($tempAttach) { - // Open the object in the attachment - $message = mapi_attach_openobj($tempAttach); - } - } - - // Open the attachment - $attachment = mapi_message_openattach($message, (int)$attachNum[(count($attachNum) - 1)]); - } - - // Check if the attachment is opened - if ($attachment) { - - // Get the props of the attachment - $props = mapi_attach_getprops($attachment, array(PR_ATTACH_LONG_FILENAME, PR_ATTACH_MIME_TAG, PR_DISPLAY_NAME, PR_ATTACH_METHOD)); - // Content Type - $contentType = "application/octet-stream"; - // Filename - $filename = "ERROR"; - - // Set filename - if (isset($props[PR_ATTACH_LONG_FILENAME])) { - $filename = $props[PR_ATTACH_LONG_FILENAME]; - } else { - if (isset($props[PR_ATTACH_FILENAME])) { - $filename = $props[PR_ATTACH_FILENAME]; - } else { - if (isset($props[PR_DISPLAY_NAME])) { - $filename = $props[PR_DISPLAY_NAME]; - } - } - } - - // Set content type - if (isset($props[PR_ATTACH_MIME_TAG])) { - $contentType = $props[PR_ATTACH_MIME_TAG]; - } else { - // Parse the extension of the filename to get the content type - if (strrpos($filename, ".") !== false) { - $extension = strtolower(substr($filename, strrpos($filename, "."))); - $contentType = "application/octet-stream"; - if (is_readable("mimetypes.dat")) { - $fh = fopen("mimetypes.dat", "r"); - $ext_found = false; - while (!feof($fh) && !$ext_found) { - $line = fgets($fh); - preg_match('/(\.[a-z0-9]+)[ \t]+([^ \t\n\r]*)/i', $line, $result); - if ($extension == $result[1]) { - $ext_found = true; - $contentType = $result[2]; - } - } - fclose($fh); - } - } - } - - - $tmpName = tempnam(TMP_PATH, stripslashes($filename)); - - // Open a stream to get the attachment data - $stream = mapi_openpropertytostream($attachment, PR_ATTACH_DATA_BIN); - $stat = mapi_stream_stat($stream); - // File length = $stat["cb"] - - $fHandle = fopen($tmpName, 'w'); - $buffer = null; - for ($i = 0; $i < $stat["cb"]; $i += BLOCK_SIZE) { - // Write stream - $buffer = mapi_stream_read($stream, BLOCK_SIZE); - fwrite($fHandle, $buffer, strlen($buffer)); - } - fclose($fHandle); - - $response = array(); - $response['tmpname'] = $tmpName; - $response['filename'] = $filename; - $response['contenttype'] = $contentType; - $response['status'] = true; - $this->addActionData($actionType, $response); - $GLOBALS["bus"]->addData($this->getResponseData()); - } - } - } else { - $response['status'] = false; - $response['message'] = dgettext("plugin_calendarimporter", "Store could not be opened!"); - $this->addActionData($actionType, $response); - $GLOBALS["bus"]->addData($this->getResponseData()); - } - } else { - $response['status'] = false; - $response['message'] = dgettext("plugin_calendarimporter", "Wrong call, store and entryid have to be set!"); - $this->addActionData($actionType, $response); - $GLOBALS["bus"]->addData($this->getResponseData()); - } - } - - /** - * Function that parses the uploaded ics file and posts it via json - * @param $actionType - * @param $actionData - */ - private function loadCalendar($actionType, $actionData) - { - $error = false; - $errorMsg = ""; - - if (is_readable($actionData["ics_filepath"])) { - $parser = null; - - try { - $parser = VObject\Reader::read( - fopen($actionData["ics_filepath"], 'r') - ); - //error_log(print_r($parser->VTIMEZONE, true)); - } catch (Exception $e) { - $error = true; - $errorMsg = $e->getMessage(); - } - if ($error) { - $response['status'] = false; - $response['message'] = $errorMsg; - } else { - if (count($parser->VEVENT) == 0) { - $response['status'] = false; - $response['message'] = dgettext("plugin_calendarimporter", "No event in ics file"); - } else { - $response['status'] = true; - $response['parsed_file'] = $actionData["ics_filepath"]; - $response['parsed'] = array( - 'events' => $this->parseCalendarToArray($parser), - 'timezone' => isset($parser->VTIMEZONE->TZID) ? (string)$parser->VTIMEZONE->TZID : (string)$parser->{'X-WR-TIMEZONE'}, - 'calendar' => (string)$parser->PRODID - ); - } - } - } else { - $response['status'] = false; - $response['message'] = dgettext("plugin_calendarimporter", "File could not be read by server"); - } - - $this->addActionData($actionType, $response); - $GLOBALS["bus"]->addData($this->getResponseData()); - - if ($this->DEBUG) { - error_log("parsing done, bus data written!"); - } - } - - /** - * Create a array with contacts - * - * @param {VObject} $calendar ics parser object - * @return array parsed events - * @private - */ - private function parseCalendarToArray($calendar) - { - $events = array(); - foreach ($calendar->VEVENT as $Index => $vEvent) { - // Sabre\VObject\Parser\XML\Element\VEvent - $properties = array(); - - //uid - used for front/backend communication - $properties["internal_fields"] = array(); - $properties["internal_fields"]["event_uid"] = base64_encode($Index . $vEvent->UID); - - $properties["startdate"] = (string)$vEvent->DTSTART->getDateTime()->getTimestamp(); - $properties["duedate"] = (string)$vEvent->DTEND->getDateTime()->getTimestamp(); - $properties["location"] = (string)$vEvent->LOCATION; - $properties["subject"] = (string)$vEvent->SUMMARY; - $properties["body"] = (string)$vEvent->DESCRIPTION; - $properties["comment"] = (string)$vEvent->COMMENT; - $properties["timezone"] = (string)$vEvent->DTSTART["TZID"]; - $properties["organizer"] = (string)$vEvent->ORGANIZER; - - $fbType = (string)$vEvent->FBTYPE; - $msIntendedStatus = (string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}; - $msBusyStatus = (string)$vEvent->{'X-MICROSOFT-CDO-BUSYSTATUS'}; - if(!empty($fbType)) { - $properties["busystatus"] = array_search($fbType, $this->freeBusyStates); - } else if(!empty($msIntendedStatus)) { - $properties["busystatus"] = array_search($msIntendedStatus, $this->busyStates); - } else if(!empty($msBusyStatus)) { - $properties["busystatus"] = array_search($msBusyStatus, $this->busyStates); - } else { - $properties["busystatus"] = array_search("BUSY", $this->busyStates); - } - $properties["transp"] = (string)$vEvent->TRANSP; - //$properties["trigger"] = (string)$vEvent->COMMENT; - $properties["priority"] = (string)$vEvent->PRIORITY; - $properties["private"] = ((string)$vEvent->CLASS) == "PRIVATE" ? true : false; - $zLabel = (string)$vEvent->{'X-ZARAFA-LABEL'}; - if (!empty($zLabel)) { - $properties["label"] = array_search($zLabel, $this->labels); - } - $lastModified = (string)$vEvent->{'LAST-MODIFIED'}; - if (!empty($lastModified)) { - $properties["last_modification_time"] = (string)$vEvent->{'LAST-MODIFIED'}->getDateTime()->getTimestamp(); - } else { - $properties["last_modification_time"] = time(); - } - $created = (string)$vEvent->CREATED; - if (!empty($created)) { - $properties["creation_time"] = (string)$vEvent->CREATED->getDateTime()->getTimestamp(); - } else { - $properties["creation_time"] = time(); - } - $properties["rrule"] = (string)$vEvent->RRULE; - - if (isset($vEvent->CATEGORIES) && count($vEvent->CATEGORIES) > 0) { - $categories = array(); - foreach ($vEvent->CATEGORIES as $category) { - $categories[] = (string) $category; - } - - $properties["categories"] = $categories; - } - - // Attendees - $properties["attendees"] = array(); - if (isset($vEvent->ATTENDEE) && count($vEvent->ATTENDEE) > 0) { - foreach ($vEvent->ATTENDEE as $attendee) { - $properties["attendees"][] = array( - "name" => (string)$attendee["CN"], - "mail" => (string)$attendee, - "status" => (string)$attendee["PARTSTAT"], - "role" => (string)$attendee["ROLE"] - ); - } - } - - // Alarms - $properties["alarms"] = array(); - if (isset($vEvent->VALARM) && count($vEvent->VALARM) > 0) { - foreach ($vEvent->VALARM as $alarm) { - $properties["alarms"][] = array( - "description" => (string)$alarm->DESCRIPTION, - "trigger" => (string)$alarm->TRIGGER, - "type" => (string)$alarm->TRIGGER["VALUE"] - ); - } - } - - array_push($events, $properties); - } - - return $events; - } -} + + * Copyright (C) 2012-2016 Christoph Haas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +include_once(__DIR__ . "/vendor/autoload.php"); +include_once(__DIR__ . "/helper.php"); + +use Sabre\VObject; +use calendarimporter\Helper; + +class CalendarModule extends Module +{ + + private $DEBUG = false; // enable error_log debugging + + private $busyStates = null; + + private $labels = null; + + private $attendeeType = null; + + /** + * @constructor + * @param $id + * @param $data + */ + public function __construct($id, $data) + { + parent::__construct($id, $data); + + // init default timezone + date_default_timezone_set(PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE); + + // init mappings + $this->busyStates = array( + "FREE", + "TENTATIVE", + "BUSY", + "OOF" + ); + + $this->freeBusyStates = array( // http://www.kanzaki.com/docs/ical/fbtype.html + "FREE", + "BUSY-TENTATIVE", + "BUSY", + "BUSY-UNAVAILABLE" + ); + + $this->labels = array( + "NONE", + "IMPORTANT", + "WORK", + "PERSONAL", + "HOLIDAY", + "REQUIRED", + "TRAVEL REQUIRED", + "PREPARATION REQUIERED", + "BIRTHDAY", + "SPECIAL DATE", + "PHONE INTERVIEW" + ); + + $this->attendeeType = array( + "NON-PARTICIPANT", // needed as zarafa starts counting at 1 + "REQ-PARTICIPANT", + "OPT-PARTICIPANT", + "NON-PARTICIPANT" + ); + } + + /** + * Executes all the actions in the $data variable. + * Exception part is used for authentication errors also + * + * @return boolean true on success or false on failure. + */ + public function execute() + { + $result = false; + + if (!$this->DEBUG) { + /* disable error printing - otherwise json communication might break... */ + ini_set('display_errors', '0'); + } + + foreach ($this->data as $actionType => $actionData) { + if (isset($actionType)) { + try { + if ($this->DEBUG) { + error_log("exec: " . $actionType); + } + switch ($actionType) { + case "load": + $result = $this->loadCalendar($actionType, $actionData); + break; + case "export": + $result = $this->exportCalendar($actionType, $actionData); + break; + case "import": + $result = $this->importCalendar($actionType, $actionData); + break; + case "importattachment": + $result = $this->getAttachmentPath($actionType, $actionData); + break; + default: + $this->handleUnknownActionType($actionType); + } + + } catch (MAPIException $e) { + if ($this->DEBUG) { + error_log("mapi exception: " . $e->getMessage()); + } + } catch (Exception $e) { + if ($this->DEBUG) { + error_log("exception: " . $e->getMessage()); + } + } + } + } + + return $result; + } + + /** + * Get a property from the array. + * + * @param $props + * @param $propName + * @return string + */ + private function getProp($props, $propName) + { + if (isset($props["props"][$propName])) { + return $props["props"][$propName]; + } + return ""; + } + + /** + * Get a duration string form given minutes + * + * @param $minutes + * @param bool $pos + * @return string + */ + private function getDurationStringFromMinutes($minutes, $pos = false) + { + $pos = $pos === true ? "+" : "-"; + $str = $pos . "P"; + + + // variables for holding values + $min = intval($minutes); + $hours = 0; + $days = 0; + $weeks = 0; + + // calculations + if ($min >= 60) { + $hours = (int)($min / 60); + $min = $min % 60; + } + if ($hours >= 24) { + $days = (int)($hours / 24); + $hours = $hours % 60; + } + if ($days >= 7) { + $weeks = (int)($days / 7); + $days = $days % 7; + } + + // format result + if ($weeks) { + $str .= "{$weeks}W"; + } + if ($days) { + $str .= "{$days}D"; + } + if ($hours) { + $str .= "{$hours}H"; + } + if ($min) { + $str .= "{$min}M"; + } + + return $str; + } + + /** + * The main export function, creates the ics file for download + * + * @param $actionType + * @param $actionData + */ + private function exportCalendar($actionType, $actionData) + { + // Get store id + $storeId = false; + if (isset($actionData["storeid"])) { + $storeId = $actionData["storeid"]; + } + + // Get records + $records = array(); + if (isset($actionData["records"])) { + $records = $actionData["records"]; + } + + // Get folders + $folder = false; + if (isset($actionData["folder"])) { + $folder = $actionData["folder"]; + } + + $response = array(); + $error = false; + $error_msg = ""; + + // write csv + $token = Helper::randomstring(16); + $file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics"; + file_put_contents($file, ""); + + $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId)); + if ($store) { + // load folder first + if ($folder !== false) { + $mapiFolder = mapi_msgstore_openentry($store, hex2bin($folder)); + + $table = mapi_folder_getcontentstable($mapiFolder); + $list = mapi_table_queryallrows($table, array(PR_ENTRYID)); + + foreach ($list as $item) { + $records[] = bin2hex($item[PR_ENTRYID]); + } + } + + $vCalendar = new VObject\Component\VCalendar(); + + // Add static stuff to vCalendar + $vCalendar->add('METHOD', 'PUBLISH'); + $vCalendar->add('X-WR-CALDESC', 'Exported Kopano Calendar'); + $vCalendar->add('X-WR-TIMEZONE', date_default_timezone_get()); + + // TODO: add VTIMEZONE object to ical. + + for ($index = 0, $count = count($records); $index < $count; $index++) { + $message = mapi_msgstore_openentry($store, hex2bin($records[$index])); + + // get message properties. + $properties = $GLOBALS['properties']->getAppointmentProperties(); + $plaintext = true; + $messageProps = $GLOBALS['operations']->getMessageProps($store, $message, $properties, $plaintext); + + $vEvent = $vCalendar->add('VEVENT', [ + 'SUMMARY' => $this->getProp($messageProps, "subject"), + 'DTSTART' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "startdate")), + 'DTEND' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "duedate")), + 'CREATED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "creation_time")), + 'LAST-MODIFIED' => date_timestamp_set(new DateTime(), $this->getProp($messageProps, "last_modification_time")), + 'PRIORITY' => intval($this->getProp($messageProps, "importance")), + 'X-MICROSOFT-CDO-INTENDEDSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid... + 'X-MICROSOFT-CDO-BUSYSTATUS' => $this->busyStates[intval($this->getProp($messageProps, "busystatus"))], // both seem to be valid... + 'FBTYPE' => $this->freeBusyStates[intval($this->getProp($messageProps, "busystatus"))], + 'X-ZARAFA-LABEL' => $this->labels[intval($this->getProp($messageProps, "label"))], + 'CLASS' => $this->getProp($messageProps, "private") ? "PRIVATE" : "PUBLIC", + 'COMMENT' => "eid:" . $records[$index] + ]); + + // Add organizer + $organizer = $this->getProp($messageProps, "sender_email_address"); + if(!empty($organizer)) { + $vEvent->add('ORGANIZER', 'mailto:' . $organizer); + $vEvent->ORGANIZER['CN'] = $this->getProp($messageProps, "sender_name"); + } + + // Add Attendees + if (isset($messageProps["recipients"]) && count($messageProps["recipients"]["item"]) > 0) { + foreach ($messageProps["recipients"]["item"] as $attendee) { + $att = $vEvent->add('ATTENDEE', "mailto:" . $this->getProp($attendee, "email_address")); + $att["CN"] = $this->getProp($attendee, "display_name"); + $att["ROLE"] = $this->attendeeType[intval($this->getProp($attendee, "recipient_type"))]; + } + } + + // Add alarms + $reminder = $this->getProp($messageProps, "reminder"); + if (!empty($reminder) && $this->getProp($messageProps, "reminder") == 1) { + $vAlarm = $vEvent->add('VALARM', [ + 'ACTION' => 'DISPLAY', + 'DESCRIPTION' => $this->getProp($messageProps, "subject") // reuse the event summary + ]); + + // Add trigger + $durationValue = $this->getDurationStringFromMinutes($this->getProp($messageProps, "reminder_minutes"), false); + $vAlarm->add('TRIGGER', $durationValue); // default trigger type is duration (see 4.8.6.3) + + /* + $valarm->add('TRIGGER', date_timestamp_set(new DateTime(), $this->getProp($messageProps, "reminder_time"))); // trigger type "DATE-TIME" + $valarm->TRIGGER['VALUE'] = 'DATE-TIME'; + */ + } + + // Add location + $location = $this->getProp($messageProps, "location"); + if (!empty($location)) { + $vEvent->add('LOCATION', $this->getProp($messageProps, "location")); + } + + // Add description + $body = $this->getProp($messageProps, "isHTML") ? $this->getProp($messageProps, "html_body") : $this->getProp($messageProps, "body"); + if (!empty($body)) { + $vEvent->add('DESCRIPTION', $body); + } + + // Add categories + $categories = $this->getProp($messageProps, "categories"); + if (!empty($categories)) { + $categoryArray = array_map('trim', explode(';', trim($categories, " ;"))); + + $vEvent->add('CATEGORIES', $categoryArray); + } + } + + // write combined ics file + file_put_contents($file, file_get_contents($file) . $vCalendar->serialize()); + } + + if (count($records) > 0) { + $response['status'] = true; + $response['download_token'] = $token; + // TRANSLATORS: Filename suffix for exported files + $response['filename'] = count($records) . dgettext("plugin_calendarimporter", "_events.ics"); + } else { + $response['status'] = false; + $response['message'] = dgettext("plugin_calendarimporter", "No events found. Export skipped!"); + } + + $this->addActionData($actionType, $response); + $GLOBALS["bus"]->addData($this->getResponseData()); + } + + /** + * The main import function, parses the uploaded ics file + * @param $actionType + * @param $actionData + */ + private function importCalendar($actionType, $actionData) + { + // Get uploaded vcf path + $icsFile = false; + if (isset($actionData["ics_filepath"])) { + $icsFile = $actionData["ics_filepath"]; + } + + // Get store id + $storeid = false; + if (isset($actionData["storeid"])) { + $storeid = $actionData["storeid"]; + } + + // Get folder entryid + $folderId = false; + if (isset($actionData["folderid"])) { + $folderId = $actionData["folderid"]; + } + + // Get uids + $uids = array(); + if (isset($actionData["uids"])) { + $uids = $actionData["uids"]; + } + + $response = array(); + $error = false; + $error_msg = ""; + + // parse the ics file a last time... + $parser = null; + try { + $parser = VObject\Reader::read( + fopen($icsFile, 'r') + ); + } catch (Exception $e) { + $error = true; + $error_msg = $e->getMessage(); + } + + $events = array(); + if (count($parser->VEVENT) > 0) { + $events = $this->parseCalendarToArray($parser); + $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid)); + $folder = mapi_msgstore_openentry($store, hex2bin($folderId)); + + $importAll = false; + if (count($uids) == count($events)) { + $importAll = true; + } + + $propValuesMAPI = array(); + $properties = $GLOBALS['properties']->getAppointmentProperties(); + // extend properties... + $properties["body"] = PR_BODY; + + $count = 0; + + // iterate through all events and import them :) + foreach ($events as $event) { + if (isset($event["startdate"]) && ($importAll || in_array($event["internal_fields"]["event_uid"], $uids))) { + + $message = mapi_folder_createmessage($folder); + + // parse the arraykeys + foreach ($event as $key => $value) { + if ($key !== "internal_fields") { + if (isset($properties[$key])) { + $propValuesMAPI[$properties[$key]] = $value; + } + } + } + + $propValuesMAPI[$properties["commonstart"]] = $propValuesMAPI[$properties["startdate"]]; + $propValuesMAPI[$properties["commonend"]] = $propValuesMAPI[$properties["duedate"]]; + $propValuesMAPI[$properties["duration"]] = ($propValuesMAPI[$properties["duedate"]] - $propValuesMAPI[$properties["startdate"]]) / 60; // Minutes needed + $propValuesMAPI[$properties["reminder"]] = false; // needed, overwritten if there is a timer + + $propValuesMAPI[$properties["message_class"]] = "IPM.Appointment"; + $propValuesMAPI[$properties["icon_index"]] = "1024"; + + // TODO: set attendees and alarms + + mapi_setprops($message, $propValuesMAPI); + mapi_savechanges($message); + if ($this->DEBUG) { + error_log("New event added: \"" . $event["subject"] . "\".\n"); + } + $count++; + } + } + + $response['status'] = true; + $response['count'] = $count; + $response['message'] = ""; + + } else { + $response['status'] = false; + $response['count'] = 0; + $response['message'] = $error ? $error_msg : dgettext("plugin_calendarimporter", "ICS file empty!"); + } + + $this->addActionData($actionType, $response); + $GLOBALS["bus"]->addData($this->getResponseData()); + } + + /** + * Store the file to a temporary directory, prepare it for oc upload + * @param $actionType + * @param $actionData + * @private + */ + private function getAttachmentPath($actionType, $actionData) + { + // Get store id + $storeId = false; + if (isset($actionData["store"])) { + $storeId = $actionData["store"]; + } + + // Get message entryid + $entryId = false; + if (isset($actionData["entryid"])) { + $entryId = $actionData["entryid"]; + } + + // Check which type isset + $openType = "attachment"; + + // Get number of attachment which should be opened. + $attachNum = false; + if (isset($actionData["attachNum"])) { + $attachNum = $actionData["attachNum"]; + } + + // Check if storeid and entryid isset + if ($storeId && $entryId) { + // Open the store + $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeId)); + + if ($store) { + // Open the message + $message = mapi_msgstore_openentry($store, hex2bin($entryId)); + + if ($message) { + $attachment = false; + + // Check if attachNum isset + if ($attachNum) { + // Loop through the attachNums, message in message in message ... + for ($i = 0; $i < (count($attachNum) - 1); $i++) { + // Open the attachment + $tempAttach = mapi_message_openattach($message, (int)$attachNum[$i]); + if ($tempAttach) { + // Open the object in the attachment + $message = mapi_attach_openobj($tempAttach); + } + } + + // Open the attachment + $attachment = mapi_message_openattach($message, (int)$attachNum[(count($attachNum) - 1)]); + } + + // Check if the attachment is opened + if ($attachment) { + + // Get the props of the attachment + $props = mapi_attach_getprops($attachment, array(PR_ATTACH_LONG_FILENAME, PR_ATTACH_MIME_TAG, PR_DISPLAY_NAME, PR_ATTACH_METHOD)); + // Content Type + $contentType = "application/octet-stream"; + // Filename + $filename = "ERROR"; + + // Set filename + if (isset($props[PR_ATTACH_LONG_FILENAME])) { + $filename = $props[PR_ATTACH_LONG_FILENAME]; + } else { + if (isset($props[PR_ATTACH_FILENAME])) { + $filename = $props[PR_ATTACH_FILENAME]; + } else { + if (isset($props[PR_DISPLAY_NAME])) { + $filename = $props[PR_DISPLAY_NAME]; + } + } + } + + // Set content type + if (isset($props[PR_ATTACH_MIME_TAG])) { + $contentType = $props[PR_ATTACH_MIME_TAG]; + } else { + // Parse the extension of the filename to get the content type + if (strrpos($filename, ".") !== false) { + $extension = strtolower(substr($filename, strrpos($filename, "."))); + $contentType = "application/octet-stream"; + if (is_readable("mimetypes.dat")) { + $fh = fopen("mimetypes.dat", "r"); + $ext_found = false; + while (!feof($fh) && !$ext_found) { + $line = fgets($fh); + preg_match('/(\.[a-z0-9]+)[ \t]+([^ \t\n\r]*)/i', $line, $result); + if ($extension == $result[1]) { + $ext_found = true; + $contentType = $result[2]; + } + } + fclose($fh); + } + } + } + + + $tmpName = tempnam(TMP_PATH, stripslashes($filename)); + + // Open a stream to get the attachment data + $stream = mapi_openpropertytostream($attachment, PR_ATTACH_DATA_BIN); + $stat = mapi_stream_stat($stream); + // File length = $stat["cb"] + + $fHandle = fopen($tmpName, 'w'); + $buffer = null; + for ($i = 0; $i < $stat["cb"]; $i += BLOCK_SIZE) { + // Write stream + $buffer = mapi_stream_read($stream, BLOCK_SIZE); + fwrite($fHandle, $buffer, strlen($buffer)); + } + fclose($fHandle); + + $response = array(); + $response['tmpname'] = $tmpName; + $response['filename'] = $filename; + $response['contenttype'] = $contentType; + $response['status'] = true; + $this->addActionData($actionType, $response); + $GLOBALS["bus"]->addData($this->getResponseData()); + } + } + } else { + $response['status'] = false; + $response['message'] = dgettext("plugin_calendarimporter", "Store could not be opened!"); + $this->addActionData($actionType, $response); + $GLOBALS["bus"]->addData($this->getResponseData()); + } + } else { + $response['status'] = false; + $response['message'] = dgettext("plugin_calendarimporter", "Wrong call, store and entryid have to be set!"); + $this->addActionData($actionType, $response); + $GLOBALS["bus"]->addData($this->getResponseData()); + } + } + + /** + * Function that parses the uploaded ics file and posts it via json + * @param $actionType + * @param $actionData + */ + private function loadCalendar($actionType, $actionData) + { + $error = false; + $errorMsg = ""; + + if (is_readable($actionData["ics_filepath"])) { + $parser = null; + + try { + $parser = VObject\Reader::read( + fopen($actionData["ics_filepath"], 'r') + ); + //error_log(print_r($parser->VTIMEZONE, true)); + } catch (Exception $e) { + $error = true; + $errorMsg = $e->getMessage(); + } + if ($error) { + $response['status'] = false; + $response['message'] = $errorMsg; + } else { + if (count($parser->VEVENT) == 0) { + $response['status'] = false; + $response['message'] = dgettext("plugin_calendarimporter", "No event in ics file"); + } else { + $response['status'] = true; + $response['parsed_file'] = $actionData["ics_filepath"]; + $response['parsed'] = array( + 'events' => $this->parseCalendarToArray($parser), + 'timezone' => isset($parser->VTIMEZONE->TZID) ? (string)$parser->VTIMEZONE->TZID : (string)$parser->{'X-WR-TIMEZONE'}, + 'calendar' => (string)$parser->PRODID + ); + } + } + } else { + $response['status'] = false; + $response['message'] = dgettext("plugin_calendarimporter", "File could not be read by server"); + } + + $this->addActionData($actionType, $response); + $GLOBALS["bus"]->addData($this->getResponseData()); + + if ($this->DEBUG) { + error_log("parsing done, bus data written!"); + } + } + + /** + * Create a array with contacts + * + * @param {VObject} $calendar ics parser object + * @return array parsed events + * @private + */ + private function parseCalendarToArray($calendar) + { + $events = array(); + foreach ($calendar->VEVENT as $Index => $vEvent) { + // Sabre\VObject\Parser\XML\Element\VEvent + $properties = array(); + + //uid - used for front/backend communication + $properties["internal_fields"] = array(); + $properties["internal_fields"]["event_uid"] = base64_encode($Index . $vEvent->UID); + + $properties["startdate"] = (string)$vEvent->DTSTART->getDateTime()->getTimestamp(); + $properties["duedate"] = (string)$vEvent->DTEND->getDateTime()->getTimestamp(); + $properties["location"] = (string)$vEvent->LOCATION; + $properties["subject"] = (string)$vEvent->SUMMARY; + $properties["body"] = (string)$vEvent->DESCRIPTION; + $properties["comment"] = (string)$vEvent->COMMENT; + $properties["timezone"] = (string)$vEvent->DTSTART["TZID"]; + $properties["organizer"] = (string)$vEvent->ORGANIZER; + + $fbType = (string)$vEvent->FBTYPE; + $msIntendedStatus = (string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}; + $msBusyStatus = (string)$vEvent->{'X-MICROSOFT-CDO-BUSYSTATUS'}; + if(!empty($fbType)) { + $properties["busystatus"] = array_search($fbType, $this->freeBusyStates); + } else if(!empty($msIntendedStatus)) { + $properties["busystatus"] = array_search($msIntendedStatus, $this->busyStates); + } else if(!empty($msBusyStatus)) { + $properties["busystatus"] = array_search($msBusyStatus, $this->busyStates); + } else { + $properties["busystatus"] = array_search("BUSY", $this->busyStates); + } + $properties["transp"] = (string)$vEvent->TRANSP; + //$properties["trigger"] = (string)$vEvent->COMMENT; + $properties["priority"] = (string)$vEvent->PRIORITY; + $properties["private"] = ((string)$vEvent->CLASS) == "PRIVATE" ? true : false; + $zLabel = (string)$vEvent->{'X-ZARAFA-LABEL'}; + if (!empty($zLabel)) { + $properties["label"] = array_search($zLabel, $this->labels); + } + $lastModified = (string)$vEvent->{'LAST-MODIFIED'}; + if (!empty($lastModified)) { + $properties["last_modification_time"] = (string)$vEvent->{'LAST-MODIFIED'}->getDateTime()->getTimestamp(); + } else { + $properties["last_modification_time"] = time(); + } + $created = (string)$vEvent->CREATED; + if (!empty($created)) { + $properties["creation_time"] = (string)$vEvent->CREATED->getDateTime()->getTimestamp(); + } else { + $properties["creation_time"] = time(); + } + $properties["rrule"] = (string)$vEvent->RRULE; + + if (isset($vEvent->CATEGORIES) && count($vEvent->CATEGORIES) > 0) { + $categories = array(); + foreach ($vEvent->CATEGORIES as $category) { + $categories[] = (string) $category; + } + + $properties["categories"] = $categories; + } + + // Attendees + $properties["attendees"] = array(); + if (isset($vEvent->ATTENDEE) && count($vEvent->ATTENDEE) > 0) { + foreach ($vEvent->ATTENDEE as $attendee) { + $properties["attendees"][] = array( + "name" => (string)$attendee["CN"], + "mail" => (string)$attendee, + "status" => (string)$attendee["PARTSTAT"], + "role" => (string)$attendee["ROLE"] + ); + } + } + + // Alarms + $properties["alarms"] = array(); + if (isset($vEvent->VALARM) && count($vEvent->VALARM) > 0) { + foreach ($vEvent->VALARM as $alarm) { + $properties["alarms"][] = array( + "description" => (string)$alarm->DESCRIPTION, + "trigger" => (string)$alarm->TRIGGER, + "type" => (string)$alarm->TRIGGER["VALUE"] + ); + } + } + + array_push($events, $properties); + } + + return $events; + } +} diff --git a/resources/css/calendarimporter-main.css b/resources/css/calendarimporter-main.css index f4e3106..965087f 100644 --- a/resources/css/calendarimporter-main.css +++ b/resources/css/calendarimporter-main.css @@ -1,30 +1,30 @@ -.icon_calendarimporter_button { - background: url(../images/import_icon.png) no-repeat; - background-repeat: no-repeat; - background-position: center; -} - -.icon_calendarimporter_export { - background: url(../images/download.png) no-repeat; - background-repeat: no-repeat; - background-position: center; -} - -.icon_calendarimporter_import { - background: url(../images/upload.png) no-repeat; - background-repeat: no-repeat; - background-position: center; -} - -.zarafa-caiplg-container { - width: 100%; - height: 50px; -} - -.zarafa-caiplg-button .x-btn-small { - width: 80%; - height: 30px; - margin-left: 10%; - margin-right: 10%; - margin-top: 10px; -} +.icon_calendarimporter_button { + background: url(../images/import_icon.png) no-repeat; + background-repeat: no-repeat; + background-position: center; +} + +.icon_calendarimporter_export { + background: url(../images/download.png) no-repeat; + background-repeat: no-repeat; + background-position: center; +} + +.icon_calendarimporter_import { + background: url(../images/upload.png) no-repeat; + background-repeat: no-repeat; + background-position: center; +} + +.zarafa-caiplg-container { + width: 100%; + height: 50px; +} + +.zarafa-caiplg-button .x-btn-small { + width: 80%; + height: 30px; + margin-left: 10%; + margin-right: 10%; + margin-top: 10px; +}