9 Commits

37 changed files with 4016 additions and 3657 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
.idea/
.vs/

21
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,21 @@
# This file is only necessary for the gitlab to github sync and does not belong to the webapp plugin code.
#before_script:
# - ssh-keyscan -t rsa,dsa,ecdsa github.com > /etc/ssh/ssh_known_hosts
stages:
- mirror
variables:
MIRROR_REPOSITORY: "git@github.com:h44z/kopano_webapp_calendarimporter.git"
mirror-github:
stage: mirror
cache: {}
script:
# Do a mirror clone of the repository
- git clone --mirror $CI_REPOSITORY_URL
# Mirror push it to the destination
- cd $CI_PROJECT_NAME.git
- git push --mirror $MIRROR_REPOSITORY
# Cleanup
- cd ..; rm -rf $CI_PROJECT_NAME.git

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

165
LICENSE Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

120
README.md
View File

@@ -1,20 +1,124 @@
CALENDAR IMPORTER AND EXPORTER:
===
Building the calendar importer plugin for Zarafa WebApp:
## Building the calendar importer plugin from source:
### Dependencies
- Kopano WebApp Source Code (https://stash.kopano.io/projects/KW/repos/kopano-webapp/browse)
- PHP >= 5 (7 or higher recommended)
- composer (https://getcomposer.org/)
- JDK 1.8 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
- ant (http://ant.apache.org/)
Add JAVA_HOME (e.g. C:\Program Files\Java\jdk1.8.0_161) to your path. Also add Ant, Composer, PHP and Java to the global PATH variable!
### Compiling the plugin
Unzip (or use git clone) the sourcecode of Kopano WebApp to a new directory. In this README we call the source folder of WebApp "kopano-webapp-source".
Then generate the WebApp build utils:
```
cd /zarafa/webapp/
cd kopano-webapp-source
ant tools
cd /zarafa/webapp/plugins/
```
Next clone the plugin to the WebApp plugin directory:
```
cd kopano-webapp-source\plugins
git clone https://git.sprinternet.at/zarafa_webapp/calendarimporter.git
cd calendarimporter
```
Now lets build the plugin:
```
cd kopano-webapp-source\plugins\calendarimporter\php
composer install
cd kopano-webapp-source\plugins\calendarimporter
ant deploy
```
### Usage
Rightclick a calendarfolder or calendar entry to export it as iCal.
The compiled plugin is saved to `kopano-webapp-source\deploy\plugins\calendarimporter`.
Rightclick a calendarfolder to import a iCal file.
## Installing the plugin
Rightclick a iCal attachment to import it.
### From compiled source
Copy the whole folder "calendarimporter" to your production WebApp (`kopano-webapp-production\plugins\calendarimporter`)
For example:
```
cp -r kopano-webapp-source\deploy\plugins\calendarimporter kopano-webapp-production\plugins\
```
## Installing the sync backend
### From source
Copy the whole folder "kopano-webapp-source\plugins\calendarimporter\backend" to a destination of cour choice.
For example:
```
cp -r kopano-webapp-source\plugins\calendarimporter\backend /opt/ical-sync/backend
```
### From precompiled download
Download the newest backend release from https://git.sprinternet.at/zarafa_webapp/calendarimporter/tree/master/DIST.
Unzip the downloaded file and copy the backend folder to a destination of cour choice.
For example:
```
cp -r Downloads\calendarimporter_backend /opt/ical-sync/backend
```
## WebApp Plugin Configuration
Edit the config.php file in the plugin root path to fit your needs.
Available configuration values:
| Configuration Value | Type | Default | Desctription |
| ------------- |:-------------:| ----- | ----- |
| PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE | boolean | false | Set to true to enable the plugin for all users |
| PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC | string | true | Set to true to enable the sync feature for all users |
| PLUGIN_CALENDARIMPORTER_DEFAULT | string | "Kalender" | Default calendar folder name (might be "Calendar" on english installations) |
| PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE | string | "Europe/Vienna" | The local Timezone |
| PLUGIN_CALENDARIMPORTER_TMP_UPLOAD | string | "/var/lib/kopano-webapp/tmp/" | Temporary path to store uploaded iCal files |
## Sync Backend Configuration
First you have to create a new Kopano user with admin rights.
For example:
```
kopano-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1
```
Then edit the config.php file of the sync backend to fit your needs.
Available configuration values:
| Configuration Value | Type | Default | Desctription |
| ------------- |:-------------:| ----- | ----- |
| $ADMINUSERNAME | string | "adminuser" | The newly created Kopano admin user |
| $ADMINPASSWORD | string | "topsecretpw" | The password of the admin user |
| $SERVER | string | "http://localhost:236/kopano" | Kopano Socket or HTTP(S) connection string |
| $CALDAVURL | string | "http://localhost:8080/ical/" | Kopano CalDAV URL |
| $TEMPDIR | string | "/tmp/" | Temporary path to store synchronised iCal files (must be writeable by the user executing the sync script) |
Next set up a cronjob to allow periodic syncing of ical items.
For example: (`/etc/crontab`):
```
# sync ics calendars every minute (interval can be changed by the user)
* * * * * icssync /opt/ical-sync/backend/sync.php > /var/log/icssync.log 2>&1
```
If you get an error, make sure that the mapi module is loaded for php-cli. Therefore create or modify: `/etc/php7/cli/conf.d/50-mapi.ini`
```
extension=mapi.so
```
Do no run the sync script as root! Create a user without admin rights (`adduser icssync`), and change permissions of the tmp folder accordingly.
## Usage
The plugin add context menu entries to calendar folders.
![Plugin Context Menus](https://git.sprinternet.at/zarafa_webapp/calendarimporter/raw/master/usage.png "Kopano Webapp Context Menu")
If syncing is enabled, the calendar section in the WebApp settings gets extended with a synchronisation overview. There you can add new iCal URLs for syncing.
![Plugin Settings Menus](https://git.sprinternet.at/zarafa_webapp/calendarimporter/raw/master/usage_sync.png "Kopano Webapp Settings Menu")

View File

@@ -1,14 +1,54 @@
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!
# Backend setup:
## Installing the sync backend
### From source
Copy the whole folder "kopano-webapp-source\plugins\calendarimporter\backend" to a destination of cour choice.
For example:
```
cp -r kopano-webapp-source\plugins\calendarimporter\backend /opt/ical-sync/backend
```
### From precompiled download
Download the newest backend release from https://git.sprinternet.at/zarafa_webapp/calendarimporter/tree/master/DIST.
Unzip the downloaded file and copy the backend folder to a destination of cour choice.
For example:
```
cp -r Downloads\calendarimporter_backend /opt/ical-sync/backend
```
## Sync Backend Configuration
First you have to create a new Kopano user with admin rights.
For example:
```
kopano-admin -c adminuser -e admin@domain.com -f "Calendar Sync Admin" -p topsecretpw -a 1
```
Then edit the config.php file of the sync backend to fit your needs.
Available configuration values:
| Configuration Value | Type | Default | Desctription |
| ------------- |:-------------:| ----- | ----- |
| $ADMINUSERNAME | string | "adminuser" | The newly created Kopano admin user |
| $ADMINPASSWORD | string | "topsecretpw" | The password of the admin user |
| $SERVER | string | "http://localhost:236/kopano" | Kopano Socket or HTTP(S) connection string |
| $CALDAVURL | string | "http://localhost:8080/ical/" | Kopano CalDAV URL |
| $TEMPDIR | string | "/tmp/" | Temporary path to store synchronised iCal files (must be writeable by the user executing the sync script) |
Next set up a cronjob to allow periodic syncing of ical items.
For example: (`/etc/crontab`):
```
# sync ics calendars every minute (interval can be changed by the user)
* * * * * icssync /opt/ical-sync/backend/sync.php > /var/log/icssync.log 2>&1
```
If you get an error, make sure that the mapi module is loaded for php-cli. Therefore create or modify: `/etc/php7/cli/conf.d/50-mapi.ini`
```
extension=mapi.so
```
Do no run the sync script as root! Create a user without admin rights (`adduser icssync`), and change permissions of the tmp folder accordingly.

View File

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

View File

@@ -1,165 +1,191 @@
<?php
/**
* 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, Kopano calender to ics im/exporter backend
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2018 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
*
* @param $url
* @param null $username
* @param null $password
* @return mixed|null
*/
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
*
* @param $userStore
* @return null|void
*/
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
*
* @param $userStore
* @param $icsentry
* @return bool|void
*/
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
*
* @param $filename
* @param $caldavurl
* @param $username
* @param $calendarname
* @param null $authuser
* @param null $authpass
* @return int
*/
function upload_ics_to_caldav($filename, $caldavurl, $username, $calendarname, $authuser = NULL, $authpass = NULL) {
$url = $caldavurl . $username . "/" . rawurlencode($calendarname) . "/";
$post = array('file'=>'@'.$filename);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$fp = fopen($filename, 'r');
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize ($filename));
if($authuser != NULL && $authpass != NULL) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$authuser:$authpass");
}
$result=curl_exec($ch);
$http_status = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
curl_close($ch);
echo "uploading file to: " . $url . " (" . $http_status . ")\n";
return $http_status;
}

View File

@@ -1,150 +1,149 @@
#!/usr/bin/php
<?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, Kopano calender to ics im/exporter backend
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2018 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 kopano mapi extension is enabled in cli mode:
* Add: /etc/php5/cli/conf.d/50-mapi.ini
* Content: extension=mapi.so
*/
// MAPI includes
include('mapi/mapi.util.php');
include('mapi/mapidefs.php');
include('mapi/mapicode.php');
include('mapi/mapitags.php');
include('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 Kopano 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,71 @@
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
v2.2.3: 14.06.2018
- Fixed JS error, thanks to hartois
- Fixed manifest.xml structure (validation now succeeds)
calendarimporter 2.2.2:
- updated documentation
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,56 @@
/**
* 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>";
/**
* ABOUT.js, Kopano calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2018 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-2018 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>sabre-io/vobject v4.1</h1>"
+ "<p>Copyright (C) 2011-2016 fruux GmbH (https://fruux.com/)</p>"
+ "<p>Licensed under the BSD 3-Clause \"New\" or \"Revised\" License</p>";

View File

@@ -2,7 +2,7 @@
* Actions.js zarafa calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
* Copyright (C) 2012-2018 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -128,7 +128,7 @@ Zarafa.plugins.calendarimporter.data.Actions = {
var inbox = container.getHierarchyStore().getDefaultStore();
var pub = container.getHierarchyStore().getPublicStore();
if (!Ext.isEmpty(inbox.subStores) && inbox.subStores.folders.totalLength > 0) {
if (!Ext.isEmpty(inbox) && !Ext.isEmpty(inbox.subStores)) {
for (var i = 0; i < inbox.subStores.folders.totalLength; i++) {
var folder = inbox.subStores.folders.getAt(i);
if (!Ext.isEmpty(folder) && folder.get("container_class") == "IPF.Appointment") {
@@ -149,7 +149,7 @@ Zarafa.plugins.calendarimporter.data.Actions = {
}
}
if (!Ext.isEmpty(pub.subStores) && pub.subStores.folders.totalLength > 0) {
if (!Ext.isEmpty(pub) && !Ext.isEmpty(pub.subStores)) {
for (var j = 0; j < pub.subStores.folders.totalLength; j++) {
var folder = pub.subStores.folders.getAt(j);
if (!Ext.isEmpty(folder) && folder.get("container_class") == "IPF.Appointment") {

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-2018 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-2018 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

@@ -2,7 +2,7 @@
* ImportPanel.js, Kopano calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
* Copyright (C) 2012-2018 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

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-2018 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-2018 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-2018 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-2018 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-2018 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-2018 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-2018 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

@@ -2,7 +2,7 @@
* ContectMenu.js, Kopano calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
* Copyright (C) 2012-2018 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

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.3</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>
<config>
<configfile>config.php</configfile>
</config>
<translations>
<translationsdir>languages</translationsdir>
</translations>
<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-2018 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;
}
}

View File

@@ -3,7 +3,7 @@
* helper.php, Kopano calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
* Copyright (C) 2012-2018 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
* plugin.calendarimporter.php, Kopano calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
* Copyright (C) 2012-2018 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View File

@@ -3,7 +3,7 @@
* upload.php, Kopano calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 Christoph Haas
* Copyright (C) 2012-2018 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

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;
}

BIN
usage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
usage_sync.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB