plugins/kolab_activesync
Aleksander Machniak
machniak at kolabsys.com
Tue Aug 12 13:43:57 CEST 2014
plugins/kolab_activesync/kolab_activesync.js | 33 +++++++++++-
plugins/kolab_activesync/kolab_activesync.php | 62 +++++++++++++++++++++--
plugins/kolab_activesync/kolab_activesync_ui.php | 50 ++++++++++++++++++
plugins/kolab_activesync/package.xml | 4 -
plugins/kolab_activesync/skins/larry/config.css | 17 +++++-
5 files changed, 155 insertions(+), 11 deletions(-)
New commits:
commit f75cc4757d3759da158cf60c32e0a9a9217592a7
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Tue Aug 12 13:43:25 2014 +0200
Added ActiveSync section in folder editing form (#476)
diff --git a/plugins/kolab_activesync/kolab_activesync.js b/plugins/kolab_activesync/kolab_activesync.js
index 9aa78e1..7146a80 100644
--- a/plugins/kolab_activesync/kolab_activesync.js
+++ b/plugins/kolab_activesync/kolab_activesync.js
@@ -41,7 +41,7 @@ function kolab_activesync_config()
if (!rcmail.env.devicecount)
device_select();
}
- else {
+ else if (rcmail.env.action != 'edit-folder') {
if (rcmail.env.active_device)
rcmail.enable_command('plugin.save-config', true);
@@ -155,9 +155,36 @@ function kolab_activesync_config()
this.update_list = function(id, name)
{
$('#devices-table tr.selected span.devicealias').html(name);
- }
-};
+ };
+
+ this.update_sync_data = function(elem)
+ {
+ elem.name.match(/^_(subscriptions|alarms)\[(.+)\]$/);
+
+ var flag, type = RegExp.$1, device = RegExp.$2,
+ http_lock = rcmail.set_busy(true, 'kolab_activesync.savingdata');
+ // set subscription flag
+ if (elem.checked) {
+ flag = type == 'alarms' ? 2 : 1;
+ }
+ else {
+ flag = type == 'alarms' ? 1 : 0;
+ }
+
+ // make sure subscription checkbox is checked if alarms is checked
+ if (flag == 2) {
+ $('input[name="_subscriptions[' + device + ']"]').prop('checked', true);
+ }
+ // make sure alarms checkbox is unchecked if subscription is unchecked
+ else if (flag == 0) {
+ $('input[name="_alarms[' + device + ']"]').prop('checked', false);
+ }
+
+ // send the request
+ rcmail.http_post('plugin.activesync-json', {cmd: 'update', id: device, flag: flag, folder: rcmail.env.folder}, http_lock);
+ };
+};
window.rcmail && rcmail.addEventListener('init', function(evt) {
activesync_object = new kolab_activesync_config();
diff --git a/plugins/kolab_activesync/kolab_activesync.php b/plugins/kolab_activesync/kolab_activesync.php
index 1fc1d08..dc36383 100644
--- a/plugins/kolab_activesync/kolab_activesync.php
+++ b/plugins/kolab_activesync/kolab_activesync.php
@@ -53,10 +53,12 @@ class kolab_activesync extends rcube_plugin
$this->register_action('plugin.activesync-json', array($this, 'json_command'));
$this->add_hook('settings_actions', array($this, 'settings_actions'));
+ $this->add_hook('folder_form', array($this, 'folder_form'));
- $this->add_texts('localization/', array('devicedeleteconfirm', 'savingdata'));
+ $this->add_texts('localization/');
- if (strpos($this->rc->action, 'plugin.activesync') === 0) {
+ if (preg_match('/^(plugin.activesync|edit-folder|save-folder)/', $this->rc->action)) {
+ $this->add_label('devicedeleteconfirm', 'savingdata');
$this->include_script('kolab_activesync.js');
}
}
@@ -78,12 +80,51 @@ class kolab_activesync extends rcube_plugin
}
/**
+ * Handler for folder info/edit form (folder_form hook).
+ * Adds ActiveSync section.
+ */
+ function folder_form($args)
+ {
+ $mbox_imap = $args['options']['name'];
+ $myrights = $args['options']['rights'];
+
+ // Edited folder name (empty in create-folder mode)
+ if (!strlen($mbox_imap)) {
+ return $args;
+ }
+
+ $devices = $this->list_devices();
+
+ // no registered devices
+ if (empty($devices)) {
+ return $args;
+ }
+
+ list($type, ) = explode('.', (string) kolab_storage::folder_type($mbox_imap));
+ if ($type && !in_array($type, array('mail', 'event', 'contact', 'task', 'note'))) {
+ return $args;
+ }
+
+ require_once $this->home . '/kolab_activesync_ui.php';
+ $this->ui = new kolab_activesync_ui($this);
+
+ if ($content = $this->ui->folder_options_table($mbox_imap, $devices, $type)) {
+ $args['form']['activesync'] = array(
+ 'name' => rcube::Q($this->gettext('tabtitle')),
+ 'content' => $content,
+ );
+ }
+
+ return $args;
+ }
+
+ /**
* Handle JSON requests
*/
public function json_command()
{
- $cmd = get_input_value('cmd', RCUBE_INPUT_GPC);
- $imei = get_input_value('id', RCUBE_INPUT_GPC);
+ $cmd = get_input_value('cmd', RCUBE_INPUT_POST);
+ $imei = get_input_value('id', RCUBE_INPUT_POST);
switch ($cmd) {
case 'save':
@@ -130,6 +171,19 @@ class kolab_activesync extends rcube_plugin
$this->rc->output->show_message($this->gettext('savingerror'), 'error');
break;
+
+ case 'update':
+ $subscription = (int) get_input_value('flag', RCUBE_INPUT_POST);
+ $folder = get_input_value('folder', RCUBE_INPUT_POST);
+
+ $err = !$this->folder_set($folder, $imei, $subscription);
+
+ if ($err)
+ $this->rc->output->show_message($this->gettext('savingerror'), 'error');
+ else
+ $this->rc->output->show_message($this->gettext('successfullysaved'), 'confirmation');
+
+ break;
}
$this->rc->output->send();
diff --git a/plugins/kolab_activesync/kolab_activesync_ui.php b/plugins/kolab_activesync/kolab_activesync_ui.php
index e2ff93f..4ede94d 100644
--- a/plugins/kolab_activesync/kolab_activesync_ui.php
+++ b/plugins/kolab_activesync/kolab_activesync_ui.php
@@ -37,7 +37,6 @@ class kolab_activesync_ui
$this->skin_path = 'plugins/kolab_activesync/' . $skin_path;
$this->plugin->include_stylesheet($skin_path . 'config.css');
- $this->rc->output->include_script('list.js');
}
public function device_list($attrib = array())
@@ -56,6 +55,8 @@ class kolab_activesync_ui
$this->rc->output->add_gui_object('devicelist', $attrib['id']);
$this->rc->output->set_env('devicecount', count($devices));
+ $this->rc->output->include_script('list.js');
+
return $table->show($attrib);
}
@@ -195,4 +196,51 @@ class kolab_activesync_ui
return $table->show();
}
+
+ public function folder_options_table($folder_name, $devices, $type)
+ {
+ $alarms = $type == 'event' || $type == 'task';
+ $meta = $this->plugin->folder_meta();
+ $folder_data = (array) ($meta[$folder_name] ? $meta[$folder_name]['FOLDER'] : null);
+
+ $table = new html_table(array('cellspacing' => 0, 'id' => 'folder-sync-options', 'class' => 'records-table'));
+
+ // table header
+ $table->add_header(array('class' => 'device'), $this->plugin->gettext('devicealias'));
+ $table->add_header(array('class' => 'subscription'), $this->plugin->gettext('synchronize'));
+ if ($alarms) {
+ $table->add_header(array('class' => 'alarm'), $this->plugin->gettext('withalarms'));
+ }
+
+ // table records
+ foreach ($devices as $id => $device) {
+ $info = $this->plugin->device_info($device['ID']);
+ $name = $id;
+ $title = '';
+ $checkbox = new html_checkbox(array('name' => "_subscriptions[$id]", 'value' => 1,
+ 'onchange' => 'return activesync_object.update_sync_data(this)'));
+
+ if (!empty($info)) {
+ $_name = trim($info['friendlyname'] . ' ' . $info['os']);
+ $title = $info['useragent'];
+
+ if ($_name) {
+ $name .= " ($_name)";
+ }
+ }
+
+ $table->add_row();
+ $table->add(array('class' => 'device', 'title' => $title), $name);
+ $table->add('subscription', $checkbox->show(!empty($folder_data[$id]['S']) ? 1 : 0));
+
+ if ($alarms) {
+ $checkbox_alarm = new html_checkbox(array('name' => "_alarms[$id]", 'value' => 1,
+ 'onchange' => 'return activesync_object.update_sync_data(this)'));
+
+ $table->add('alarm', $checkbox_alarm->show($folder_data[$id]['S'] > 1 ? 1 : 0));
+ }
+ }
+
+ return $table->show();
+ }
}
diff --git a/plugins/kolab_activesync/package.xml b/plugins/kolab_activesync/package.xml
index 3d584b8..44ba925 100644
--- a/plugins/kolab_activesync/package.xml
+++ b/plugins/kolab_activesync/package.xml
@@ -19,9 +19,9 @@
<email>bruederli at kolabsys.com</email>
<active>yes</active>
</lead>
- <date>2013-04-09</date>
+ <date>2014-08-12</date>
<version>
- <release>1.0</release>
+ <release>1.1</release>
<api>1.0</api>
</version>
<stability>
diff --git a/plugins/kolab_activesync/skins/larry/config.css b/plugins/kolab_activesync/skins/larry/config.css
index dc6c3d1..b61885b 100644
--- a/plugins/kolab_activesync/skins/larry/config.css
+++ b/plugins/kolab_activesync/skins/larry/config.css
@@ -46,7 +46,7 @@ div.subscriptionblock h3.event {
}
div.subscriptionblock h3.task {
- background-position: 4px -58x;
+ background-position: 4px -58px;
}
div.subscriptionblock h3.note {
@@ -98,6 +98,21 @@ div.subscriptionblock h3.note {
margin-top: 0.5em;
}
+#folder-sync-options {
+ border-radius: 4px;
+}
+
+#folder-sync-options td.subscription,
+#folder-sync-options td.alarm,
+#folder-sync-options th {
+ text-align: center;
+}
+
+#folder-sync-options th.subscription,
+#folder-sync-options th.alarm {
+ width: 90px;
+}
+
#introtext {
position: absolute;
top: 16px;
More information about the commits
mailing list