Line endings

This commit is contained in:
Christoph Haas 2016-12-16 14:51:04 +01:00
parent d6783cbc83
commit 9cb9978adc
21 changed files with 3670 additions and 3639 deletions

View File

@ -1,14 +1,14 @@
Backend setup: Backend setup:
1. Create a Admin User in Zarafa: 1. Create a Admin User in Kopano:
zarafa-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1 kopano-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1
2. Edit the config.php to fit your needs. 2. Edit the config.php to fit your needs.
3. Setup cron to run your script every 10 minutes (or whatever...) 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: 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 * Add: /etc/php5/cli/conf.d/50-mapi.ini
* Content: extension=mapi.so * Content: extension=mapi.so
Never run the backend script as root! Never run the backend script as root!

View File

@ -1 +1,7 @@
<?php // config options $ADMINUSERNAME = "admin"; $ADMINPASSWORD = "admin"; $SERVER = "file:///var/run/zarafa"; $CALDAVURL = "http://localhost:8080/ical/"; $TEMPDIR = "/tmp/"; ?> <?php
// config options
$ADMINUSERNAME = "admin"; // Kopano administrative user
$ADMINPASSWORD = "admin"; // Kopano administrative user password
$SERVER = "file:///var/run/zarafa"; // Kopano socket or http(s) connection
$CALDAVURL = "http://localhost:8080/ical/"; // Caldav URL
$TEMPDIR = "/tmp/"; // Temporary directory for storing downloaded ics files

View File

@ -1,165 +1,191 @@
<?php <?php
/** /**
* functions.php, zarafa calender to ics im/exporter backend * functions.php, Kopano calender to ics im/exporter backend
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* */
*/
/**
/* gets the data from a URL */ * gets the data from a URL
function curl_get_data($url, $username = NULL, $password = NULL) { *
$ch = curl_init(); * @param $url
$timeout = 5; * @param null $username
* @param null $password
curl_setopt($ch, CURLOPT_URL, $url); * @return mixed|null
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); */
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); function curl_get_data($url, $username = NULL, $password = NULL) {
$ch = curl_init();
if($username != NULL && $password != NULL) { $timeout = 5;
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_URL, $url);
} curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
$http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE)); if($username != NULL && $password != NULL) {
curl_close($ch); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
if($http_status > 210 || $http_status < 200) }
return NULL;
return $data; $data = curl_exec($ch);
} $http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
curl_close($ch);
/* gets all zarafa users */
function get_user_ics_list($userStore) { if($http_status > 210 || $http_status < 200)
// get settings return NULL;
// first check if property exist and we can open that using mapi_openproperty return $data;
$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) { * gets all zarafa users
// read the settings property *
$stream = mapi_openproperty($userStore, PR_EC_WEBACCESS_SETTINGS_JSON, IID_IStream, 0, 0); * @param $userStore
if ($stream == false) { * @return null|void
echo "Error opening settings property\n"; */
} function get_user_ics_list($userStore) {
// get settings
$settings_string = ""; // first check if property exist and we can open that using mapi_openproperty
$stat = mapi_stream_stat($stream); $storeProps = mapi_getprops($userStore, array(PR_EC_WEBACCESS_SETTINGS_JSON));
mapi_stream_seek($stream, 0, STREAM_SEEK_SET);
for ($i = 0; $i < $stat['cb']; $i += 1024) { // Check if property exists, if it doesn not exist then we can continue with empty set of settings
$settings_string .= mapi_stream_read($stream, 1024); 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(empty($settings_string)) { if ($stream == false) {
// property exists but without any content so ignore it and continue with echo "Error opening settings property\n";
// empty set of settings }
return;
} $settings_string = "";
$stat = mapi_stream_stat($stream);
$settings = json_decode($settings_string, true); mapi_stream_seek($stream, 0, STREAM_SEEK_SET);
if (empty($settings) || empty($settings['settings'])) { for ($i = 0; $i < $stat['cb']; $i += 1024) {
echo "Error retrieving existing settings\n"; $settings_string .= mapi_stream_read($stream, 1024);
} }
$calcontext = $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]; if(empty($settings_string)) {
if(isset($calcontext["icssync"])) { // property exists but without any content so ignore it and continue with
foreach($calcontext["icssync"] as $syncitem) { // empty set of settings
echo "Found sync url: " . $syncitem["icsurl"] . " for calendar: " . $syncitem["calendar"] . "\n"; return;
} }
return $calcontext["icssync"]; $settings = json_decode($settings_string, true);
} if (empty($settings) || empty($settings['settings'])) {
echo "Error retrieving existing settings\n";
return NULL; }
}
} $calcontext = $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"];
if(isset($calcontext["icssync"])) {
/* updates the webapp settings */ foreach($calcontext["icssync"] as $syncitem) {
function update_last_sync_date($userStore, $icsentry) { echo "Found sync url: " . $syncitem["icsurl"] . " for calendar: " . $syncitem["calendar"] . "\n";
// 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)); return $calcontext["icssync"];
}
// 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) { return NULL;
// read the settings property }
$stream = mapi_openpropertytostream($userStore, PR_EC_WEBACCESS_SETTINGS_JSON, MAPI_MODIFY); }
if ($stream == false) {
echo "Error opening settings property\n"; /**
} * updates the webapp settings
*
$settings_string = ""; * @param $userStore
$stat = mapi_stream_stat($stream); * @param $icsentry
mapi_stream_seek($stream, 0, STREAM_SEEK_SET); * @return bool|void
for ($i = 0; $i < $stat['cb']; $i += 1024) { */
$settings_string .= mapi_stream_read($stream, 1024); function update_last_sync_date($userStore, $icsentry) {
} // get settings
// first check if property exist and we can open that using mapi_openproperty
if(empty($settings_string)) { $storeProps = mapi_getprops($userStore, array(PR_EC_WEBACCESS_SETTINGS_JSON));
// property exists but without any content so ignore it and continue with
// empty set of settings // Check if property exists, if it doesn not exist then we can continue with empty set of settings
return; 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);
$settings = json_decode($settings_string, true); if ($stream == false) {
if (empty($settings) || empty($settings['settings'])) { echo "Error opening settings property\n";
echo "Error retrieving existing settings\n"; }
}
$settings_string = "";
$settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]["icssync"][$icsentry]["lastsync"] = date('Y-m-d H:i:s'); $stat = mapi_stream_stat($stream);
mapi_stream_seek($stream, 0, STREAM_SEEK_SET);
$newsettings = json_encode($settings); for ($i = 0; $i < $stat['cb']; $i += 1024) {
mapi_stream_setsize($stream, strlen($newsettings)); $settings_string .= mapi_stream_read($stream, 1024);
mapi_stream_seek($stream, 0, STREAM_SEEK_SET); }
mapi_stream_write($stream, $newsettings);
$res = mapi_stream_commit ($stream); if(empty($settings_string)) {
return $res; // property exists but without any content so ignore it and continue with
} // empty set of settings
return;
return false; }
}
$settings = json_decode($settings_string, true);
/* upload a file */ if (empty($settings) || empty($settings['settings'])) {
function upload_ics_to_caldav($filename, $caldavurl, $username, $calendarname, $authuser = NULL, $authpass = NULL) { echo "Error retrieving existing settings\n";
$url = $caldavurl . $username . "/" . rawurlencode($calendarname) . "/"; }
$post = array('file'=>'@'.$filename);
$ch = curl_init(); $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]["icssync"][$icsentry]["lastsync"] = date('Y-m-d H:i:s');
curl_setopt($ch, CURLOPT_URL,$url); $newsettings = json_encode($settings);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); mapi_stream_setsize($stream, strlen($newsettings));
mapi_stream_seek($stream, 0, STREAM_SEEK_SET);
$fp = fopen($filename, 'r'); mapi_stream_write($stream, $newsettings);
curl_setopt($ch, CURLOPT_PUT, true); $res = mapi_stream_commit ($stream);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); return $res;
curl_setopt($ch, CURLOPT_INFILE, $fp); }
curl_setopt($ch, CURLOPT_INFILESIZE, filesize ($filename));
return false;
if($authuser != NULL && $authpass != NULL) { }
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$authuser:$authpass"); /**
} * upload a file
*
$result=curl_exec($ch); * @param $filename
$http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE)); * @param $caldavurl
curl_close($ch); * @param $username
* @param $calendarname
echo "uploading file to: " . $url . " (" . $http_status . ")\n"; * @param null $authuser
* @param null $authpass
return $http_status; * @return int
} */
?> 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;
}

View File

