Use delegator's name in delegatee identities derived from delegator
Set 'Sender:' header in mail sent on behalf of delegator
This commit is contained in:
parent
acd574b650
commit
5780b841cc
2 changed files with 57 additions and 2 deletions
|
@ -46,6 +46,9 @@ class kolab_delegation extends rcube_plugin
|
|||
// on-check-recent delegation support
|
||||
$this->add_hook('check_recent', array($this, 'check_recent_hook'));
|
||||
|
||||
// on-message-send delegation support
|
||||
$this->add_hook('message_before_send', array($this, 'message_before_send'));
|
||||
|
||||
// delegation support in Calendar plugin
|
||||
$this->add_hook('message_load', array($this, 'message_load'));
|
||||
$this->add_hook('calendar_user_emails', array($this, 'calendar_user_emails'));
|
||||
|
@ -138,6 +141,22 @@ class kolab_delegation extends rcube_plugin
|
|||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mail send action
|
||||
*/
|
||||
public function message_before_send($args)
|
||||
{
|
||||
// Checking headers of email being send, we'll add
|
||||
// Sender: header if mail is send on behalf of someone else
|
||||
|
||||
if (!empty($_SESSION['delegators'])) {
|
||||
$engine = $this->engine();
|
||||
$engine->delegator_delivery_filter($args);
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* E-mail message loading action
|
||||
*/
|
||||
|
|
|
@ -470,6 +470,7 @@ class kolab_delegation_engine
|
|||
}
|
||||
}
|
||||
|
||||
$realname = $name;
|
||||
if ($uid && $name) {
|
||||
$name .= ' (' . $uid . ')';
|
||||
}
|
||||
|
@ -486,6 +487,7 @@ class kolab_delegation_engine
|
|||
return array(
|
||||
'uid' => $uid,
|
||||
'name' => $name,
|
||||
'realname' => $realname,
|
||||
'imap_uid' => $imap_uid,
|
||||
'email' => $email,
|
||||
'ID' => $data['ID'],
|
||||
|
@ -605,9 +607,9 @@ class kolab_delegation_engine
|
|||
|
||||
// create identities for delegator emails
|
||||
foreach ($email_arr as $email) {
|
||||
// @TODO: "Delegatorname" or "Username on behalf of Delegatorname"?
|
||||
$default['name'] = $delegator['realname'];
|
||||
$default['email'] = $email;
|
||||
// @TODO: "Username" or "Delegatorname" or "Username on behalf of Delegatorname"
|
||||
//$default['name'] = $delegator['email'];
|
||||
$this->rc->user->insert_identity($default);
|
||||
}
|
||||
|
||||
|
@ -808,6 +810,40 @@ class kolab_delegation_engine
|
|||
$args['abort'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters/updates message headers according to delegator context
|
||||
*
|
||||
* @param array $args Reference to plugin hook arguments
|
||||
*/
|
||||
public function delegator_delivery_filter(&$args)
|
||||
{
|
||||
// no context, but message still can be send on behalf of...
|
||||
if (!empty($_SESSION['delegators'])) {
|
||||
$message = $args['message'];
|
||||
$headers = $message->headers();
|
||||
|
||||
// get email address from From: header
|
||||
$from = rcube_mime::decode_address_list($headers['From']);
|
||||
$from = array_shift($from);
|
||||
$from = $from['mailto'];
|
||||
|
||||
foreach ($_SESSION['delegators'] as $uid => $addresses) {
|
||||
if (in_array($from, $addresses)) {
|
||||
$context = $uid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// add Sender: header with current user default identity
|
||||
if ($context) {
|
||||
$identity = $this->rc->user->get_identity();
|
||||
$sender = format_email_recipient($identity['email'], $identity['name']);
|
||||
|
||||
$message->headers(array('Sender' => $sender), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two ACLs (according to supported rights)
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue