first stage of allowing mail app to display further actions in emailadmin edit: Folder ACL and Vacation notice for now

This commit is contained in:
Ralf Becker 2014-09-24 10:03:00 +00:00
parent c07c550e7a
commit a0ba88621c
2 changed files with 36 additions and 28 deletions

View File

@ -18,40 +18,48 @@ class mail_hooks
/** /**
* Hook to add context menu entries to user list * Hook to add context menu entries to user list
* *
* @param array $data * @param array $data values for keys account_id and acc_id
*/ */
static function edit_user($data) static function emailadmin_edit($data)
{ {
unset($data); // not used, but required by function signature $actions = array();
$have_imap_admin_and_sieve = false; $account = emailadmin_account::read($data['acc_id'], $data['account_id']);
// list all mail accounts if (emailadmin_account::is_multiple($account) && $account['acc_imap_admin_username'] ||
foreach(emailadmin_account::search(false, 'params', null, false, 0, false) as $params) $account['acc_imap_type'] == 'managementserver_imap')
{
// check if account is valid for multiple users, has admin credentials and sieve enabled
if (emailadmin_account::is_multiple($params) &&
$params['acc_imap_admin_username'] && $params['acc_sieve_enabled'] ||
$params['acc_imap_type'] == 'managementserver_imap')
{
$have_imap_admin_and_sieve = true;
break;
}
}
$user_actions = array();
if ($have_imap_admin_and_sieve) // add action to set vacation notice for a user
{ {
translation::add_app('mail'); translation::add_app('mail');
$user_actions[] = array ( if (true /* ToDo check ACL available */ || $account['acc_imap_type'] == 'managementserver_imap')
'id' => 'mail_vacation', {
'caption' => 'Vacation notice', $actions[] = array (
'popup' => '750x420', 'id' => 'mail_acl',
'url' => 'menuaction=mail.mail_sieve.editVacation&account_id=$id', 'caption' => 'Folder ACL',
'allowMultiple' => false, 'icon' => 'lock',
); 'popup' => '750x420',
'url' => array(
'menuaction' => 'mail.mail_acl.edit',
'acc_id' => $data['acc_id'],
'account_id' => $data['account_id'],
),
);
}
if ($account['acc_sieve_enabled'] || $account['acc_imap_type'] == 'managementserver_imap')
{
$actions[] = array (
'id' => 'mail_vacation',
'caption' => 'Vacation notice',
'icon' => 'mail/navbar',
'popup' => '750x420',
'url' => array(
'menuaction' => 'mail.mail_sieve.editVacation',
'acc_id' => $data['acc_id'],
'account_id' => $data['account_id'],
),
);
}
} }
return $user_actions; return $actions;
} }
/** /**

View File

@ -36,7 +36,7 @@ $setup_info['mail']['hooks']['session_creation'] = 'mail_bo::resetConnectionErro
$setup_info['mail']['hooks']['verify_settings'] = 'mail_bo::forcePrefReload'; $setup_info['mail']['hooks']['verify_settings'] = 'mail_bo::forcePrefReload';
$setup_info['mail']['hooks']['clear_cache'] = 'mail_bo::unsetCachedObjects'; $setup_info['mail']['hooks']['clear_cache'] = 'mail_bo::unsetCachedObjects';
$setup_info['mail']['hooks']['check_notify'] = 'mail_hooks::notification_check_mailbox'; $setup_info['mail']['hooks']['check_notify'] = 'mail_hooks::notification_check_mailbox';
$setup_info['mail']['hooks']['edit_user'] = 'mail_hooks::edit_user'; $setup_info['mail']['hooks']['emailadmin_edit'] = 'mail_hooks::emailadmin_edit';
/* /*
$setup_info['mail']['hooks'][] = 'home'; $setup_info['mail']['hooks'][] = 'home';