forked from extern/egroupware
* Mail: resolve distributionlists upon saving as draft, infolog, tracker and storing sent message in designated send-folder
This commit is contained in:
parent
f96772a157
commit
f9e775c549
@ -2155,20 +2155,7 @@ class mail_compose
|
|||||||
// Expand any mailing lists
|
// Expand any mailing lists
|
||||||
foreach(array('to','cc','bcc') as $field)
|
foreach(array('to','cc','bcc') as $field)
|
||||||
{
|
{
|
||||||
foreach((array)$_formData[$field] as $field_key => $address)
|
$_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
|
||||||
{
|
|
||||||
if(is_int($address))
|
|
||||||
{
|
|
||||||
// List was selected, expand to addresses
|
|
||||||
unset($_formData[$field][$field_key]);
|
|
||||||
$list = $GLOBALS['egw']->contacts->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address));
|
|
||||||
// Just add email addresses, they'll be checked below
|
|
||||||
foreach($list as $email)
|
|
||||||
{
|
|
||||||
$_formData[$field][] = $email['email'] ? $email['email'] : $email['email_home'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach((array)$_formData['to'] as $address) {
|
foreach((array)$_formData['to'] as $address) {
|
||||||
@ -2435,6 +2422,37 @@ class mail_compose
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* resolveEmailAddressList
|
||||||
|
* @param array $_emailAddressList list of emailaddresses, may contain distributionlists
|
||||||
|
* @return array return the list of emailaddresses with distributionlists resolved
|
||||||
|
*/
|
||||||
|
static function resolveEmailAddressList($_emailAddressList)
|
||||||
|
{
|
||||||
|
$addrFromList=array();
|
||||||
|
foreach((array)$_emailAddressList as $ak => $address) {
|
||||||
|
if(is_int($address))
|
||||||
|
{
|
||||||
|
// List was selected, expand to addresses
|
||||||
|
unset($_emailAddressList[$ak]);
|
||||||
|
$list = $GLOBALS['egw']->contacts->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address));
|
||||||
|
// Just add email addresses, they'll be checked below
|
||||||
|
foreach($list as $email)
|
||||||
|
{
|
||||||
|
$addrFromList[] = $email['email'] ? $email['email'] : $email['email_home'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($addrFromList))
|
||||||
|
{
|
||||||
|
foreach ($addrFromList as $addr)
|
||||||
|
{
|
||||||
|
if (!empty($addr)) $_emailAddressList[]=$addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_emailAddressList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save message as draft to specific folder
|
* Save message as draft to specific folder
|
||||||
*
|
*
|
||||||
@ -2471,7 +2489,7 @@ class mail_compose
|
|||||||
$BCCmail = '';
|
$BCCmail = '';
|
||||||
|
|
||||||
$this->createMessage($mail, $_formData, $identity);
|
$this->createMessage($mail, $_formData, $identity);
|
||||||
|
$this->sessionData['bcc'] = self::resolveEmailAddressList($this->sessionData['bcc']);
|
||||||
foreach((array)$this->sessionData['bcc'] as $address) {
|
foreach((array)$this->sessionData['bcc'] as $address) {
|
||||||
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),'');
|
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),'');
|
||||||
foreach((array)$address_array as $addressObject) {
|
foreach((array)$address_array as $addressObject) {
|
||||||
@ -2536,9 +2554,9 @@ class mail_compose
|
|||||||
$messageIsDraft = false;
|
$messageIsDraft = false;
|
||||||
|
|
||||||
$this->sessionData['mailaccount'] = $_formData['mailaccount'];
|
$this->sessionData['mailaccount'] = $_formData['mailaccount'];
|
||||||
$this->sessionData['to'] = $_formData['to'];
|
$this->sessionData['to'] = self::resolveEmailAddressList($_formData['to']);
|
||||||
$this->sessionData['cc'] = $_formData['cc'];
|
$this->sessionData['cc'] = self::resolveEmailAddressList($_formData['cc']);
|
||||||
$this->sessionData['bcc'] = $_formData['bcc'];
|
$this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']);
|
||||||
$this->sessionData['folder'] = $_formData['folder'];
|
$this->sessionData['folder'] = $_formData['folder'];
|
||||||
$this->sessionData['replyto'] = $_formData['replyto'];
|
$this->sessionData['replyto'] = $_formData['replyto'];
|
||||||
$this->sessionData['subject'] = trim($_formData['subject']);
|
$this->sessionData['subject'] = trim($_formData['subject']);
|
||||||
@ -2748,6 +2766,7 @@ class mail_compose
|
|||||||
}
|
}
|
||||||
// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
|
// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
|
||||||
if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
|
if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
|
||||||
|
//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
|
||||||
foreach((array)$this->sessionData['bcc'] as $address) {
|
foreach((array)$this->sessionData['bcc'] as $address) {
|
||||||
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),'');
|
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),'');
|
||||||
foreach((array)$address_array as $addressObject) {
|
foreach((array)$address_array as $addressObject) {
|
||||||
|
Loading…
Reference in New Issue
Block a user