From b6c1f28c04ee8d7082f7782b5fc519194c1b9fe5 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 26 Feb 2016 11:18:41 +0100 Subject: [PATCH] Fix bug where read-only folder was displayed as read-write in delegation form and it wasn't possible to unset ACL on a folder (#5347) --- plugins/kolab_delegation/kolab_delegation.js | 4 ++-- .../kolab_delegation/kolab_delegation_engine.php | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/kolab_delegation/kolab_delegation.js b/plugins/kolab_delegation/kolab_delegation.js index 01d6d30b..c1bbe9b6 100644 --- a/plugins/kolab_delegation/kolab_delegation.js +++ b/plugins/kolab_delegation/kolab_delegation.js @@ -188,8 +188,8 @@ rcube_webmail.prototype.delegate_save = function() } data.folders = {}; - $('input.read:checked').each(function(i, elem) { - data.folders[elem.value] = 1; + $('input.read').each(function(i, elem) { + data.folders[elem.value] = this.checked ? 1 : 0; }); $('input.write:checked').each(function(i, elem) { data.folders[elem.value] = 2; diff --git a/plugins/kolab_delegation/kolab_delegation_engine.php b/plugins/kolab_delegation/kolab_delegation_engine.php index 88e4563b..e1a62299 100644 --- a/plugins/kolab_delegation/kolab_delegation_engine.php +++ b/plugins/kolab_delegation/kolab_delegation_engine.php @@ -105,6 +105,9 @@ class kolab_delegation_engine if ($r) { $storage->set_acl($folder_name, $uid, $r); } + else { + $storage->delete_acl($folder_name, $uid); + } if (!empty($folders) && isset($folders[$folder_name])) { unset($folders[$folder_name]); @@ -863,12 +866,10 @@ class kolab_delegation_engine /** * Compares two ACLs (according to supported rights) * - * @todo: this is stolen from acl plugin, move to rcube_storage/rcube_imap - * * @param array $acl1 ACL rights array (or string) * @param array $acl2 ACL rights array (or string) * - * @param int Comparision result, 2 - full match, 1 - partial match, 0 - no match + * @param bool True if $acl1 contains all rights from $acl2 */ function acl_compare($acl1, $acl2) { @@ -884,12 +885,9 @@ class kolab_delegation_engine $cnt1 = count($res); $cnt2 = count($acl2); - if ($cnt1 == $cnt2) - return 2; - else if ($cnt1) - return 1; - else - return 0; + if ($cnt1 >= $cnt2) { + return true; + } } /**