From a1335b963f47c160c916d88898e92ac5456e858b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 14 Mar 2014 10:08:58 +0100 Subject: [PATCH 1/5] Add Settings section in PHP not javascript, small improvements --- plugins/kolab_activesync/kolab_activesync.js | 22 +---------------- plugins/kolab_activesync/kolab_activesync.php | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/plugins/kolab_activesync/kolab_activesync.js b/plugins/kolab_activesync/kolab_activesync.js index d9e2943e..1f625e6b 100644 --- a/plugins/kolab_activesync/kolab_activesync.js +++ b/plugins/kolab_activesync/kolab_activesync.js @@ -159,25 +159,5 @@ function kolab_activesync_config() window.rcmail && rcmail.addEventListener('init', function(evt) { - // add button to tabs list - var tab = $('').attr('id', 'settingstabpluginactivesync').addClass('tablink'), - button = $('').attr('href', rcmail.env.comm_path+'&_action=plugin.activesync') - .html(rcmail.gettext('tabtitle', 'kolab_activesync')) - .appendTo(tab); - rcmail.add_element(tab, 'tabs'); - - if (/^plugin.activesync/.test(rcmail.env.action)) - activesync_object = new kolab_activesync_config(); + activesync_object = new kolab_activesync_config(); }); - - -// extend jQuery -(function($){ - $.fn.serializeJSON = function(){ - var json = {}; - jQuery.map($(this).serializeArray(), function(n, i) { - json[n['name']] = n['value']; - }); - return json; - }; -})(jQuery); diff --git a/plugins/kolab_activesync/kolab_activesync.php b/plugins/kolab_activesync/kolab_activesync.php index 05e1f354..a7ee1014 100644 --- a/plugins/kolab_activesync/kolab_activesync.php +++ b/plugins/kolab_activesync/kolab_activesync.php @@ -52,8 +52,28 @@ class kolab_activesync extends rcube_plugin $this->register_action('plugin.activesync-config', array($this, 'config_frame')); $this->register_action('plugin.activesync-json', array($this, 'json_command')); - $this->add_texts('localization/', true); - $this->include_script('kolab_activesync.js'); + $this->add_hook('settings_actions', array($this, 'settings_actions')); + + $this->add_texts('localization/', array('devicedeleteconfirm', 'savingdata')); + + if (strpos($this->rc->action, 'plugin.activesync') === 0) { + $this->include_script('kolab_activesync.js'); + } + } + + /** + * Adds Activesync section in Settings + */ + function settings_actions($args) + { + $args['actions'][] = array( + 'action' => 'plugin.activesync', + 'class' => 'activesync', + 'label' => 'tabtitle', + 'domain' => 'kolab_activesync', + ); + + return $args; } /** From df2ed0d8e6417eea9718b92324d56d524173f6e3 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 14 Mar 2014 10:25:33 +0100 Subject: [PATCH 2/5] Add Settings action in PHP not in javascript, small improvements --- plugins/kolab_delegation/kolab_delegation.js | 7 ------ plugins/kolab_delegation/kolab_delegation.php | 25 +++++++++++++++++-- .../kolab_delegation/skins/larry/style.css | 4 +-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/plugins/kolab_delegation/kolab_delegation.js b/plugins/kolab_delegation/kolab_delegation.js index 1efa70bc..d113c71f 100644 --- a/plugins/kolab_delegation/kolab_delegation.js +++ b/plugins/kolab_delegation/kolab_delegation.js @@ -38,13 +38,6 @@ window.rcmail && rcmail.addEventListener('init', function(evt) { else if (rcmail.env.task != 'settings') return; - // add Delegation section to the list - var tab = $('').attr('id', 'settingstabplugindelegation').addClass('tablink'), - button = $('').attr('href', rcmail.env.comm_path+'&_action=plugin.delegation') - .html(rcmail.gettext('tabtitle', 'kolab_delegation')) - .appendTo(tab); - rcmail.add_element(tab, 'tabs'); - if (/^plugin.delegation/.test(rcmail.env.action)) { rcmail.addEventListener('plugin.delegate_save_complete', function(e) { rcmail.delegate_save_complete(e); }); diff --git a/plugins/kolab_delegation/kolab_delegation.php b/plugins/kolab_delegation/kolab_delegation.php index 060308fb..8b4a5ef9 100644 --- a/plugins/kolab_delegation/kolab_delegation.php +++ b/plugins/kolab_delegation/kolab_delegation.php @@ -65,9 +65,15 @@ class kolab_delegation extends rcube_plugin $this->register_action('plugin.delegation-save', array($this, 'controller_action')); $this->register_action('plugin.delegation-autocomplete', array($this, 'controller_action')); + $this->add_hook('settings_actions', array($this, 'settings_actions')); + if ($this->rc->action == 'plugin.delegation' || empty($_REQUEST['_framed'])) { - $this->add_texts('localization/', array('tabtitle', 'deleteconfirm', 'savingdata', 'yes', 'no')); - $this->include_script('kolab_delegation.js'); + $this->add_texts('localization/', array('deleteconfirm', 'savingdata', 'yes', 'no')); + + if ($this->rc->action == 'plugin.delegation') { + $this->include_script('kolab_delegation.js'); + } + $this->skin_path = $this->local_skin_path(); $this->include_stylesheet($this->skin_path . '/style.css'); } @@ -78,6 +84,21 @@ class kolab_delegation extends rcube_plugin } } + /** + * Adds Delegation section in Settings + */ + function settings_actions($args) + { + $args['actions'][] = array( + 'action' => 'plugin.delegation', + 'class' => 'delegation', + 'label' => 'tabtitle', + 'domain' => 'kolab_delegation', + ); + + return $args; + } + /** * Engine object getter */ diff --git a/plugins/kolab_delegation/skins/larry/style.css b/plugins/kolab_delegation/skins/larry/style.css index 35c1bf68..eda61c17 100644 --- a/plugins/kolab_delegation/skins/larry/style.css +++ b/plugins/kolab_delegation/skins/larry/style.css @@ -1,10 +1,10 @@ /* Stylesheets for the Kolab Delegation configuration UI */ -#settings-sections #settingstabplugindelegation a { +#settings-sections span.listitem.delegation a { background: url(delegation.png) 6px 1px no-repeat; } -#settings-sections #settingstabplugindelegation.selected a { +#settings-sections span.listitem.delegation.selected a { background-position: 6px -23px; } From 32ffbe0adecb0ae26f90e60f856cde8506e03227 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 14 Mar 2014 14:05:26 +0100 Subject: [PATCH 3/5] Fix case-sensitivity in normalization/mapping of LDAP entries (Bug #2905) --- plugins/kolab_auth/kolab_auth_ldap.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/kolab_auth/kolab_auth_ldap.php b/plugins/kolab_auth/kolab_auth_ldap.php index ddf7cffe..d529b73e 100644 --- a/plugins/kolab_auth/kolab_auth_ldap.php +++ b/plugins/kolab_auth/kolab_auth_ldap.php @@ -329,12 +329,14 @@ class kolab_auth_ldap extends rcube_ldap_generic // fields mapping foreach ($this->fieldmap as $field => $attr) { - // $entry is indexed by lower-case attribute names + // $entry might be indexed by lower-case attribute names $attr_lc = strtolower($attr); if (isset($entry[$attr_lc])) { $entry[$field] = $entry[$attr_lc]; } - // @TODO: consider returning also $entry[$attr] when $attr != $attr_lc + else if (isset($entry[$attr])) { + $entry[$field] = $entry[$attr]; + } } return $entry; From bf283d2fc2afd61b2eb2bb4c5ff392709949074a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 15 Mar 2014 15:18:29 +0100 Subject: [PATCH 4/5] Support Note objects --- plugins/libkolab/lib/kolab_format.php | 48 +++++++++++++++++++++- plugins/libkolab/lib/kolab_format_note.php | 43 +++++++++++++++++-- plugins/libkolab/lib/kolab_format_xcal.php | 40 +----------------- 3 files changed, 88 insertions(+), 43 deletions(-) diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php index 238ac648..11a5c4fe 100644 --- a/plugins/libkolab/lib/kolab_format.php +++ b/plugins/libkolab/lib/kolab_format.php @@ -45,7 +45,7 @@ abstract class kolab_format protected $version = '3.0'; const KTYPE_PREFIX = 'application/x-vnd.kolab.'; - const PRODUCT_ID = 'Roundcube-libkolab-0.9'; + const PRODUCT_ID = 'Roundcube-libkolab-0.9'; /** * Factory method to instantiate a kolab_format object of the given type and version @@ -497,4 +497,50 @@ abstract class kolab_format { return array(); } + + protected function get_attachments(&$object) + { + // handle attachments + $vattach = $this->obj->attachments(); + for ($i=0; $i < $vattach->size(); $i++) { + $attach = $vattach->get($i); + + // skip cid: attachments which are mime message parts handled by kolab_storage_folder + if (substr($attach->uri(), 0, 4) != 'cid:' && $attach->label()) { + $name = $attach->label(); + $content = $attach->data(); + $object['_attachments'][$name] = array( + 'name' => $name, + 'mimetype' => $attach->mimetype(), + 'size' => strlen($content), + 'content' => $content, + ); + } + else if (substr($attach->uri(), 0, 4) == 'http') { + $object['links'][] = $attach->uri(); + } + } + } + + protected function set_attachments($object) + { + // save attachments + $vattach = new vectorattachment; + foreach ((array) $object['_attachments'] as $cid => $attr) { + if (empty($attr)) + continue; + $attach = new Attachment; + $attach->setLabel((string)$attr['name']); + $attach->setUri('cid:' . $cid, $attr['mimetype']); + $vattach->push($attach); + } + + foreach ((array) $object['links'] as $link) { + $attach = new Attachment; + $attach->setUri($link, 'unknown'); + $vattach->push($attach); + } + + $this->obj->setAttachments($vattach); + } } diff --git a/plugins/libkolab/lib/kolab_format_note.php b/plugins/libkolab/lib/kolab_format_note.php index 04a84213..1f49deeb 100644 --- a/plugins/libkolab/lib/kolab_format_note.php +++ b/plugins/libkolab/lib/kolab_format_note.php @@ -31,6 +31,11 @@ class kolab_format_note extends kolab_format protected $read_func = 'readNote'; protected $write_func = 'writeNote'; + protected $sensitivity_map = array( + 'public' => kolabformat::ClassPublic, + 'private' => kolabformat::ClassPrivate, + 'confidential' => kolabformat::ClassConfidential, + ); /** * Set properties to the kolabformat object @@ -42,7 +47,12 @@ class kolab_format_note extends kolab_format // set common object properties parent::set($object); - // TODO: set object propeties + $this->obj->setSummary($object['title']); + $this->obj->setDescription($object['description']); + $this->obj->setClassification($this->sensitivity_map[$object['sensitivity']]); + $this->obj->setCategories(self::array2vector($object['categories'])); + + $this->set_attachments($object); // cache this data $this->data = $object; @@ -73,10 +83,35 @@ class kolab_format_note extends kolab_format // read common object props into local data object $object = parent::to_array($data); - // TODO: read object properties + $sensitivity_map = array_flip($this->sensitivity_map); - $this->data = $object; - return $this->data; + // read object properties + $object += array( + 'sensitivity' => $sensitivity_map[$this->obj->classification()], + 'categories' => self::vector2array($this->obj->categories()), + 'title' => $this->obj->summary(), + 'description' => $this->obj->description(), + ); + + $this->get_attachments($object); + + return $this->data = $object; + } + + /** + * Callback for kolab_storage_cache to get object specific tags to cache + * + * @return array List of tags to save in cache + */ + public function get_tags() + { + $tags = array(); + + foreach ((array) $this->data['categories'] as $cat) { + $tags[] = rcube_utils::normalize_string($cat); + } + + return $tags; } } diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php index 4af692c4..a2544f4b 100644 --- a/plugins/libkolab/lib/kolab_format_xcal.php +++ b/plugins/libkolab/lib/kolab_format_xcal.php @@ -237,26 +237,7 @@ abstract class kolab_format_xcal extends kolab_format } } - // handle attachments - $vattach = $this->obj->attachments(); - for ($i=0; $i < $vattach->size(); $i++) { - $attach = $vattach->get($i); - - // skip cid: attachments which are mime message parts handled by kolab_storage_folder - if (substr($attach->uri(), 0, 4) != 'cid:' && $attach->label()) { - $name = $attach->label(); - $content = $attach->data(); - $object['_attachments'][$name] = array( - 'name' => $name, - 'mimetype' => $attach->mimetype(), - 'size' => strlen($content), - 'content' => $content, - ); - } - else if (substr($attach->uri(), 0, 4) == 'http') { - $object['links'][] = $attach->uri(); - } - } + $this->get_attachments($object); return $object; } @@ -443,24 +424,7 @@ abstract class kolab_format_xcal extends kolab_format } $this->obj->setAlarms($valarms); - // save attachments - $vattach = new vectorattachment; - foreach ((array)$object['_attachments'] as $cid => $attr) { - if (empty($attr)) - continue; - $attach = new Attachment; - $attach->setLabel((string)$attr['name']); - $attach->setUri('cid:' . $cid, $attr['mimetype']); - $vattach->push($attach); - } - - foreach ((array)$object['links'] as $link) { - $attach = new Attachment; - $attach->setUri($link, 'unknown'); - $vattach->push($attach); - } - - $this->obj->setAttachments($vattach); + $this->set_attachments($object); } /** From 02a84b391f4b9986bc4cdda8574ec2653404efb7 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 15 Mar 2014 15:19:24 +0100 Subject: [PATCH 5/5] Display folders of type 'note' for selection to sync --- plugins/kolab_activesync/kolab_activesync_ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kolab_activesync/kolab_activesync_ui.php b/plugins/kolab_activesync/kolab_activesync_ui.php index 6dcdcaab..84c8b880 100644 --- a/plugins/kolab_activesync/kolab_activesync_ui.php +++ b/plugins/kolab_activesync/kolab_activesync_ui.php @@ -95,7 +95,7 @@ class kolab_activesync_ui $attrib['id'] = 'foldersubscriptions'; // group folders by type (show only known types) - $folder_groups = array('mail' => array(), 'contact' => array(), 'event' => array(), 'task' => array()); + $folder_groups = array('mail' => array(), 'contact' => array(), 'event' => array(), 'task' => array(), 'note' => array()); $folder_types = kolab_storage::folders_typedata(); $imei = $this->device['_id']; $subscribed = array();