@ -1,150 +1,149 @@
#!/usr/bin/php #!/usr/bin/php
<?php <?php
/** /**
* sync.php, zarafa calender to ics im/exporter backend * sync.php, Kopano calender to ics im/exporter backend
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
if(php_sapi_name() !== 'cli') { if(php_sapi_name() !== 'cli') {
die("Script must be run from commandline!"); die("Script must be run from commandline!");
} }
/** /**
* Make sure that the zarafa mapi extension is enabled in cli mode: * Make sure that the kopano mapi extension is enabled in cli mode:
* Add: /etc/php5/cli/conf.d/50-mapi.ini * Add: /etc/php5/cli/conf.d/50-mapi.ini
* Content: extension=mapi.so * Content: extension=mapi.so
*/ */
// MAPI includes // MAPI includes
include('/usr/share/php/mapi/mapi.util.php'); include('/usr/share/php/mapi/mapi.util.php');
include('/usr/share/php/mapi/mapidefs.php'); include('/usr/share/php/mapi/mapidefs.php');
include('/usr/share/php/mapi/mapicode.php'); include('/usr/share/php/mapi/mapicode.php');
include('/usr/share/php/mapi/mapitags.php'); include('/usr/share/php/mapi/mapitags.php');
include('/usr/share/php/mapi/mapiguid.php'); include('/usr/share/php/mapi/mapiguid.php');
include('config.php'); include('config.php');
include('functions.php'); include('functions.php');
// log in to zarafa // log in to zarafa
$session = mapi_logon_zarafa($ADMINUSERNAME, $ADMINPASSWORD, $SERVER); $session = mapi_logon_zarafa($ADMINUSERNAME, $ADMINPASSWORD, $SERVER);
if($session === FALSE) { if($session === FALSE) {
exit("Logon failed with error " .mapi_last_hresult() . "\n"); exit("Logon failed with error " .mapi_last_hresult() . "\n");
} }
// load all stores for the admin user // load all stores for the admin user
$storeTable = mapi_getmsgstorestable($session); $storeTable = mapi_getmsgstorestable($session);
if($storeTable === FALSE) { if($storeTable === FALSE) {
exit("Storetable could not be opened. Error " .mapi_last_hresult() . "\n"); exit("Storetable could not be opened. Error " .mapi_last_hresult() . "\n");
} }
$storesList = mapi_table_queryallrows($storeTable, array(PR_ENTRYID, PR_DEFAULT_STORE)); $storesList = mapi_table_queryallrows($storeTable, array(PR_ENTRYID, PR_DEFAULT_STORE));
// get admin users default store // get admin users default store
foreach ($storesList as $row) { foreach ($storesList as $row) {
if($row[PR_DEFAULT_STORE]) { if($row[PR_DEFAULT_STORE]) {
$storeEntryid = $row[PR_ENTRYID]; $storeEntryid = $row[PR_ENTRYID];
} }
} }
if(!$storeEntryid) { if(!$storeEntryid) {
exit("Can't find default store\n"); exit("Can't find default store\n");
} }
// open default store // open default store
$store = mapi_openmsgstore($session, $storeEntryid); $store = mapi_openmsgstore($session, $storeEntryid);
if(!$store) { if(!$store) {
exit("Unable to open system store\n"); exit("Unable to open system store\n");
} }
// get a userlist // get a userlist
$userList = array(); $userList = array();
// for multi company setup // for multi company setup
$companyList = mapi_zarafa_getcompanylist($store); $companyList = mapi_zarafa_getcompanylist($store);
if(mapi_last_hresult() == NOERROR && is_array($companyList)) { if(mapi_last_hresult() == NOERROR && is_array($companyList)) {
// multi company setup, get all users from all companies // multi company setup, get all users from all companies
foreach($companyList as $companyName => $companyData) { foreach($companyList as $companyName => $companyData) {
$userList = array_merge($userList, mapi_zarafa_getuserlist($store, $companyData["companyid"])); $userList = array_merge($userList, mapi_zarafa_getuserlist($store, $companyData["companyid"]));
} }
} else { } else {
// single company setup, get list of all zarafa users // single company setup, get list of all zarafa users
$userList = mapi_zarafa_getuserlist($store); $userList = mapi_zarafa_getuserlist($store);
} }
if(count($userList) <= 0) { if(count($userList) <= 0) {
exit("Unable to get user list\n"); exit("Unable to get user list\n");
} }
// loop over all users // loop over all users
foreach($userList as $userName => $userData) { foreach($userList as $userName => $userData) {
// check for valid users // check for valid users
if($userName == "SYSTEM" ||$userName == $ADMINUSERNAME) { if($userName == "SYSTEM" ||$userName == $ADMINUSERNAME) {
continue; continue;
} }
echo "###Getting sync settings for user: " . $userName . "\n"; echo "###Getting sync settings for user: " . $userName . "\n";
$userEntryId = mapi_msgstore_createentryid($store, $userName); $userEntryId = mapi_msgstore_createentryid($store, $userName);
$userStore = mapi_openmsgstore($session, $userEntryId); $userStore = mapi_openmsgstore($session, $userEntryId);
if(!$userStore) { if(!$userStore) {
echo "Can't open user store\n"; echo "Can't open user store\n";
continue; continue;
} }
$syncItems = get_user_ics_list($userStore); $syncItems = get_user_ics_list($userStore);
if($syncItems != NULL && count($syncItems) > 0) { if($syncItems != NULL && count($syncItems) > 0) {
foreach($syncItems as $syncItemName => $syncItem) { foreach($syncItems as $syncItemName => $syncItem) {
//check update intervall //check update intervall
$lastUpdate = strtotime($syncItem["lastsync"]); $lastUpdate = strtotime($syncItem["lastsync"]);
$updateIntervall = intval($syncItem["intervall"]) * 60; // we need seconds $updateIntervall = intval($syncItem["intervall"]) * 60; // we need seconds
$currenttime = time(); $currenttime = time();
if(($lastUpdate + $updateIntervall) <= $currenttime) { if(($lastUpdate + $updateIntervall) <= $currenttime) {
echo "Update intervall OK ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n"; echo "Update intervall OK ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n";
$tmpFilename = $TEMPDIR . uniqid($userName . $syncItem["calendar"], true) . ".ics"; $tmpFilename = $TEMPDIR . uniqid($userName . $syncItem["calendar"], true) . ".ics";
$user = NULL; $user = NULL;
$pass= NULL; $pass= NULL;
if($syncItem["user"] != NULL && !empty($syncItem["user"])) if($syncItem["user"] != NULL && !empty($syncItem["user"]))
$user = $syncItem["user"]; $user = $syncItem["user"];
if($syncItem["pass"] != NULL && !empty($syncItem["pass"])) if($syncItem["pass"] != NULL && !empty($syncItem["pass"]))
$pass= base64_decode($syncItem["pass"]); $pass= base64_decode($syncItem["pass"]);
$icsData = curl_get_data($syncItem["icsurl"], $user, $pass); $icsData = curl_get_data($syncItem["icsurl"], $user, $pass);
if($icsData != NULL) { if($icsData != NULL) {
file_put_contents($tmpFilename, $icsData); file_put_contents($tmpFilename, $icsData);
echo "Got valid data for " . $syncItem["icsurl"] . " stored in " . $tmpFilename . "\n"; echo "Got valid data for " . $syncItem["icsurl"] . " stored in " . $tmpFilename . "\n";
$result = upload_ics_to_caldav($tmpFilename, $CALDAVURL, $userName, $syncItem["calendarname"], $ADMINUSERNAME, $ADMINPASSWORD); $result = upload_ics_to_caldav($tmpFilename, $CALDAVURL, $userName, $syncItem["calendarname"], $ADMINUSERNAME, $ADMINPASSWORD);
if(intval($result) == 200) { if(intval($result) == 200) {
echo "Import completed: $result\n"; echo "Import completed: $result\n";
$result = update_last_sync_date($userStore, $syncItemName); $result = update_last_sync_date($userStore, $syncItemName);
$res = $result ? "true":"false"; $res = $result ? "true":"false";
echo "Updated Zarafa settings: " . $res . "\n"; echo "Updated Zarafa settings: " . $res . "\n";
} else { } else {
echo "Uploading failed: " . $result . "\n"; echo "Uploading failed: " . $result . "\n";
} }
} }
} else { } else {
echo "Update intervall STOP ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n"; echo "Update intervall STOP ($currenttime): " . ($lastUpdate + $updateIntervall) . "\n";
} }
} }
} }
echo "###Done sync for user: " . $userName . "\n\n"; echo "###Done sync for user: " . $userName . "\n\n";
} }
?>

View File

@ -1,64 +1,64 @@
calendarimporter 2.2.1: calendarimporter 2.2.1:
- finally supporting Kopano Webapp 3.1.x - finally supporting Kopano Webapp 3.1.x
- translation to german added - translation to german added
calendarimporter 2.2.0: calendarimporter 2.2.0:
- support for Kopano Webapp 3.1.1 - support for Kopano Webapp 3.1.1
- Code rework - Code rework
- Calendar export improved - Calendar export improved
- Calendar import improved - Calendar import improved
- GUI improvements - GUI improvements
calendarimporter 2.1.0: calendarimporter 2.1.0:
- ics sync is now implemented - ics sync is now implemented
calendarimporter 2.0.5: calendarimporter 2.0.5:
- added settings widget - added settings widget
- compatible with webapp 1.5 and 1.6 - compatible with webapp 1.5 and 1.6
calendarimporter 2.0.4: calendarimporter 2.0.4:
- added compatible with webapp 1.4 - added compatible with webapp 1.4
- added gui for sync - sync algorithms not jet implemented - added gui for sync - sync algorithms not jet implemented
calendarimporter 2.0.3: calendarimporter 2.0.3:
- fixed all day events - fixed all day events
calendarimporter 2.0.2: calendarimporter 2.0.2:
- fixed crash when public store does not exist - fixed crash when public store does not exist
- check if temporary directory is writeable - check if temporary directory is writeable
- disabled display_error with ini_set - disabled display_error with ini_set
- fixed exporter: now really exporting the chosen calendar - fixed exporter: now really exporting the chosen calendar
- improved parser (timezone detection) - improved parser (timezone detection)
calendarimporter 2.0.1: calendarimporter 2.0.1:
- removed debug line "utc = true;" - removed debug line "utc = true;"
- Fixed problems with colons in value fields (improved regex) - Fixed problems with colons in value fields (improved regex)
- minor fixes/improvements - minor fixes/improvements
calendarimporter 2.0: calendarimporter 2.0:
- updated iCalcreator to 2.16.12 - updated iCalcreator to 2.16.12
- fixed exporter problem: now you can export more than 50 events - fixed exporter problem: now you can export more than 50 events
- fixed button visibility for attachment importing - fixed button visibility for attachment importing
- minor fixes/improvements - minor fixes/improvements
calendarimporter 2.0b: calendarimporter 2.0b:
- Completely rewritten timezone management - Completely rewritten timezone management
- Import of iCal attachments possible - Import of iCal attachments possible
- webapp 1.3 about page added - webapp 1.3 about page added
- bugfixes - bugfixes
calendarimporter 1.2: calendarimporter 1.2:
- New timezone management - New timezone management
- more imported fields (Busystatus, importance, label, class, organizer, reminder) - more imported fields (Busystatus, importance, label, class, organizer, reminder)
- smaller improvements - smaller improvements
- deploy/build script - deploy/build script
- support for shared/public folders - support for shared/public folders
calendarimporter 1.1 final: calendarimporter 1.1 final:
- ics exporter - ics exporter
- improved ics fileparser - improved ics fileparser
- fixed ExtJS Problem in chrome - fixed ExtJS Problem in chrome
KNOWN PROBLEMS: KNOWN PROBLEMS:
- attachments in events are ignored - attachments in events are ignored
- recurrent events are not handled properly (im/export) - recurrent events are not handled properly (im/export)

