From 7a305bdf95d89da739beb6d29034e7ef5c5e5da9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 22 May 2014 07:36:02 +0000 Subject: [PATCH] enable/disable Sieve and ACL actions on tree account-specific, also added a couple more icons to tree icons --- mail/inc/class.mail_ui.inc.php | 64 ++++++++++++++++++++-------------- mail/js/app.js | 37 ++++++++++++++++++++ 2 files changed, 75 insertions(+), 26 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 91e6c82cdf..6094831210 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -617,25 +617,30 @@ class mail_ui 'sieve' => array( 'caption' => 'Mail filter', 'onExecute' => 'javaScript:app.mail.edit_sieve', - 'group' => $group++, + 'group' => ++$group, // new group for filter + 'enabled' => 'javaScript:app.mail.sieve_enabled', + 'icon' => 'etemplate/fav_filter', // funnel ), 'vacation' => array( 'caption' => 'Vacation notice', - 'icon' => 'configure', + 'icon' => 'mail/navbar', // mail as in admin 'onExecute' => 'javaScript:app.mail.edit_vacation', - 'group' => $group++, + 'group' => $group, + 'enabled' => 'javaScript:app.mail.sieve_enabled', ), 'edit_account' => array( 'caption' => 'Edit account ...', 'icon' => 'configure', 'onExecute' => 'javaScript:app.mail.edit_account', //'enableId' => '^\\d+$', // only show action on account itself + 'group' => ++$group, // new groups for account & acl ), 'edit_acl' => array( 'caption' => 'Edit folder ACL ...', - 'icon' => 'blocks', - 'enabled' => 'javaScript:app.mail.mail_CheckFolderNoSelect', + 'icon' => 'lock', + 'enabled' => 'javaScript:app.mail.acl_enabled', 'onExecute' => 'javaScript:app.mail.edit_acl', + 'group' => $group, ), ); // the preference prefaskformove controls actually if there is a popup on target or not @@ -663,36 +668,39 @@ class mail_ui unset($tree_actions['subscribe']); unset($tree_actions['unsubscribe']); } - $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; - if($deleteOptions == 'move_to_trash') + ++$group; // put delete in own group + switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) { - $tree_actions['empty_trash'] = array( - 'caption' => 'empty trash', - 'icon' => 'dhtmlxtree/MailFolderTrash', - 'onExecute' => 'javaScript:app.mail.mail_emptyTrash', - //'enableId' => '^\\d+$', // only show action on account itself - ); - } - if($preferences['deleteOptions'] == 'mark_as_deleted') - { - $tree_actions['compress_folder'] = array( - 'caption' => 'compress folder', - 'icon' => 'dhtmlxtree/MailFolderTrash', - 'onExecute' => 'javaScript:app.mail.mail_compressFolder', - //'enableId' => '^\\d+$', // only show action on account itself - ); + case 'move_to_trash': + $tree_actions['empty_trash'] = array( + 'caption' => 'empty trash', + 'icon' => 'dhtmlxtree/MailFolderTrash', + 'onExecute' => 'javaScript:app.mail.mail_emptyTrash', + //'enableId' => '^\\d+$', // only show action on account itself + 'group' => $group, + ); + break; + case 'mark_as_deleted': + $tree_actions['compress_folder'] = array( + 'caption' => 'compress folder', + 'icon' => 'dhtmlxtree/MailFolderTrash', + 'onExecute' => 'javaScript:app.mail.mail_compressFolder', + //'enableId' => '^\\d+$', // only show action on account itself + 'group' => $group, + ); + break; } // enforce global (group-specific) ACL - if (!$this->mail_bo->icServer->queryCapability('ACL') || !mail_hooks::access('aclmanagement')) + if (!mail_hooks::access('aclmanagement')) { unset($tree_actions['edit_acl']); } - if (!$this->mail_bo->icServer->acc_sieve_enabled || !mail_hooks::access('editfilterrules')) + if (!mail_hooks::access('editfilterrules')) { unset($tree_actions['sieve']); } - if (!$this->mail_bo->icServer->acc_sieve_enabled || !mail_hooks::access('absentnotice')) + if (!mail_hooks::access('absentnotice')) { unset($tree_actions['vacation']); } @@ -885,7 +893,9 @@ class mail_ui 'im2' => 'thunderbird.png', 'path'=> array($acc_id), 'child'=> (int)($acc_id != $_profileID || $folderObjects), // dynamic loading on unfold - 'parent' => '' + 'parent' => '', + // mark on account if Sieve is enabled + 'data' => array('sieve' => $accountObj->acc_sieve_enabled), ); $this->setOutStructure($oA, $out, self::$delimiter); @@ -946,6 +956,8 @@ class mail_ui if ($path=='INBOX') { $oA['im0'] = $oA['im1']= $oA['im2'] = "kfm_home.png"; + // mark on inbox if ACL is supported + $oA['data'] = array('acl' => $this->mail_bo->icServer->queryCapability('ACL')); } elseif (in_array($obj->shortFolderName,mail_bo::$autoFolders)) { diff --git a/mail/js/app.js b/mail/js/app.js index 7244299095..a19cdd69a8 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1003,6 +1003,43 @@ app.classes.mail = AppJS.extend( return true; }, + /** + * Check if Sieve is enabled on that account + * + * Sieve enabled is stored as data { acl: true/false } on account node. + * + * @param {object} _action + * @param {object} _senders the representation of the tree leaf to be manipulated + * @param {object} _currentNode + */ + sieve_enabled: function(_action,_senders,_currentNode) + { + var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]'); + var acc_id = _senders[0].id.split('::')[0]; + var node = ftree ? ftree.getNode(acc_id) : null; + + return node && node.data && node.data.sieve; + }, + + /** + * Check if ACL is enabled on that account + * + * ACL enabled is stored as data { acl: true/false } on INBOX node. + * We also need to check if folder is marked as no-select! + * + * @param {object} _action + * @param {object} _senders the representation of the tree leaf to be manipulated + * @param {object} _currentNode + */ + acl_enabled: function(_action,_senders,_currentNode) + { + var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]'); + var inbox = _senders[0].id.split('::')[0]+'::INBOX'; + var node = ftree ? ftree.getNode(inbox) : null; + + return node && node.data.acl && this.mail_CheckFolderNoSelect(_action,_senders,_currentNode); + }, + /** * mail_setFolderStatus, function to set the status for the visible folders *