Line endings

This commit is contained in:
Christoph Haas 2016-12-16 14:51:48 +01:00
parent 41ea9199a0
commit 275913dea8
21 changed files with 3655 additions and 3648 deletions

View File

@ -1,14 +1,14 @@
Backend setup:
1. Create a Admin User in Zarafa:
zarafa-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1
2. Edit the config.php to fit your needs.
3. Setup cron to run your script every 10 minutes (or whatever...)
4. If you get an error, make sure that the mapi module is loaded for php-cli:
* Add: /etc/php5/cli/conf.d/50-mapi.ini
* Content: extension=mapi.so
Backend setup:
1. Create a Admin User in Zarafa:
zarafa-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1
2. Edit the config.php to fit your needs.
3. Setup cron to run your script every 10 minutes (or whatever...)
4. If you get an error, make sure that the mapi module is loaded for php-cli:
* Add: /etc/php5/cli/conf.d/50-mapi.ini
* Content: extension=mapi.so
Never run the backend script as root!

View File

@ -1 +1,8 @@
<?php // config options $ADMINUSERNAME = "admin"; $ADMINPASSWORD = "admin"; $SERVER = "file:///var/run/zarafa"; $CALDAVURL = "http://localhost:8080/ical/"; $TEMPDIR = "/tmp/"; ?>
<?php
// config options
$ADMINUSERNAME = "admin";
$ADMINPASSWORD = "admin";
$SERVER = "file:///var/run/zarafa";
$CALDAVURL = "http://localhost:8080/ical/";
$TEMPDIR = "/tmp/";
?>

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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