View File

@ -1,66 +1,66 @@
/** /**
* ABOUT.js, Kopano calender to ics im/exporter * ABOUT.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
Ext.namespace('Zarafa.plugins.calendarimporter'); Ext.namespace('Zarafa.plugins.calendarimporter');
/** /**
* @class Zarafa.plugins.calendarimporter.ABOUT * @class Zarafa.plugins.calendarimporter.ABOUT
* @extends String * @extends String
* *
* The copyright string holding the copyright notice for the Zarafa calendarimporter Plugin. * The copyright string holding the copyright notice for the Zarafa calendarimporter Plugin.
*/ */
Zarafa.plugins.calendarimporter.ABOUT = "" Zarafa.plugins.calendarimporter.ABOUT = ""
+ "<p>Copyright (C) 2012-2016 Christoph Haas &lt;christoph.h@sprinternet.at&gt;</p>" + "<p>Copyright (C) 2012-2016 Christoph Haas &lt;christoph.h@sprinternet.at&gt;</p>"
+ "<p>This program is free software; you can redistribute it and/or " + "<p>This program is free software; you can redistribute it and/or "
+ "modify it under the terms of the GNU Lesser General Public " + "modify it under the terms of the GNU Lesser General Public "
+ "License as published by the Free Software Foundation; either " + "License as published by the Free Software Foundation; either "
+ "version 2.1 of the License, or (at your option) any later version.</p>" + "version 2.1 of the License, or (at your option) any later version.</p>"
+ "<p>This program is distributed in the hope that it will be useful, " + "<p>This program is distributed in the hope that it will be useful, "
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of " + "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU " + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "
+ "Lesser General Public License for more details.</p>" + "Lesser General Public License for more details.</p>"
+ "<p>You should have received a copy of the GNU Lesser General Public " + "<p>You should have received a copy of the GNU Lesser General Public "
+ "License along with this program; if not, write to the Free Software " + "License along with this program; if not, write to the Free Software "
+ "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>" + "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>"
+ "<hr />" + "<hr />"
+ "<p>The calendarimporter plugin contains the following third-party components:</p>" + "<p>The calendarimporter plugin contains the following third-party components:</p>"
+ "<h1>iCalcreator v2.16.12</h1>" + "<h1>iCalcreator v2.16.12</h1>"
+ "<p>Copyright 2007-2013 Kjell-Inge Gustafsson kigkonsult</p>" + "<p>Copyright 2007-2013 Kjell-Inge Gustafsson kigkonsult</p>"
+ "<p>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.</p>" + "<p>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.</p>"
+ "<p>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.</p>" + "<p>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.</p>"
+ "<h1>Ics-parser</h1>" + "<h1>Ics-parser</h1>"
+ "<p>Copyright 2002-2007 Martin Thoma &lt;info@martin-thoma.de&gt;</p>" + "<p>Copyright 2002-2007 Martin Thoma &lt;info@martin-thoma.de&gt;</p>"
+ "<p>Licensed under the MIT License.</p>" + "<p>Licensed under the MIT License.</p>"
+ "<p>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.</p>"; + "<p>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.</p>";

View File

@ -1,85 +1,85 @@
/** /**
* ResponseHandler.js, Kopano calender to ics im/exporter * ResponseHandler.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
/** /**
* ResponseHandler * ResponseHandler
* *
* This class handles all responses from the php backend * This class handles all responses from the php backend
*/ */
Ext.namespace('Zarafa.plugins.calendarimporter.data'); Ext.namespace('Zarafa.plugins.calendarimporter.data');
/** /**
* @class Zarafa.plugins.calendarimporter.data.ResponseHandler * @class Zarafa.plugins.calendarimporter.data.ResponseHandler
* @extends Zarafa.plugins.calendarimporter.data.AbstractResponseHandler * @extends Zarafa.plugins.calendarimporter.data.AbstractResponseHandler
* *
* Calendar specific response handler. * Calendar specific response handler.
*/ */
Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, { Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, {
/** /**
* @cfg {Function} successCallback The function which * @cfg {Function} successCallback The function which
* will be called after success request. * will be called after success request.
*/ */
successCallback: null, successCallback: null,
/** /**
* Call the successCallback callback function. * Call the successCallback callback function.
* @param {Object} response Object contained the response data. * @param {Object} response Object contained the response data.
*/ */
doExport: function (response) { doExport: function (response) {
this.successCallback(response); this.successCallback(response);
}, },
/** /**
* Call the successCallback callback function. * Call the successCallback callback function.
* @param {Object} response Object contained the response data. * @param {Object} response Object contained the response data.
*/ */
doLoad: function (response) { doLoad: function (response) {
this.successCallback(response); this.successCallback(response);
}, },
/** /**
* Call the successCallback callback function. * Call the successCallback callback function.
* @param {Object} response Object contained the response data. * @param {Object} response Object contained the response data.
*/ */
doImport: function (response) { doImport: function (response) {
this.successCallback(response); this.successCallback(response);
}, },
/** /**
* Call the successCallback callback function. * Call the successCallback callback function.
* @param {Object} response Object contained the response data. * @param {Object} response Object contained the response data.
*/ */
doImportattachment: function (response) { doImportattachment: function (response) {
this.successCallback(response); this.successCallback(response);
}, },
/** /**
* In case exception happened on server, server will return * In case exception happened on server, server will return
* exception response with the code of exception. * exception response with the code of exception.
* @param {Object} response Object contained the response data. * @param {Object} response Object contained the response data.
*/ */
doError: function (response) { doError: function (response) {
alert("error response code: " + response.error.info.code); alert("error response code: " + response.error.info.code);
} }
}); });
Ext.reg('calendarimporter.calendarresponsehandler', Zarafa.plugins.calendarimporter.data.ResponseHandler); Ext.reg('calendarimporter.calendarresponsehandler', Zarafa.plugins.calendarimporter.data.ResponseHandler);

File diff suppressed because it is too large Load Diff

View File

@ -1,66 +1,66 @@
/** /**
* ImportContentPanel.js, Kopano calender to ics im/exporter * ImportContentPanel.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
/** /**
* ImportContentPanel * ImportContentPanel
* *
* Container for the importpanel. * Container for the importpanel.
*/ */
Ext.namespace("Zarafa.plugins.calendarimporter.dialogs"); Ext.namespace("Zarafa.plugins.calendarimporter.dialogs");
/** /**
* @class Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel * @class Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel
* @extends Zarafa.core.ui.ContentPanel * @extends Zarafa.core.ui.ContentPanel
* *
* The content panel which shows the hierarchy tree of Owncloud account files. * The content panel which shows the hierarchy tree of Owncloud account files.
* @xtype calendarimportercontentpanel * @xtype calendarimportercontentpanel
*/ */
Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, { Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
/** /**
* @constructor * @constructor
* @param config Configuration structure * @param config Configuration structure
*/ */
constructor: function (config) { constructor: function (config) {
config = config || {}; config = config || {};
Ext.applyIf(config, { Ext.applyIf(config, {
layout: 'fit', layout: 'fit',
title: dgettext('plugin_calendarimporter', 'Import Calendar File'), title: dgettext('plugin_calendarimporter', 'Import Calendar File'),
closeOnSave: true, closeOnSave: true,
width: 800, width: 800,
height: 700, height: 700,
//Add panel //Add panel
items: [ items: [
{ {
xtype: 'calendarimporter.importpanel', xtype: 'calendarimporter.importpanel',
filename: config.filename, filename: config.filename,
folder: config.folder folder: config.folder
} }
] ]
}); });
Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel.superclass.constructor.call(this, config); Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel.superclass.constructor.call(this, config);
} }
}); });
Ext.reg('calendarimporter.contentpanel', Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel); Ext.reg('calendarimporter.contentpanel', Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel);

View File

