From 63e0157bafaa075c1c15af91174e876c44900a3e Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 11 May 2017 16:47:31 +0200 Subject: [PATCH] WIP of RFC 4314 implementation, in order to be able to separate delete message right and delete mailbox right in mail acl dialog --- mail/inc/class.mail_acl.inc.php | 50 ++++++++++++++++++++++ mail/js/app.js | 73 ++++++++++++++++++++------------- mail/templates/default/acl.xet | 32 ++++++++++----- 3 files changed, 117 insertions(+), 38 deletions(-) diff --git a/mail/inc/class.mail_acl.inc.php b/mail/inc/class.mail_acl.inc.php index ffe2dded5b..f2afd24d05 100644 --- a/mail/inc/class.mail_acl.inc.php +++ b/mail/inc/class.mail_acl.inc.php @@ -10,6 +10,56 @@ * @version $Id$ */ +/* + * Reference: RFC 4314 DOCUMENTATION - RIGHTS (https://tools.ietf.org/html/rfc4314) + * + * Standard Rights: + * + * The currently defined standard rights are (note that the list below + * doesn't list all commands that use a particular right): + * + * l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox) + * r - read (SELECT the mailbox, perform STATUS) + * s - keep seen/unseen information across sessions (set or clear \SEEN flag + * via STORE, also set \SEEN during APPEND/COPY/ FETCH BODY[...]) + * w - write (set or clear flags other than \SEEN and \DELETED via + * STORE, also set them during APPEND/COPY) + * i - insert (perform APPEND, COPY into mailbox) + * p - post (send mail to submission address for mailbox, + * not enforced by IMAP4 itself) + * k - create mailboxes (CREATE new sub-mailboxes in any + * implementation-defined hierarchy, parent mailbox for the new + * mailbox name in RENAME) + * x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) + * t - delete messages (set or clear \DELETED flag via STORE, set + * \DELETED flag during APPEND/COPY) + * e - perform EXPUNGE and expunge as a part of CLOSE + * a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) + * + * + * + * Obsolete Rights: + * + * Due to ambiguity in RFC 2086, some existing RFC 2086 server + * implementations use the "c" right to control the DELETE command. + * Others chose to use the "d" right to control the DELETE command. For + * the former group, let's define the "create" right as union of the "k" + * and "x" rights, and the "delete" right as union of the "e" and "t" + * rights. For the latter group, let's define the "create" rights as a + * synonym to the "k" right, and the "delete" right as union of the "e", + * "t", and "x" rights. + * For compatibility with RFC 2086, this section defines two virtual + * rights "d" and "c". + * If a client includes the "d" right in a rights list, then it MUST be + * treated as if the client had included every member of the "delete" + * right. (It is not an error for a client to specify both the "d" + * right and one or more members of the "delete" right, but the effect + * is no different than if just the "d" right or all members of the + * "delete" right had been specified.) + * + */ + + use EGroupware\Api; use EGroupware\Api\Framework; use EGroupware\Api\Etemplate; diff --git a/mail/js/app.js b/mail/js/app.js index 36967f1036..51b7b297b7 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -62,7 +62,7 @@ app.classes.mail = AppJS.extend( * @array * */ - aclRights:['l','r','s','w','i','p','c','d','a'], + aclRights:['l','r','s','w','i','p','c','d','k','x','t','e','a'], /** * In order to store Intervals assigned to window @@ -3920,6 +3920,11 @@ app.classes.mail = AppJS.extend( { var rightsWidget = this.et2.getWidgetById(rowId+'[acl_' + this.aclRights[i]+ ']'); rightsWidget.set_value((jQuery.inArray(this.aclRights[i],rights) != -1 )?true:false); + if ((rights.indexOf('c') == -1 && ['k','x'].indexOf(this.aclRights[i]) > -1) + || (rights.indexOf('d') == -1 && ['e','x','t'].indexOf(this.aclRights[i]) > -1 )) + { + rightsWidget.set_readonly(false); + } } } }, @@ -3934,35 +3939,47 @@ app.classes.mail = AppJS.extend( */ acl_common_rights: function(event, widget) { - var rowId = widget.id.replace(/[^0-9.]+/g, ''); - var aclCommonWidget = this.et2.getWidgetById(rowId + '[acl]'); - var rights = ''; + var rowId = widget.id.replace(/[^0-9.]+/g, ''); + var aclCommonWidget = this.et2.getWidgetById(rowId + '[acl]'); + var rights = ''; + var selectedBox = widget.id; + var virtualDelete = ['e','t','x']; + var virtualCreate = ['k','x']; - for (var i=0;i-1) + { + rightsWidget.set_value(false); + rightsWidget.set_readonly(widget.get_value() == "true" ? true:false); + } + if (selectedBox == rowId+'[acl_d]' && virtualDelete.indexOf(this.aclRights[i])>-1) + { + rightsWidget.set_value(false); + rightsWidget.set_readonly(widget.get_value() == "true" ? true:false); + } + if (rightsWidget.get_value() == "true") + rights += this.aclRights[i]; + } - } - - for (var i=0;i + + + + - - - - - - - - - - + + + + + + + + + + + + + + @@ -63,6 +71,10 @@ + + + +