diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-08-02 07:55:15 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-08-02 07:55:15 +0000 |
| commit | 9420400b501e0c57faf2bb9f0f394ccb2390488b (patch) | |
| tree | 06455cf4938082626c4149aa50ff1d67c8102c27 | |
| parent | 16fa4681bce4ad71236ca29a706600767ffc0a07 (diff) | |
- Improved partial ACL (in simple mode) handling/presentation
git-svn-id: https://svn.roundcube.net/trunk@5000 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | plugins/acl/acl.js | 26 | ||||
| -rw-r--r-- | plugins/acl/acl.php | 25 | ||||
| -rw-r--r-- | plugins/acl/skins/default/acl.css | 7 | ||||
| -rw-r--r-- | plugins/acl/skins/default/images/enabled.png (renamed from plugins/acl/skins/default/images/flagged.png) | bin | 674 -> 674 bytes | |||
| -rw-r--r-- | plugins/acl/skins/default/images/partial.png | bin | 0 -> 389 bytes |
5 files changed, 48 insertions, 10 deletions
diff --git a/plugins/acl/acl.js b/plugins/acl/acl.js index ce1797fd0..3cca7bf1e 100644 --- a/plugins/acl/acl.js +++ b/plugins/acl/acl.js @@ -1,7 +1,7 @@ /** * ACL plugin script * - * @version 0.4 + * @version 0.5 * @author Aleksander Machniak <alec@alec.pl> */ @@ -209,7 +209,7 @@ rcube_webmail.prototype.acl_add_row = function(o, sel) // Update new row $('td', row).map(function() { - var cl = this.className.replace(/^acl/, ''); + var r, cl = this.className.replace(/^acl/, ''); if (items && items[cl]) cl = items[cl]; @@ -217,7 +217,7 @@ rcube_webmail.prototype.acl_add_row = function(o, sel) if (cl == 'user') $(this).text(o.username); else - $(this).addClass(String(o.acl).match(RegExp(cl)) ? 'enabled' : 'disabled').text(''); + $(this).addClass(rcmail.acl_class(o.acl, cl)).text(''); }); row.attr('id', 'rcmrow'+id); @@ -316,3 +316,23 @@ rcube_webmail.prototype.acl_init_form = function(id) if (type == 'user') name_input.focus(); } + +// Returns class name according to ACL comparision result +rcube_webmail.prototype.acl_class = function(acl1, acl2) +{ + var i, len, found = 0; + + acl1 = String(acl1); + acl2 = String(acl2); + + for (i=0, len=acl2.length; i<len; i++) + if (acl1.indexOf(acl2[i]) > -1) + found++; + + if (found == len) + return 'enabled'; + else if (found) + return 'partial'; + + return 'disabled'; +} diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index 3c986a376..f512a1e00 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -3,7 +3,7 @@ /** * Folders Access Control Lists Management (RFC4314, RFC2086) * - * @version 0.4 + * @version 0.5 * @author Aleksander Machniak <alec@alec.pl> * * @@ -251,7 +251,7 @@ class acl extends rcube_plugin 'read' => 'lrs', 'write' => 'wi', 'delete' => $deleteright, - 'full' => implode($supported), + 'full' => preg_replace('/[lrswi'.$deleteright.']/', '', implode($supported)), ); foreach ($items as $key => $val) { @@ -369,7 +369,7 @@ class acl extends rcube_plugin 'read' => 'lrs', 'write' => 'wi', 'delete' => $deleteright, - 'full' => implode($supported), + 'full' => preg_replace('/[lrswi'.$deleteright.']/', '', implode($supported)), ); } @@ -403,7 +403,12 @@ class acl extends rcube_plugin foreach ($items as $key => $right) { $in = $this->acl_compare($userrights, $right); - $table->add('acl'.$key . ' ' . ($in ? 'enabled' : 'disabled'), ''); + switch ($in) { + case 2: $class = 'enabled'; break; + case 1: $class = 'partial'; break; + default: $class = 'disabled'; break; + } + $table->add('acl' . $key . ' ' . $class, ''); } $js_table[$userid] = implode($userrights); @@ -542,7 +547,7 @@ class acl extends rcube_plugin * @param array $acl1 ACL rights array (or string) * @param array $acl2 ACL rights array (or string) * - * @param boolean Comparision result + * @param int Comparision result, 2 - full match, 1 - partial match, 0 - no match */ function acl_compare($acl1, $acl2) { @@ -555,7 +560,15 @@ class acl extends rcube_plugin $acl2 = array_intersect($acl2, $rights); $res = array_intersect($acl1, $acl2); - return count($res) == count($acl2); + $cnt1 = count($res); + $cnt2 = count($acl2); + + if ($cnt1 == $cnt2) + return 2; + else if ($cnt1) + return 1; + else + return 0; } /** diff --git a/plugins/acl/skins/default/acl.css b/plugins/acl/skins/default/acl.css index c3582995d..cd8f4b72e 100644 --- a/plugins/acl/skins/default/acl.css +++ b/plugins/acl/skins/default/acl.css @@ -45,9 +45,14 @@ -o-text-overflow: ellipsis; } +#acltable tbody td.partial +{ + background: url(images/partial.png) center no-repeat; +} + #acltable tbody td.enabled { - background: url(images/flagged.png) center no-repeat; + background: url(images/enabled.png) center no-repeat; } #acltable tr.selected td diff --git a/plugins/acl/skins/default/images/flagged.png b/plugins/acl/skins/default/images/enabled.png Binary files differindex 98215f68c..98215f68c 100644 --- a/plugins/acl/skins/default/images/flagged.png +++ b/plugins/acl/skins/default/images/enabled.png diff --git a/plugins/acl/skins/default/images/partial.png b/plugins/acl/skins/default/images/partial.png Binary files differnew file mode 100644 index 000000000..12023f057 --- /dev/null +++ b/plugins/acl/skins/default/images/partial.png |