@ -1,47 +1,47 @@
Ext.util.base64 = { Ext.util.base64 = {
base64s : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", base64s : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
encode: function(decStr){ encode: function(decStr){
if (typeof btoa === 'function') { if (typeof btoa === 'function') {
return btoa(decStr); return btoa(decStr);
} }
var base64s = this.base64s; var base64s = this.base64s;
var bits; var bits;
var dual; var dual;
var i = 0; var i = 0;
var encOut = ""; var encOut = "";
while(decStr.length >= i + 3){ while(decStr.length >= i + 3){
bits = (decStr.charCodeAt(i++) & 0xff) <<16 | (decStr.charCodeAt(i++) & 0xff) <<8 | decStr.charCodeAt(i++) & 0xff; 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)); 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){ if(decStr.length -i > 0 && decStr.length -i < 3){
dual = Boolean(decStr.length -i -1); dual = Boolean(decStr.length -i -1);
bits = ((decStr.charCodeAt(i++) & 0xff) <<16) | (dual ? (decStr.charCodeAt(i) & 0xff) <<8 : 0); 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) : '=') + '='; encOut += base64s.charAt((bits & 0x00fc0000) >>18) + base64s.charAt((bits & 0x0003f000) >>12) + (dual ? base64s.charAt((bits & 0x00000fc0) >>6) : '=') + '=';
} }
return(encOut); return(encOut);
}, },
decode: function(encStr){ decode: function(encStr){
if (typeof atob === 'function') { if (typeof atob === 'function') {
return atob(encStr); return atob(encStr);
} }
var base64s = this.base64s; var base64s = this.base64s;
var bits; var bits;
var decOut = ""; var decOut = "";
var i = 0; var i = 0;
for(; i<encStr.length; i += 4){ for(; i<encStr.length; i += 4){
bits = (base64s.indexOf(encStr.charAt(i)) & 0xff) <<18 | (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 | (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 | base64s.indexOf(encStr.charAt(i +3)) & 0xff; bits = (base64s.indexOf(encStr.charAt(i)) & 0xff) <<18 | (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 | (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 | base64s.indexOf(encStr.charAt(i +3)) & 0xff;
decOut += String.fromCharCode((bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff); decOut += String.fromCharCode((bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff);
} }
if(encStr.charCodeAt(i -2) == 61){ if(encStr.charCodeAt(i -2) == 61){
return(decOut.substring(0, decOut.length -2)); return(decOut.substring(0, decOut.length -2));
} }
else if(encStr.charCodeAt(i -1) == 61){ else if(encStr.charCodeAt(i -1) == 61){
return(decOut.substring(0, decOut.length -1)); return(decOut.substring(0, decOut.length -1));
} }
else { else {
return(decOut); return(decOut);
} }
} }
} }

View File

@ -1,306 +1,306 @@
/** /**
* plugin.calendarimporter.js, Kopano calender to ics im/exporter * plugin.calendarimporter.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace
Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin
/** /**
* @constructor * @constructor
* @param {Object} config Configuration object * @param {Object} config Configuration object
* *
*/ */
constructor: function (config) { constructor: function (config) {
config = config || {}; config = config || {};
Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config); Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config);
}, },
/** /**
* initialises insertion point for plugin * initialises insertion point for plugin
* @protected * @protected
*/ */
initPlugin: function () { initPlugin: function () {
Zarafa.plugins.calendarimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments); Zarafa.plugins.calendarimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments);
/* our panel */ /* our panel */
Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.dialogs.importevents'); Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.dialogs.importevents');
/* directly import received icals */ /* directly import received icals */
this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton); this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton);
/* add settings widget */ /* add settings widget */
this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsWidget); this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsWidget);
/* export a calendar entry via rightclick */ /* export a calendar entry via rightclick */
this.registerInsertionPoint('context.calendar.contextmenu.actions', this.createItemExportInsertionPoint, this); this.registerInsertionPoint('context.calendar.contextmenu.actions', this.createItemExportInsertionPoint, this);
/* ical sync stuff */ /* ical sync stuff */
if (container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_sync") === true) { if (container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_sync") === true) {
/* edit panel */ /* edit panel */
Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.settings.dialogs.calsyncedit'); Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.settings.dialogs.calsyncedit');
/* enable the settings widget */ /* enable the settings widget */
this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsCalSyncWidget); this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsCalSyncWidget);
} }
}, },
/** /**
* This method hooks to the contact context menu and allows users to export users to vcf. * This method hooks to the contact context menu and allows users to export users to vcf.
* *
* @param include * @param include
* @param btn * @param btn
* @returns {Object} * @returns {Object}
*/ */
createItemExportInsertionPoint: function (include, btn) { createItemExportInsertionPoint: function (include, btn) {
return { return {
text: dgettext('plugin_calendarimporter', 'Export Event'), text: dgettext('plugin_calendarimporter', 'Export Event'),
handler: this.exportToICS.createDelegate(this, [btn]), handler: this.exportToICS.createDelegate(this, [btn]),
scope: this, scope: this,
iconCls: 'icon_calendarimporter_export' iconCls: 'icon_calendarimporter_export'
}; };
}, },
/** /**
* Generates a request to download the selected records as vCard. * Generates a request to download the selected records as vCard.
* @param {Ext.Button} btn * @param {Ext.Button} btn
*/ */
exportToICS: function (btn) { exportToICS: function (btn) {
if (btn.records.length == 0) { if (btn.records.length == 0) {
return; // skip if no records where given! return; // skip if no records where given!
} }
var recordIds = []; var recordIds = [];
for (var i = 0; i < btn.records.length; i++) { for (var i = 0; i < btn.records.length; i++) {
recordIds.push(btn.records[i].get("entryid")); recordIds.push(btn.records[i].get("entryid"));
} }
Zarafa.plugins.calendarimporter.data.Actions.exportToICS(btn.records[0].get("store_entryid"), recordIds, undefined); Zarafa.plugins.calendarimporter.data.Actions.exportToICS(btn.records[0].get("store_entryid"), recordIds, undefined);
}, },
/** /**
* Creates the button * Creates the button
* *
* @return {Object} Configuration object for a {@link Ext.Button button} * @return {Object} Configuration object for a {@link Ext.Button button}
* *
*/ */
createSettingsWidget: function () { createSettingsWidget: function () {
return [{ return [{
xtype: 'calendarimporter.settingswidget' xtype: 'calendarimporter.settingswidget'
}]; }];
}, },
/** /**
* Creates the button * Creates the button
* *
* @return {Object} Configuration object for a {@link Ext.Button button} * @return {Object} Configuration object for a {@link Ext.Button button}
* *
*/ */
createSettingsCalSyncWidget: function () { createSettingsCalSyncWidget: function () {
return [{ return [{
xtype: 'calendarimporter.settingscalsyncwidget' xtype: 'calendarimporter.settingscalsyncwidget'
}]; }];
}, },
/** /**
* Insert import button in all attachment suggestions * Insert import button in all attachment suggestions
* @return {Object} Configuration object for a {@link Ext.Button button} * @return {Object} Configuration object for a {@link Ext.Button button}
*/ */
createAttachmentImportButton: function (include, btn) { createAttachmentImportButton: function (include, btn) {
return { return {
text: dgettext('plugin_calendarimporter', 'Import to Calendar'), text: dgettext('plugin_calendarimporter', 'Import to Calendar'),
handler: this.getAttachmentFileName.createDelegate(this, [btn]), handler: this.getAttachmentFileName.createDelegate(this, [btn]),
scope: this, scope: this,
iconCls: 'icon_calendarimporter_button', iconCls: 'icon_calendarimporter_button',
beforeShow: function (item, record) { beforeShow: function (item, record) {
var extension = record.data.name.split('.').pop().toLowerCase(); var extension = record.data.name.split('.').pop().toLowerCase();
if (record.data.filetype == "text/calendar" || extension == "ics" || extension == "ifb" || extension == "ical" || extension == "ifbf") { if (record.data.filetype == "text/calendar" || extension == "ics" || extension == "ifb" || extension == "ical" || extension == "ifbf") {
item.setVisible(true); item.setVisible(true);
} else { } else {
item.setVisible(false); item.setVisible(false);
} }
} }
}; };
}, },
/** /**
* Callback for getAttachmentFileName * Callback for getAttachmentFileName
*/ */
gotAttachmentFileName: function (response) { gotAttachmentFileName: function (response) {
if (response.status == true) { if (response.status == true) {
this.scope.openImportDialog(response.tmpname); this.scope.openImportDialog(response.tmpname);
} else { } else {
Zarafa.common.dialogs.MessageBox.show({ Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_calendarimporter', 'Error'), title: dgettext('plugin_calendarimporter', 'Error'),
msg: response["message"], msg: response["message"],
icon: Zarafa.common.dialogs.MessageBox.ERROR, icon: Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK buttons: Zarafa.common.dialogs.MessageBox.OK
}); });
} }
}, },
/** /**
* Clickhandler for the button * Clickhandler for the button
*/ */
getAttachmentFileName: function (btn, callback) { getAttachmentFileName: function (btn, callback) {
Zarafa.common.dialogs.MessageBox.show({ Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_calendarimporter', 'Please wait'), title: dgettext('plugin_calendarimporter', 'Please wait'),
msg: dgettext('plugin_calendarimporter', 'Loading attachment...'), msg: dgettext('plugin_calendarimporter', 'Loading attachment...'),
progressText: dgettext('plugin_calendarimporter', 'Initializing...'), progressText: dgettext('plugin_calendarimporter', 'Initializing...'),
width: 300, width: 300,
progress: true, progress: true,
closable: false closable: false
}); });
// progress bar... ;) // progress bar... ;)
var f = function (v) { var f = function (v) {
return function () { return function () {
if (v == 100) { if (v == 100) {
Zarafa.common.dialogs.MessageBox.hide(); Zarafa.common.dialogs.MessageBox.hide();
} else { } else {
// # TRANSLATORS: {0} will be replaced by the percentage value (0-100) // # 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))); Zarafa.common.dialogs.MessageBox.updateProgress(v / 100, String.format(dgettext('plugin_calendarimporter', '{0}% loaded'), Math.round(v)));
} }
}; };
}; };
for (var i = 1; i < 101; i++) { for (var i = 1; i < 101; i++) {
setTimeout(f(i), 20 * i); setTimeout(f(i), 20 * i);
} }
/* store the attachment to a temporary folder and prepare it for uploading */ /* store the attachment to a temporary folder and prepare it for uploading */
var attachmentRecord = btn.records; var attachmentRecord = btn.records;
var attachmentStore = attachmentRecord.store; var attachmentStore = attachmentRecord.store;
var store = attachmentStore.getParentRecord().get('store_entryid'); var store = attachmentStore.getParentRecord().get('store_entryid');
var entryid = attachmentStore.getAttachmentParentRecordEntryId(); var entryid = attachmentStore.getAttachmentParentRecordEntryId();
var attachNum = new Array(1); var attachNum = new Array(1);
if (attachmentRecord.get('attach_num') != -1) { if (attachmentRecord.get('attach_num') != -1) {
attachNum[0] = attachmentRecord.get('attach_num'); attachNum[0] = attachmentRecord.get('attach_num');
} else { } else {
attachNum[0] = attachmentRecord.get('tmpname'); attachNum[0] = attachmentRecord.get('tmpname');
} }
var dialog_attachments = attachmentStore.getId(); var dialog_attachments = attachmentStore.getId();
var filename = attachmentRecord.data.name; var filename = attachmentRecord.data.name;
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({ var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: this.gotAttachmentFileName, successCallback: this.gotAttachmentFileName,
scope: this scope: this
}); });
// request attachment preperation // request attachment preperation
container.getRequest().singleRequest( container.getRequest().singleRequest(
'calendarmodule', 'calendarmodule',
'importattachment', 'importattachment',
{ {
entryid: entryid, entryid: entryid,
store: store, store: store,
attachNum: attachNum, attachNum: attachNum,
dialog_attachments: dialog_attachments, dialog_attachments: dialog_attachments,
filename: filename filename: filename
}, },
responseHandler responseHandler
); );
}, },
/** /**
* Open the import dialog. * Open the import dialog.
* @param {String} filename * @param {String} filename
*/ */
openImportDialog: function (filename) { openImportDialog: function (filename) {
var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']; var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'];
var config = { var config = {
filename: filename, filename: filename,
modal: true modal: true
}; };
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config); Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
}, },
/** /**
* Bid for the type of shared component * Bid for the type of shared component
* and the given record. * and the given record.
* This will bid on calendar.dialogs.importevents * This will bid on calendar.dialogs.importevents
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for. * @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Ext.data.Record} record Optionally passed record. * @param {Ext.data.Record} record Optionally passed record.
* @return {Number} The bid for the shared component * @return {Number} The bid for the shared component
*/ */
bidSharedComponent: function (type, record) { bidSharedComponent: function (type, record) {
var bid = -1; var bid = -1;
switch (type) { switch (type) {
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']:
bid = 2; bid = 2;
break; break;
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
bid = 2; bid = 2;
break; break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']: case Zarafa.core.data.SharedComponentType['common.contextmenu']:
if (record instanceof Zarafa.core.data.MAPIRecord) { if (record instanceof Zarafa.core.data.MAPIRecord) {
if (record.get('object_type') == Zarafa.core.mapi.ObjectType.MAPI_FOLDER && record.get('container_class') == "IPF.Appointment") { if (record.get('object_type') == Zarafa.core.mapi.ObjectType.MAPI_FOLDER && record.get('container_class') == "IPF.Appointment") {
bid = 2; bid = 2;
} }
} }
break; break;
} }
return bid; return bid;
}, },
/** /**
* Will return the reference to the shared component. * Will return the reference to the shared component.
* Based on the type of component requested a component is returned. * 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 {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Ext.data.Record} record Optionally passed record. * @param {Ext.data.Record} record Optionally passed record.
* @return {Ext.Component} Component * @return {Ext.Component} Component
*/ */
getSharedComponent: function (type, record) { getSharedComponent: function (type, record) {
var component; var component;
switch (type) { switch (type) {
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']:
component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel; component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel;
break; break;
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel; component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel;
break; break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']: case Zarafa.core.data.SharedComponentType['common.contextmenu']:
component = Zarafa.plugins.calendarimporter.ui.ContextMenu; component = Zarafa.plugins.calendarimporter.ui.ContextMenu;
break; break;
} }
return component; return component;
} }
}); });
/*############################################################################################################################* /*############################################################################################################################*
* STARTUP * STARTUP
*############################################################################################################################*/ *############################################################################################################################*/
Zarafa.onReady(function () { Zarafa.onReady(function () {
container.registerPlugin(new Zarafa.core.PluginMetaData({ container.registerPlugin(new Zarafa.core.PluginMetaData({
name: 'calendarimporter', name: 'calendarimporter',
displayName: dgettext('plugin_calendarimporter', 'Calendarimporter Plugin'), displayName: dgettext('plugin_calendarimporter', 'Calendarimporter Plugin'),
about: Zarafa.plugins.calendarimporter.ABOUT, about: Zarafa.plugins.calendarimporter.ABOUT,
pluginConstructor: Zarafa.plugins.calendarimporter.ImportPlugin pluginConstructor: Zarafa.plugins.calendarimporter.ImportPlugin
})); }));
}); });

