diff --git a/mail/inc/class.mail_hooks.inc.php b/mail/inc/class.mail_hooks.inc.php index d407fc3803..a3dc855eeb 100644 --- a/mail/inc/class.mail_hooks.inc.php +++ b/mail/inc/class.mail_hooks.inc.php @@ -512,7 +512,7 @@ class mail_hooks 'xmlrpc' => False, 'admin' => False ), - 'prefpreventmanagefolders' => array( + /*'prefpreventmanagefolders' => array( 'type' => 'select', 'label' => 'Prevent managing folders', 'help' => 'Do you want to prevent the managing of folders (creation, accessrights AND subscribtion)?', @@ -571,7 +571,7 @@ class mail_hooks 'xmlrpc' => True, 'admin' => False, 'forced' => '0', - ), + ),*/ 'notavailableautofolders' => array( 'type' => 'multiselect', 'label' => 'do not auto create folders', @@ -691,15 +691,18 @@ class mail_hooks } // create account wizard - $file += array( - 'create new account' => "javascript:egw_openWindowCentered2('" . - egw::link('/index.php', array('menuaction' => 'mail.mail_wizard.add'), ''). - "','_blank',640,480,'yes')", - ); - - if ($preferences['prefcontroltestconnection'] <> 'none') $file['Test Connection'] = egw::link('/index.php','menuaction=mail.mail_ui.TestConnection&appname=mail'); - - + if (self::access('createaccount')) + { + $file += array( + 'create new account' => "javascript:egw_openWindowCentered2('" . + egw::link('/index.php', array('menuaction' => 'mail.mail_wizard.add'), ''). + "','_blank',640,480,'yes')", + ); + } + if (self::access('testconnection')) + { + $file['Test Connection'] = egw::link('/index.php','menuaction=mail.mail_ui.TestConnection&appname=mail'); + } // display them all display_sidebox($appname,$menu_title,$file); @@ -862,4 +865,45 @@ class mail_hooks egw_cache::setCache(egw_cache::INSTANCE,'email','notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']),$notified_mail_uidsCache, $expiration=60*60*24*2); return true; } + + /** + * Hook returning options for deny_* groups + * + * @param string $name function name + * @param array $arguments + * @return string html + */ + public static function __callStatic($name, $arguments) + { + if (substr($name, 0, 5) != 'deny_') + { + throw new egw_exception_wrong_parameter("No method $name!"); + } + $accountsel = new uiaccountsel(); + + return ''. + $accountsel->selection('newsettings['.$name.']', 'deny_prefs', $arguments[0][$name], 'groups', 4); + } + + /** + * Check if current user has access to a specific feature + * + * Example: if (!mail_hooks::access("managerfolders")) return; + * + * @param string $feature "createaccounts", "managefolders", "forwards", "notifications", "filters", + * "notificationformailviaemail", "editfilterrules", "absentnotice", "testconnection", "aclmanagement" + * @return boolean true if user has access, false if not + */ + public static function access($feature) + { + static $config=null; + if (!isset($config)) $config = (array)config::read('mail'); + + if (!empty($config['deny_'.$feature])) + { + $denied_groups = explode(',', $config['deny_'.$feature]); + return array_intersect($denied_groups, $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true)); + } + return true; + } } diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 205ef761d9..2f4230baba 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -410,12 +410,27 @@ class mail_ui ); } - if (!$this->mail_bo->icServer->queryCapability('ACL')) unset($tree_actions['edit_acl']); - if (!$this->mail_bo->icServer->acc_sieve_enabled) + // enforce global (group-specific) ACL + if (!$this->mail_bo->icServer->queryCapability('ACL') || !mail_hooks::access('aclmanagement')) + { + unset($tree_actions['edit_acl']); + } + if (!$this->mail_bo->icServer->acc_sieve_enabled || !mail_hooks::access('editfilterrules')) { unset($tree_actions['sieve']); + } + if (!$this->mail_bo->icServer->acc_sieve_enabled || !mail_hooks::access('absentnotice')) + { unset($tree_actions['vacation']); } + if (!mail_hooks::access('managefolders')) + { + unset($tree_actions['add']); + unset($tree_actions['move']); + unset($tree_actions['delete']); + unset($tree_actions['subscribe']); + unset($tree_actions['unsubscribe']); + } $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions); diff --git a/mail/templates/default/config.tpl b/mail/templates/default/config.tpl index 2cb0737447..b1b9e1e192 100755 --- a/mail/templates/default/config.tpl +++ b/mail/templates/default/config.tpl @@ -11,10 +11,13 @@