got mailing lists working again in mail compose using includeLists=true attribute

using "$list_name <$list_id@lists.egroupware.org>" instead of just integer ids for the list, thought et2-select-mail is NOT displaying the mailing-list icon, after a mailing-list is selected
This commit is contained in:
ralf 2022-09-12 14:50:52 +02:00
parent 02164c2cae
commit 26824323e5
4 changed files with 20 additions and 23 deletions

View File

@ -50,6 +50,11 @@ export class Et2SelectEmail extends Et2Select
*/
allowDragAndDrop: {type: Boolean},
/**
* Include mailing lists: returns them with their integer list_id
*/
includeLists: {type: Boolean},
/**
* Show the full, original value email address under all circumstances, rather than the contact name for known contacts
*/
@ -65,6 +70,7 @@ export class Et2SelectEmail extends Et2Select
this.allowFreeEntries = true;
this.editModeEnabled = true;
this.allowDragAndDrop = false;
this.includeLists = false;
this.multiple = true;
this.fullEmail = false;
this.defaultValidators.push(new IsEmail());
@ -75,7 +81,6 @@ export class Et2SelectEmail extends Et2Select
super.connectedCallback();
}
protected _bindListeners()
{
super._bindListeners();
@ -119,7 +124,7 @@ export class Et2SelectEmail extends Et2Select
*/
protected remoteQuery(search : string, options : object)
{
return this.egw().json(this.searchUrl, [search]).sendRequest().then((result) =>
return this.egw().request(this.searchUrl, [search, {includeLists: this.includeLists}]).then((result) =>
{
this.processRemoteResults(result);
});

View File

@ -25,7 +25,7 @@ export class IsEmail extends Pattern
* eg. in Safari 11.0 or node.js 4.8.3 and therefore grunt uglify!
* Server-side will fail in that case because it uses the full regexp.
*/
static EMAIL_PREG : RegExp = new RegExp(/^(([^\042',<][^,<]+|\042[^\042]+\042|\'[^\']+\'|"(?:[^"\\]|\\.)*")\s?<)?[^\x00-\x20()\xe2\x80\x8b<>@,;:\042\[\]\x80-\xff]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,}>?$/i);
static EMAIL_PREG : RegExp = /^(([^\042',<][^,<]+|\042[^\042]+\042|\'[^\']+\'|"(?:[^"\\]|\\.)*")\s?<)?[^\x00-\x20()\xe2\x80\x8b<>@,;:\042\[\]\x80-\xff]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,}>?$/i;
constructor()
{

View File

@ -106,17 +106,18 @@ class Taglist extends Etemplate\Widget
*
* Uses the mail application if available, or addressbook
*/
public static function ajax_email($search)
public static function ajax_email($search=null, array $options=null)
{
$_REQUEST['query'] = $_REQUEST['query'] ?: $search;
// If no mail app access, use link system -> addressbook
if(!$GLOBALS['egw_info']['apps']['mail'])
if(empty($GLOBALS['egw_info']['apps']['mail']))
{
$_REQUEST['app'] = 'addressbook-email';
return self::ajax_search();
}
// TODO: this should go to a BO, not a UI object
$_REQUEST['include_lists'] = $options['includeLists'] ?? false;
return mail_compose::ajax_searchAddress();
}

View File

@ -2832,31 +2832,24 @@ class mail_compose
*/
static function resolveEmailAddressList($_emailAddressList)
{
$contacts_obs = null;
static $contacts_obs = null;
$addrFromList=array();
foreach((array)$_emailAddressList as $ak => $address)
{
if(is_int($address))
if(is_numeric($address) && $address > 0 || preg_match('/ <(\\d+)@lists.egroupware.org>$/', $address, $matches))
{
if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
// List was selected, expand to addresses
unset($_emailAddressList[$ak]);
$list = $contacts_obj->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)
foreach($contacts_obj->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),
'','','',False,'AND',false,
['list' => (int)($matches[1] ?? $address)]) as $email)
{
$addrFromList[] = $email['email'] ? $email['email'] : $email['email_home'];
$addrFromList[] = $email['email'] ?: $email['email_home'];
}
}
}
if (!empty($addrFromList))
{
foreach ($addrFromList as $addr)
{
if (!empty($addr)) $_emailAddressList[]=$addr;
}
}
return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
return array_values(array_merge($_emailAddressList, $addrFromList));
}
/**
@ -3766,12 +3759,10 @@ class mail_compose
{
$type = $key > 0 ? 'manual' : 'group';
$list = array(
'id' => $key,
'name' => $list_name,
'value' => $list_name.' <'.$key.'@lists.egroupware.org>',
'label' => $list_name,
'class' => 'mailinglist ' . "{$type}_list",
'title' => lang('Mailinglist'),
'data' => $key
'icon' => Api\Image::find('api', 'email'),
);
${"${type}_lists"}[] = $list;
}