View File

@ -1,136 +1,136 @@
/** /**
* SettingsCalSyncWidget.js, Kopano calender to ics im/exporter * SettingsCalSyncWidget.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
Ext.namespace('Zarafa.plugins.calendarimporter.settings'); Ext.namespace('Zarafa.plugins.calendarimporter.settings');
/** /**
* @class Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget * @class Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget
* @extends Zarafa.settings.ui.SettingsWidget * @extends Zarafa.settings.ui.SettingsWidget
* @xtype calendarimporter.settingscalsyncwidget * @xtype calendarimporter.settingscalsyncwidget
* *
*/ */
Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, {
/** /**
* @cfg {Zarafa.settings.SettingsContext} settingsContext * @cfg {Zarafa.settings.SettingsContext} settingsContext
*/ */
settingsContext: undefined, settingsContext: undefined,
/** /**
* @constructor * @constructor
* @param {Object} config Configuration object * @param {Object} config Configuration object
*/ */
constructor: function (config) { constructor: function (config) {
config = config || {}; config = config || {};
var store = new Ext.data.JsonStore({ var store = new Ext.data.JsonStore({
fields: [ fields: [
{name: 'id', type: 'int'}, {name: 'id', type: 'int'},
{name: 'icsurl'}, {name: 'icsurl'},
{name: 'user'}, {name: 'user'},
{name: 'pass'}, {name: 'pass'},
{name: 'intervall', type: 'int'}, {name: 'intervall', type: 'int'},
{name: 'calendar'}, {name: 'calendar'},
{name: 'calendarname'}, {name: 'calendarname'},
{name: 'lastsync'} {name: 'lastsync'}
], ],
sortInfo: { sortInfo: {
field: 'id', field: 'id',
direction: 'ASC' direction: 'ASC'
}, },
autoDestroy: true autoDestroy: true
}); });
Ext.applyIf(config, { Ext.applyIf(config, {
height: 400, height: 400,
title: dgettext('plugin_calendarimporter', 'Calendar Sync settings'), title: dgettext('plugin_calendarimporter', 'Calendar Sync settings'),
xtype: 'calendarimporter.settingscalsyncwidget', xtype: 'calendarimporter.settingscalsyncwidget',
layout: { layout: {
// override from SettingsWidget // override from SettingsWidget
type: 'fit' type: 'fit'
}, },
items: [{ items: [{
xtype: 'calendarimporter.calsyncpanel', xtype: 'calendarimporter.calsyncpanel',
store: store, store: store,
ref: 'calsyncPanel' ref: 'calsyncPanel'
}] }]
}); });
Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget.superclass.constructor.call(this, config); Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget.superclass.constructor.call(this, config);
}, },
/** /**
* Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when
* it has been called with {@link zarafa.settings.ui.SettingsCategory#update}. * it has been called with {@link zarafa.settings.ui.SettingsCategory#update}.
* This is used to load the latest version of the settings from the * This is used to load the latest version of the settings from the
* {@link Zarafa.settings.SettingsModel} into the UI of this category. * {@link Zarafa.settings.SettingsModel} into the UI of this category.
* @param {Zarafa.settings.SettingsModel} settingsModel The settings to load * @param {Zarafa.settings.SettingsModel} settingsModel The settings to load
*/ */
update: function (settingsModel) { update: function (settingsModel) {
this.model = settingsModel; this.model = settingsModel;
// Convert the signatures into Store data // Convert the signatures into Store data
var icslinks = settingsModel.get('zarafa/v1/contexts/calendar/icssync', true); var icslinks = settingsModel.get('zarafa/v1/contexts/calendar/icssync', true);
var syncArray = []; var syncArray = [];
for (var key in icslinks) { for (var key in icslinks) {
if (icslinks.hasOwnProperty(key)) { // skip inherited props if (icslinks.hasOwnProperty(key)) { // skip inherited props
syncArray.push(Ext.apply({}, icslinks[key], {id: key})); syncArray.push(Ext.apply({}, icslinks[key], {id: key}));
} }
} }
// Load all icslinks into the GridPanel // Load all icslinks into the GridPanel
var store = this.calsyncPanel.calsyncGrid.getStore(); var store = this.calsyncPanel.calsyncGrid.getStore();
store.loadData(syncArray); store.loadData(syncArray);
}, },
/** /**
* Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when
* it has been called with {@link zarafa.settings.ui.SettingsCategory#updateSettings}. * 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}. * 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 * @param {Zarafa.settings.SettingsModel} settingsModel The settings to update
*/ */
updateSettings: function (settingsModel) { updateSettings: function (settingsModel) {
settingsModel.beginEdit(); settingsModel.beginEdit();
// Start reading the Grid store and convert the contents back into // Start reading the Grid store and convert the contents back into
// an object which can be pushed to the settings. // an object which can be pushed to the settings.
var icslinks = this.calsyncPanel.calsyncGrid.getStore().getRange(); var icslinks = this.calsyncPanel.calsyncGrid.getStore().getRange();
var icslinkData = {}; var icslinkData = {};
for (var i = 0, len = icslinks.length; i < len; i++) { for (var i = 0, len = icslinks.length; i < len; i++) {
var icslink = icslinks[i]; var icslink = icslinks[i];
icslinkData[icslink.get('id')] = { icslinkData[icslink.get('id')] = {
'icsurl': icslink.get('icsurl'), 'icsurl': icslink.get('icsurl'),
'intervall': icslink.get('intervall'), 'intervall': icslink.get('intervall'),
'user': icslink.get('user'), 'user': icslink.get('user'),
'pass': icslink.get('pass'), 'pass': icslink.get('pass'),
'lastsync': icslink.get('lastsync'), 'lastsync': icslink.get('lastsync'),
'calendar': icslink.get('calendar'), 'calendar': icslink.get('calendar'),
'calendarname': Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(icslink.get('calendar')).display_name 'calendarname': Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(icslink.get('calendar')).display_name
}; };
} }
settingsModel.set('zarafa/v1/contexts/calendar/icssync', icslinkData); settingsModel.set('zarafa/v1/contexts/calendar/icssync', icslinkData);
settingsModel.endEdit(); settingsModel.endEdit();
} }
}); });
Ext.reg('calendarimporter.settingscalsyncwidget', Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget); Ext.reg('calendarimporter.settingscalsyncwidget', Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget);

View File

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

View File

