Add mailing lists to email tag list search results.

Added for To, CC & Bcc.
This commit is contained in:
Nathan Gray 2013-11-21 22:29:57 +00:00
parent 0853f5bd66
commit fda214670c
2 changed files with 46 additions and 4 deletions

View File

@ -1881,6 +1881,25 @@ class mail_compose
$_mailObject->AddCustomHeader('Organization: '. $_identity['ident_org']); $_mailObject->AddCustomHeader('Organization: '. $_identity['ident_org']);
} }
// Expand any mailing lists
foreach(array('to','cc','bcc') as $field)
{
foreach((array)$_formData[$field] as $field_key => $address)
{
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) {
$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) {
@ -2527,6 +2546,8 @@ class mail_compose
public static function ajax_searchAddress($_searchStringLength=2) { public static function ajax_searchAddress($_searchStringLength=2) {
//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
$_searchString = trim($_REQUEST['query']); $_searchString = trim($_REQUEST['query']);
$include_lists = (boolean)$_REQUEST['include_lists'];
if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) { if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) {
//error_log(__METHOD__.__LINE__.array2string($_searchString)); //error_log(__METHOD__.__LINE__.array2string($_searchString));
if (method_exists($GLOBALS['egw']->contacts,'search')) { if (method_exists($GLOBALS['egw']->contacts,'search')) {
@ -2597,8 +2618,29 @@ class mail_compose
if ($i > 10) break; // we check for # of results here, as we might have empty email addresses if ($i > 10) break; // we check for # of results here, as we might have empty email addresses
} }
} }
} }
// Add up to 5 matching mailing lists
if($include_lists)
{
$lists = array_filter(
$GLOBALS['egw']->contacts->get_lists(EGW_ACL_READ),
function($element) use($_searchString) {
return (stripos($element, $_searchString) >= 0);
}
);
$list_count = 0;
foreach($lists as $key => $list_name)
{
$results[] = array(
'id' => $key,
'name' => $list_name,
'label' => $list_name
);
if($list_count++ > 5) break;
}
}
//error_log(__METHOD__.__LINE__.array2string($jsArray)); //error_log(__METHOD__.__LINE__.array2string($jsArray));
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
echo json_encode($results); echo json_encode($results);

View File

@ -36,15 +36,15 @@
</hbox> </hbox>
<hbox class="mailComposeHeaders" width="99%"> <hbox class="mailComposeHeaders" width="99%">
<description value="To"/> <description value="To"/>
<taglist-email id="to" width="88%" onclick="app.mail.address_click"/> <taglist-email id="to" width="88%" onclick="app.mail.address_click" include_lists="true"/>
</hbox> </hbox>
<hbox class="mailComposeHeaders" width="99%"> <hbox class="mailComposeHeaders" width="99%">
<description value="Cc"/> <description value="Cc"/>
<taglist-email id="cc" width="88%" onclick="app.mail.address_click"/> <taglist-email id="cc" width="88%" onclick="app.mail.address_click" include_lists="true"/>
</hbox> </hbox>
<hbox class="mailComposeHeaders" width="99%"> <hbox class="mailComposeHeaders" width="99%">
<description value="Bcc"/> <description value="Bcc"/>
<taglist-email id="bcc" width="88%" onclick="app.mail.address_click"/> <taglist-email id="bcc" width="88%" onclick="app.mail.address_click" include_lists="true"/>
</hbox> </hbox>
<hbox class="mailComposeHeaders" width="99%"> <hbox class="mailComposeHeaders" width="99%">
<description value="Reply To"/> <description value="Reply To"/>