From 34827545cc4a1b0f1960f0c81f244ed92d800b78 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 15 Nov 2013 17:22:46 +0000 Subject: [PATCH] Mail folder ACLs feature on mail app --- mail/inc/class.mail_acl.inc.php | 102 ++++++++++++++++++++++++++++++++ mail/inc/class.mail_ui.inc.php | 20 ++++++- mail/js/app.js | 12 ++++ mail/templates/default/acl.xet | 78 ++++++++++++++++++++++++ 4 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 mail/inc/class.mail_acl.inc.php create mode 100755 mail/templates/default/acl.xet diff --git a/mail/inc/class.mail_acl.inc.php b/mail/inc/class.mail_acl.inc.php new file mode 100644 index 0000000000..bdea30bf41 --- /dev/null +++ b/mail/inc/class.mail_acl.inc.php @@ -0,0 +1,102 @@ + + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version + */ + +class mail_acl +{ + /** + * Methods callable via menuaction + * + * @var array + */ + var $public_functions = array( + 'edit' => True, + ); + + /** + * instance of mail_bo + * + * @var mail_bo + */ + var $mail_bo; + + /** + * + * @var mail_account + */ + var $current_account; + /** + * Constructor + * + * + */ + function __construct() + { + $this->mail_bo = mail_bo::getInstance(false, (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']); + $this->current_account = $this->mail_bo->icServer->acc_imap_username; + } + + /** + * Edit folder ACLs for account(s) + * + * @param string $msg + * @param array $content + */ + function edit(array $content=null ,$msg='') + { + if (!is_array($content)) + { + $mailbox = $_GET['mailbox']; + if (!empty($mailbox)) + { + $acl = $this->retrive_acl($mailbox, $msg); + + } + } + + $tmpl = new etemplate_new('mail.acl'); + $content = array(); + $tmpl->exec('mail.mail_ui.edit_acl', $content, $sel_options, $readonlys, array(),2); + } + + /** + * Update Folder ACL rights + * + */ + function update_acl ($mailbox, $ident,$options, &$msg) + { + + } + + /** + * Retrive Folder ACL rights + * + */ + function retrive_acl ($mailbox, &$msg) + { + if ($acl = $this->mail_bo->icServer->getACL($mailbox)) + { + if (is_array($acl)) + { + $msg = lang('ACL rights retrived successfully!'); + } + else + { + $msg = lang('ACL rights retrive failed, seems there are no rights set!'); + } + } + else + { + $msg = lang('Get ACL rights failed from IMAP server!'); + error_log(__METHOD__. "(" . $acl . ")" ); + } + } +} \ No newline at end of file diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 215698b806..e5f755a92a 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -288,7 +288,13 @@ class mail_ui $etpl = new etemplate_new('mail.index'); // Set tree actions - $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', array( + $tree_actions = array( + 'all_folders' => array( + 'caption' => 'Show all folders', + 'checkbox' => true, + 'onExecute' => 'javaScript:app.mail.all_folders', + 'group' => $group++, + ), 'drop_move_mail' => array( 'type' => 'drop', 'acceptedTypes' => 'mail', @@ -327,8 +333,16 @@ class mail_ui 'onExecute' => 'javaScript:app.mail.edit_account', //'enableId' => '^\\d+$', // only show action on account itself ), - )); -//error_log(__METHOD__.__LINE__.array2string($content)); + 'edit_acl' => array( + 'caption' => 'Edit folder ACL', + 'icon' => 'configure', + 'onExecute' => 'javaScript:app.mail.edit_acl', + ), + ); + + if (!$this->mail_bo->icServer->queryCapability('ACL')) unset($tree_actions['edit_acl']); + $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions); + if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']='quick'; $readonlys = $preserv = $sel_options; return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv); diff --git a/mail/js/app.js b/mail/js/app.js index 3c2592ab15..91307f13a6 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1949,6 +1949,18 @@ app.classes.mail = AppJS.extend( request.sendRequest(); }, + /** + * Edit a folder acl for account(s) + * + * @param _action + * @param _senders - the representation of the tree leaf to be manipulated + */ + edit_acl: function(_action, _senders) + { + var folder_id = _senders[0].id.split('::INBOX/'); + this.egw.open_link('mail.mail_acl.edit&mailbox='+folder_id[1], '_blank', '640x480'); + }, + /** * Edit a mail account * diff --git a/mail/templates/default/acl.xet b/mail/templates/default/acl.xet new file mode 100755 index 0000000000..1529ea8386 --- /dev/null +++ b/mail/templates/default/acl.xet @@ -0,0 +1,78 @@ + + + + + \ No newline at end of file