@ -1,60 +1,60 @@
/** /**
* CalSyncEditContentPanel.js, Kopano calender to ics im/exporter * CalSyncEditContentPanel.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs'); Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs');
/** /**
* @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel * @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel
* @extends Zarafa.core.ui.ContentPanel * @extends Zarafa.core.ui.ContentPanel
* @xtype calendarimporter.calsynceditcontentpanel * @xtype calendarimporter.calsynceditcontentpanel
* *
* {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel CalSyncEditContentPanel} will be used to edit ics sync entries. * {@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, { Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
/** /**
* @constructor * @constructor
* @param config Configuration structure * @param config Configuration structure
*/ */
constructor: function (config) { constructor: function (config) {
config = config || {}; config = config || {};
// Add in some standard configuration data. // Add in some standard configuration data.
Ext.applyIf(config, { Ext.applyIf(config, {
// Override from Ext.Component // Override from Ext.Component
xtype: 'calendarimporter.calsynceditcontentpanel', xtype: 'calendarimporter.calsynceditcontentpanel',
layout: 'fit', layout: 'fit',
model: true, model: true,
autoSave: false, autoSave: false,
width: 400, width: 400,
height: 400, height: 400,
title: dgettext('plugin_calendarimporter', 'ICAL Sync'), title: dgettext('plugin_calendarimporter', 'ICAL Sync'),
items: [{ items: [{
xtype: 'calendarimporter.calsynceditpanel', xtype: 'calendarimporter.calsynceditpanel',
item: config.item item: config.item
}] }]
}); });
Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel.superclass.constructor.call(this, config); Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel.superclass.constructor.call(this, config);
} }
}); });
Ext.reg('calendarimporter.calsynceditcontentpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel); Ext.reg('calendarimporter.calsynceditcontentpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel);

View File

@ -1,223 +1,223 @@
/** /**
* CalSyncEditPanel.js, Kopano calender to ics im/exporter * CalSyncEditPanel.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs'); Ext.namespace('Zarafa.plugins.calendarimporter.settings.dialogs');
/** /**
* @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel * @class Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel
* @extends Ext.form.FormPanel * @extends Ext.form.FormPanel
* @xtype calendarimporter.calsynceditpanel * @xtype calendarimporter.calsynceditpanel
* *
* Will generate UI for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel}. * Will generate UI for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel}.
*/ */
Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel = Ext.extend(Ext.form.FormPanel, { Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel = Ext.extend(Ext.form.FormPanel, {
/** /**
* the id of the currently edited item * the id of the currently edited item
*/ */
currentItem: undefined, currentItem: undefined,
/** /**
* @constructor * @constructor
* @param config Configuration structure * @param config Configuration structure
*/ */
constructor: function (config) { constructor: function (config) {
config = config || {}; config = config || {};
if (config.item) if (config.item)
this.currentItem = config.item; this.currentItem = config.item;
Ext.applyIf(config, { Ext.applyIf(config, {
// Override from Ext.Component // Override from Ext.Component
xtype: 'calendarimporter.calsynceditpanel', xtype: 'calendarimporter.calsynceditpanel',
labelAlign: 'top', labelAlign: 'top',
defaultType: 'textfield', defaultType: 'textfield',
items: this.createPanelItems(config), items: this.createPanelItems(config),
buttons: [{ buttons: [{
text: _('Save'), text: _('Save'),
handler: this.doSave, handler: this.doSave,
scope: this scope: this
}, },
{ {
text: _('Cancel'), text: _('Cancel'),
handler: this.doClose, handler: this.doClose,
scope: this scope: this
}] }]
}); });
Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel.superclass.constructor.call(this, config); Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel.superclass.constructor.call(this, config);
}, },
/** /**
* close the dialog * close the dialog
*/ */
doClose: function () { doClose: function () {
this.dialog.close(); this.dialog.close();
}, },
/** /**
* save the data to the store * save the data to the store
*/ */
doSave: function () { doSave: function () {
var store = this.dialog.store; var store = this.dialog.store;
var id = 0; var id = 0;
var record = undefined; var record = undefined;
if (!this.currentItem) { if (!this.currentItem) {
record = new store.recordType({ record = new store.recordType({
id: this.hashCode(this.icsurl.getValue()), id: this.hashCode(this.icsurl.getValue()),
icsurl: this.icsurl.getValue(), icsurl: this.icsurl.getValue(),
intervall: this.intervall.getValue(), intervall: this.intervall.getValue(),
user: this.user.getValue(), user: this.user.getValue(),
pass: Ext.util.base64.encode(this.pass.getValue()), pass: Ext.util.base64.encode(this.pass.getValue()),
calendar: this.calendar.getValue(), calendar: this.calendar.getValue(),
calendarname: Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name, calendarname: Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name,
lastsync: "never" lastsync: "never"
}); });
} }
if (this.icsurl.isValid()) { if (this.icsurl.isValid()) {
if (record) { if (record) {
store.add(record); store.add(record);
} else { } else {
this.currentItem.set('icsurl', this.icsurl.getValue()); this.currentItem.set('icsurl', this.icsurl.getValue());
this.currentItem.set('intervall', this.intervall.getValue()); this.currentItem.set('intervall', this.intervall.getValue());
this.currentItem.set('user', this.user.getValue()); this.currentItem.set('user', this.user.getValue());
this.currentItem.set('pass', Ext.util.base64.encode(this.pass.getValue())); this.currentItem.set('pass', Ext.util.base64.encode(this.pass.getValue()));
this.currentItem.set('calendar', this.calendar.getValue()); this.currentItem.set('calendar', this.calendar.getValue());
this.currentItem.set('calendarname', Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name); this.currentItem.set('calendarname', Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(this.calendar.getValue()).display_name);
} }
this.dialog.close(); this.dialog.close();
} }
}, },
/** /**
* Function will create panel items for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel} * 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. * @return {Array} array of items that should be added to panel.
* @private * @private
*/ */
createPanelItems: function (config) { createPanelItems: function (config) {
var icsurl = ""; var icsurl = "";
var intervall = "15"; var intervall = "15";
var user = ""; var user = "";
var pass = ""; var pass = "";
var calendarname = ""; var calendarname = "";
var calendar = Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByName(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_calendar")).entryid; 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); var myStore = Zarafa.plugins.calendarimporter.data.Actions.getAllCalendarFolders(true);
if (config.item) { if (config.item) {
icsurl = config.item.get('icsurl'); icsurl = config.item.get('icsurl');
intervall = config.item.get('intervall'); intervall = config.item.get('intervall');
user = config.item.get('user'); user = config.item.get('user');
pass = Ext.util.base64.decode(config.item.get('pass')); pass = Ext.util.base64.decode(config.item.get('pass'));
calendar = config.item.get('calendar'); calendar = config.item.get('calendar');
calendarname = config.item.get('calendarname'); calendarname = config.item.get('calendarname');
} }
return [{ return [{
xtype: 'fieldset', xtype: 'fieldset',
title: dgettext('plugin_calendarimporter', 'ICAL Information'), title: dgettext('plugin_calendarimporter', 'ICAL Information'),
defaultType: 'textfield', defaultType: 'textfield',
layout: 'form', layout: 'form',
flex: 1, flex: 1,
defaults: { defaults: {
anchor: '100%', anchor: '100%',
flex: 1 flex: 1
}, },
items: [{ items: [{
fieldLabel: dgettext('plugin_calendarimporter', 'ICS Url'), fieldLabel: dgettext('plugin_calendarimporter', 'ICS Url'),
name: 'icsurl', name: 'icsurl',
ref: '../icsurl', ref: '../icsurl',
value: icsurl, value: icsurl,
allowBlank: false allowBlank: false
}, },
{ {
xtype: 'selectbox', xtype: 'selectbox',
fieldLabel: dgettext('plugin_calendarimporter', 'Destination Calendar'), fieldLabel: dgettext('plugin_calendarimporter', 'Destination Calendar'),
name: 'calendar', name: 'calendar',
ref: '../calendar', ref: '../calendar',
value: calendar, value: calendar,
editable: false, editable: false,
store: myStore, store: myStore,
mode: 'local', mode: 'local',
labelSeperator: ":", labelSeperator: ":",
border: false, border: false,
anchor: "100%", anchor: "100%",
scope: this, scope: this,
allowBlank: false allowBlank: false
}, },
{ {
xtype: 'numberfield', xtype: 'numberfield',
fieldLabel: dgettext('plugin_calendarimporter', 'Sync Intervall (minutes)'), fieldLabel: dgettext('plugin_calendarimporter', 'Sync Intervall (minutes)'),
name: 'intervall', name: 'intervall',
ref: '../intervall', ref: '../intervall',
value: intervall, value: intervall,
allowBlank: false allowBlank: false
}] }]
}, },
{ {
xtype: 'fieldset', xtype: 'fieldset',
title: dgettext('plugin_calendarimporter', 'Authentication (optional)'), title: dgettext('plugin_calendarimporter', 'Authentication (optional)'),
defaultType: 'textfield', defaultType: 'textfield',
layout: 'form', layout: 'form',
defaults: { defaults: {
anchor: '100%' anchor: '100%'
}, },
items: [{ items: [{
fieldLabel: dgettext('plugin_calendarimporter', 'Username'), fieldLabel: dgettext('plugin_calendarimporter', 'Username'),
name: 'user', name: 'user',
ref: '../user', ref: '../user',
value: user, value: user,
allowBlank: true allowBlank: true
}, },
{ {
fieldLabel: dgettext('plugin_calendarimporter', 'Password'), fieldLabel: dgettext('plugin_calendarimporter', 'Password'),
name: 'pass', name: 'pass',
ref: '../pass', ref: '../pass',
value: pass, value: pass,
inputType: 'password', inputType: 'password',
allowBlank: true allowBlank: true
}] }]
}]; }];
}, },
/** /**
* Java String.hashCode() implementation * Java String.hashCode() implementation
* @private * @private
*/ */
hashCode: function (str) { hashCode: function (str) {
var hash = 0; var hash = 0;
var chr = 0; var chr = 0;
var i = 0; var i = 0;
if (str.length == 0) return hash; if (str.length == 0) return hash;
for (i = 0; i < str.length; i++) { for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i); chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr; hash = ((hash << 5) - hash) + chr;
hash = hash & hash; // Convert to 32bit integer hash = hash & hash; // Convert to 32bit integer
} }
return Math.abs(hash); return Math.abs(hash);
} }
}); });
Ext.reg('calendarimporter.calsynceditpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel); Ext.reg('calendarimporter.calsynceditpanel', Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel);

View File

@ -1,180 +1,180 @@
/** /**
* CalSyncGrid.js, Kopano calender to ics im/exporter * CalSyncGrid.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui'); Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui');
/** /**
* @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid * @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid
* @extends Ext.grid.GridPanel * @extends Ext.grid.GridPanel
* @xtype calendarimporter.calsyncgrid * @xtype calendarimporter.calsyncgrid
* *
*/ */
Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.GridPanel, { Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.GridPanel, {
/** /**
* @constructor * @constructor
* @param {Object} config Configuration structure * @param {Object} config Configuration structure
*/ */
constructor: function (config) { constructor: function (config) {
config = config || {}; config = config || {};
Ext.applyIf(config, { Ext.applyIf(config, {
xtype: 'calendarimporter.calsyncgrid', xtype: 'calendarimporter.calsyncgrid',
border: true, border: true,
store: config.store, store: config.store,
viewConfig: { viewConfig: {
forceFit: true, forceFit: true,
emptyText: '<div class=\'emptytext\'>' + dgettext('plugin_calendarimporter', 'No ICAL sync entry exists') + '</div>' emptyText: '<div class=\'emptytext\'>' + dgettext('plugin_calendarimporter', 'No ICAL sync entry exists') + '</div>'
}, },
loadMask: this.initLoadMask(), loadMask: this.initLoadMask(),
columns: this.initColumnModel(), columns: this.initColumnModel(),
selModel: this.initSelectionModel(), selModel: this.initSelectionModel(),
listeners: { listeners: {
viewready: this.onViewReady, viewready: this.onViewReady,
rowdblclick: this.onRowDblClick, rowdblclick: this.onRowDblClick,
scope: this scope: this
} }
}); });
Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.constructor.call(this, config); Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.constructor.call(this, config);
}, },
/** /**
* initialize events for the grid panel. * initialize events for the grid panel.
* @private * @private
*/ */
initEvents: function () { initEvents: function () {
Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.initEvents.call(this); Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.initEvents.call(this);
// select first icssync when store has finished loading // select first icssync when store has finished loading
this.mon(this.store, 'load', this.onViewReady, this, {single: true}); this.mon(this.store, 'load', this.onViewReady, this, {single: true});
}, },
/** /**
* Render function * Render function
* @return {String} * @return {String}
* @private * @private
*/ */
renderAuthColumn: function (value, p, record) { renderAuthColumn: function (value, p, record) {
return value ? "true" : "false"; return value ? "true" : "false";
}, },
/** /**
* Render function * Render function
* @return {String} * @return {String}
* @private * @private
*/ */
renderCalendarColumn: function (value, p, record) { renderCalendarColumn: function (value, p, record) {
return Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(value).display_name; return Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(value).display_name;
}, },
/** /**
* Creates a column model object, used in {@link #colModel} config * Creates a column model object, used in {@link #colModel} config
* @return {Ext.grid.ColumnModel} column model object * @return {Ext.grid.ColumnModel} column model object
* @private * @private
*/ */
initColumnModel: function () { initColumnModel: function () {
return [{ return [{
dataIndex: 'icsurl', dataIndex: 'icsurl',
header: dgettext('plugin_calendarimporter', 'ICS File'), header: dgettext('plugin_calendarimporter', 'ICS File'),
renderer: Zarafa.common.ui.grid.Renderers.text renderer: Zarafa.common.ui.grid.Renderers.text
}, },
{ {
dataIndex: 'calendarname', dataIndex: 'calendarname',
header: dgettext('plugin_calendarimporter', 'Destination Calender'), header: dgettext('plugin_calendarimporter', 'Destination Calender'),
renderer: Zarafa.common.ui.grid.Renderers.text renderer: Zarafa.common.ui.grid.Renderers.text
}, },
{ {
dataIndex: 'user', dataIndex: 'user',
header: dgettext('plugin_calendarimporter', 'Authentication'), header: dgettext('plugin_calendarimporter', 'Authentication'),
renderer: this.renderAuthColumn renderer: this.renderAuthColumn
}, },
{ {
dataIndex: 'intervall', dataIndex: 'intervall',
header: dgettext('plugin_calendarimporter', 'Sync Intervall') header: dgettext('plugin_calendarimporter', 'Sync Intervall')
}, },
{ {
dataIndex: 'lastsync', dataIndex: 'lastsync',
header: dgettext('plugin_calendarimporter', 'Last Synchronisation'), header: dgettext('plugin_calendarimporter', 'Last Synchronisation'),
renderer: Zarafa.common.ui.grid.Renderers.text renderer: Zarafa.common.ui.grid.Renderers.text
}] }]
}, },
/** /**
* Creates a selection model object, used in {@link #selModel} config * Creates a selection model object, used in {@link #selModel} config
* @return {Ext.grid.RowSelectionModel} selection model object * @return {Ext.grid.RowSelectionModel} selection model object
* @private * @private
*/ */
initSelectionModel: function () { initSelectionModel: function () {
return new Ext.grid.RowSelectionModel({ return new Ext.grid.RowSelectionModel({
singleSelect: true singleSelect: true
}); });
}, },
/** /**
* Initialize the {@link Ext.grid.GridPanel.loadMask} field * Initialize the {@link Ext.grid.GridPanel.loadMask} field
* *
* @return {Ext.LoadMask} The configuration object for {@link Ext.LoadMask} * @return {Ext.LoadMask} The configuration object for {@link Ext.LoadMask}
* @private * @private
*/ */
initLoadMask: function () { initLoadMask: function () {
return { return {
msg: dgettext('plugin_calendarimporter', 'Loading ics sync entries...') msg: dgettext('plugin_calendarimporter', 'Loading ics sync entries...')
}; };
}, },
/** /**
* Event handler which is fired when the gridPanel is ready. This will automatically * Event handler which is fired when the gridPanel is ready. This will automatically
* select the first row in the grid. * select the first row in the grid.
* @private * @private
*/ */
onViewReady: function () { onViewReady: function () {
this.getSelectionModel().selectFirstRow(); this.getSelectionModel().selectFirstRow();
}, },
/** /**
* Function will be called to remove a ics sync entry. * Function will be called to remove a ics sync entry.
*/ */
removeIcsSyncAs: function () { removeIcsSyncAs: function () {
var icsRecord = this.getSelectionModel().getSelected(); var icsRecord = this.getSelectionModel().getSelected();
if (!icsRecord) { if (!icsRecord) {
Ext.Msg.alert(dgettext('plugin_calendarimporter', 'Alert'), dgettext('plugin_calendarimporter', 'Please select a ics sync entry.')); Ext.Msg.alert(dgettext('plugin_calendarimporter', 'Alert'), dgettext('plugin_calendarimporter', 'Please select a ics sync entry.'));
return; return;
} }
this.store.remove(icsRecord); this.store.remove(icsRecord);
}, },
/** /**
* Event handler which is fired when the {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid} is double clicked. * 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. * it will call generic function to handle the functionality.
* @private * @private
*/ */
onRowDblClick: function (grid, rowIndex) { onRowDblClick: function (grid, rowIndex) {
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, { Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, {
store: grid.getStore(), store: grid.getStore(),
item: grid.getStore().getAt(rowIndex), item: grid.getStore().getAt(rowIndex),
manager: Ext.WindowMgr manager: Ext.WindowMgr
}); });
} }
}); });
Ext.reg('calendarimporter.calsyncgrid', Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid); Ext.reg('calendarimporter.calsyncgrid', Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid);

View File

@ -1,172 +1,172 @@
/** /**
* CalSyncPanel.js, Kopano calender to ics im/exporter * CalSyncPanel.js, Kopano calender to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui'); Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui');
/** /**
* @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel * @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel
* @extends Ext.Panel * @extends Ext.Panel
* @xtype calendarimporter.calsyncpanel * @xtype calendarimporter.calsyncpanel
* Will generate UI for the {@link Zarafa.common.settings.SettingsSendAsWidget SettingsSendAsWidget}. * Will generate UI for the {@link Zarafa.common.settings.SettingsSendAsWidget SettingsSendAsWidget}.
*/ */
Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, { Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, {
// store // store
store: undefined, store: undefined,
/** /**
* @constructor * @constructor
* @param config Configuration structure * @param config Configuration structure
*/ */
constructor: function (config) { constructor: function (config) {
config = config || {}; config = config || {};
if (config.store) if (config.store)
this.store = config.store; this.store = config.store;
Ext.applyIf(config, { Ext.applyIf(config, {
// Override from Ext.Component // Override from Ext.Component
xtype: 'calendarimporter.calsyncpanel', xtype: 'calendarimporter.calsyncpanel',
border: false, border: false,
layout: { layout: {
type: 'vbox', type: 'vbox',
align: 'stretch', align: 'stretch',
pack: 'start' pack: 'start'
}, },
items: this.createPanelItems(this.store) items: this.createPanelItems(this.store)
}); });
Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.constructor.call(this, config); 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} * 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. * @return {Array} array of items that should be added to panel.
* @private * @private
*/ */
createPanelItems: function (store) { createPanelItems: function (store) {
return [{ return [{
xtype: 'displayfield', xtype: 'displayfield',
value: dgettext('plugin_calendarimporter', 'Setup calendars you want to subscribe to.'), value: dgettext('plugin_calendarimporter', 'Setup calendars you want to subscribe to.'),
fieldClass: 'x-form-display-field' fieldClass: 'x-form-display-field'
}, { }, {
xtype: 'container', xtype: 'container',
flex: 1, flex: 1,
layout: { layout: {
type: 'hbox', type: 'hbox',
align: 'stretch', align: 'stretch',
pack: 'start' pack: 'start'
}, },
items: [{ items: [{
xtype: 'calendarimporter.calsyncgrid', xtype: 'calendarimporter.calsyncgrid',
ref: '../calsyncGrid', ref: '../calsyncGrid',
store: store, store: store,
flex: 1 flex: 1
}, { }, {
xtype: 'container', xtype: 'container',
width: 160, width: 160,
defaults: { defaults: {
width: 140 width: 140
}, },
layout: { layout: {
type: 'vbox', type: 'vbox',
align: 'center', align: 'center',
pack: 'start' pack: 'start'
}, },
items: [{ items: [{
xtype: 'button', xtype: 'button',
text: _('Add') + '...', text: _('Add') + '...',
handler: this.onCalSyncAdd, handler: this.onCalSyncAdd,
ref: '../../addButton', ref: '../../addButton',
scope: this scope: this
}, { }, {
xtype: 'spacer', xtype: 'spacer',
height: 20 height: 20
}, { }, {
xtype: 'button', xtype: 'button',
text: _('Remove') + '...', text: _('Remove') + '...',
disabled: true, disabled: true,
ref: '../../removeButton', ref: '../../removeButton',
handler: this.onCalSyncRemove, handler: this.onCalSyncRemove,
scope: this scope: this
}] }]
}] }]
}]; }];
}, },
/** /**
* initialize events for the panel. * initialize events for the panel.
* @private * @private
*/ */
initEvents: function () { initEvents: function () {
Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.initEvents.call(this); Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.initEvents.call(this);
// register event to enable/disable buttons // register event to enable/disable buttons
this.mon(this.calsyncGrid.getSelectionModel(), 'selectionchange', this.onGridSelectionChange, this); this.mon(this.calsyncGrid.getSelectionModel(), 'selectionchange', this.onGridSelectionChange, this);
}, },
/** /**
* Handler function will be called when user clicks on 'Add' button. * Handler function will be called when user clicks on 'Add' button.
* @private * @private
*/ */
onCalSyncAdd: function () { onCalSyncAdd: function () {
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, { Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, {
store: this.store, store: this.store,
item: undefined, item: undefined,
manager: Ext.WindowMgr manager: Ext.WindowMgr
}); });
}, },
/** /**
* Event handler will be called when selection in {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid} * Event handler will be called when selection in {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid}
* has been changed * has been changed
* @param {Ext.grid.RowSelectionModel} selectionModel selection model that fired the event * @param {Ext.grid.RowSelectionModel} selectionModel selection model that fired the event
*/ */
onGridSelectionChange: function (selectionModel) { onGridSelectionChange: function (selectionModel) {
var noSelection = (selectionModel.hasSelection() === false); var noSelection = (selectionModel.hasSelection() === false);
this.removeButton.setDisabled(noSelection); this.removeButton.setDisabled(noSelection);
}, },
/** /**
* Handler function will be called when user clicks on 'Remove' button. * Handler function will be called when user clicks on 'Remove' button.
* @private * @private
*/ */
onCalSyncRemove: function () { onCalSyncRemove: function () {
this.calsyncGrid.removeIcsSyncAs(); this.calsyncGrid.removeIcsSyncAs();
}, },
/** /**
* Function will be used to reload data in the store. * Function will be used to reload data in the store.
*/ */
discardChanges: function () { discardChanges: function () {
this.store.load(); this.store.load();
}, },
/** /**
* Function will be used to save changes in the store. * Function will be used to save changes in the store.
*/ */
saveChanges: function () { saveChanges: function () {
this.store.save(); this.store.save();
} }
}); });
Ext.reg('calendarimporter.calsyncpanel', Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel); Ext.reg('calendarimporter.calsyncpanel', Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel);

View File

@ -1,52 +1,52 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE plugin SYSTEM "manifest.dtd"> <!DOCTYPE plugin SYSTEM "manifest.dtd">
<plugin version="2"> <plugin version="2">
<info> <info>
<version>2.2.1</version> <version>2.2.1</version>
<name>calendarimporter</name> <name>calendarimporter</name>
<title>ICS Calendar Importer/Exporter</title> <title>ICS Calendar Importer/Exporter</title>
<author>Christoph Haas</author> <author>Christoph Haas</author>
<authorURL>http://www.sprinternet.at</authorURL> <authorURL>http://www.sprinternet.at</authorURL>
<description>Import or Export a ICS file to/from the Kopano calendar</description> <description>Import or Export a ICS file to/from the Kopano calendar</description>
</info> </info>
<translations> <translations>
<translationsdir>languages</translationsdir> <translationsdir>languages</translationsdir>
</translations> </translations>
<config> <config>
<configfile>config.php</configfile> <configfile>config.php</configfile>
</config> </config>
<components> <components>
<component> <component>
<files> <files>
<server> <server>
<serverfile>php/plugin.calendarimporter.php</serverfile> <serverfile>php/plugin.calendarimporter.php</serverfile>
<serverfile type="module" module="calendarmodule">php/module.calendar.php</serverfile> <serverfile type="module" module="calendarmodule">php/module.calendar.php</serverfile>
</server> </server>
<client> <client>
<clientfile load="release">js/calendarimporter.js</clientfile> <clientfile load="release">js/calendarimporter.js</clientfile>
<clientfile load="debug">js/calendarimporter-debug.js</clientfile> <clientfile load="debug">js/calendarimporter-debug.js</clientfile>
<clientfile load="source">js/data/timezones.js</clientfile> <clientfile load="source">js/data/timezones.js</clientfile>
<clientfile load="source">js/data/Actions.js</clientfile> <clientfile load="source">js/data/Actions.js</clientfile>
<clientfile load="source">js/data/ResponseHandler.js</clientfile> <clientfile load="source">js/data/ResponseHandler.js</clientfile>
<clientfile load="source">js/external/Ext.util.base64.js</clientfile> <clientfile load="source">js/external/Ext.util.base64.js</clientfile>
<clientfile load="source">js/ui/ContextMenu.js</clientfile> <clientfile load="source">js/ui/ContextMenu.js</clientfile>
<clientfile load="source">js/dialogs/ImportContentPanel.js</clientfile> <clientfile load="source">js/dialogs/ImportContentPanel.js</clientfile>
<clientfile load="source">js/dialogs/ImportPanel.js</clientfile> <clientfile load="source">js/dialogs/ImportPanel.js</clientfile>
<clientfile load="source">js/dialogs/settings/SettingsWidget.js</clientfile> <clientfile load="source">js/dialogs/settings/SettingsWidget.js</clientfile>
<clientfile load="source">js/dialogs/settings/SettingsCalSyncWidget.js</clientfile> <clientfile load="source">js/dialogs/settings/SettingsCalSyncWidget.js</clientfile>
<clientfile load="source">js/dialogs/settings/ui/CalSyncGrid.js</clientfile> <clientfile load="source">js/dialogs/settings/ui/CalSyncGrid.js</clientfile>
<clientfile load="source">js/dialogs/settings/ui/CalSyncPanel.js</clientfile> <clientfile load="source">js/dialogs/settings/ui/CalSyncPanel.js</clientfile>
<clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditContentPanel.js</clientfile> <clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditContentPanel.js</clientfile>
<clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditPanel.js</clientfile> <clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditPanel.js</clientfile>
<clientfile load="source">js/plugin.calendarimporter.js</clientfile> <clientfile load="source">js/plugin.calendarimporter.js</clientfile>
</client> </client>
<resources> <resources>
<resourcefile load="release">resources/css/calendarimporter.css</resourcefile> <resourcefile load="release">resources/css/calendarimporter.css</resourcefile>
<resourcefile load="debug">resources/css/calendarimporter.css</resourcefile> <resourcefile load="debug">resources/css/calendarimporter.css</resourcefile>
<resourcefile load="source">resources/css/calendarimporter-main.css</resourcefile> <resourcefile load="source">resources/css/calendarimporter-main.css</resourcefile>
</resources> </resources>
</files> </files>
</component> </component>
</components> </components>
</plugin> </plugin>

View File

@ -1,75 +1,75 @@
<?php <?php
/** /**
* download.php, Kopano calendar to ics im/exporter * download.php, Kopano calendar to ics im/exporter
* *
* Author: Christoph Haas <christoph.h@sprinternet.at> * Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas * Copyright (C) 2012-2016 Christoph Haas
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
namespace calendarimporter; namespace calendarimporter;
class DownloadHandler class DownloadHandler
{ {
/** /**
* Download the given vcf file. * Download the given vcf file.
* @return boolean * @return boolean
*/ */
public static function doDownload() public static function doDownload()
{ {
if (isset($_GET["token"])) { if (isset($_GET["token"])) {
$token = $_GET["token"]; $token = $_GET["token"];
} else { } else {
return false; return false;
} }
if (isset($_GET["filename"])) { if (isset($_GET["filename"])) {
$filename = $_GET["filename"]; $filename = $_GET["filename"];
} else { } else {
return false; return false;
} }
// validate token // validate token
if (!preg_match('/^[a-zA-Z0-9]+$/', $token)) { // token is a md5 hash if (!preg_match('/^[a-zA-Z0-9]+$/', $token)) { // token is a md5 hash
return false; return false;
} }
$file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics"; $file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics";
if (!file_exists($file)) { // invalid token if (!file_exists($file)) { // invalid token
return false; return false;
} }
// set headers here // set headers here
header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Disposition: attachment; filename="' . $filename . '"');
// no caching // no caching
header('Expires: 0'); // set expiration time header('Expires: 0'); // set expiration time
header('Content-Description: File Transfer'); header('Content-Description: File Transfer');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Pragma: public'); header('Pragma: public');
flush(); flush();
// print the downloaded file // print the downloaded file
readfile($file); readfile($file);
ignore_user_abort(true); ignore_user_abort(true);
unlink($file); unlink($file);
return true; return true;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,30 @@
.icon_calendarimporter_button { .icon_calendarimporter_button {
background: url(../images/import_icon.png) no-repeat; background: url(../images/import_icon.png) no-repeat;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
} }
.icon_calendarimporter_export { .icon_calendarimporter_export {
background: url(../images/download.png) no-repeat; background: url(../images/download.png) no-repeat;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
} }
.icon_calendarimporter_import { .icon_calendarimporter_import {
background: url(../images/upload.png) no-repeat; background: url(../images/upload.png) no-repeat;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
} }
.zarafa-caiplg-container { .zarafa-caiplg-container {
width: 100%; width: 100%;
height: 50px; height: 50px;
} }
.zarafa-caiplg-button .x-btn-small { .zarafa-caiplg-button .x-btn-small {
width: 80%; width: 80%;
height: 30px; height: 30px;
margin-left: 10%; margin-left: 10%;
margin-right: 10%; margin-right: 10%;
margin-top: 10px; margin-top: 10px;
} }