fix PHP Warning array_values expects parameter 1 to be an array line 3635

This commit is contained in:
Ralf Becker 2020-12-02 09:07:09 +01:00
parent c3ae524ed6
commit e717daa467

View File

@ -3630,11 +3630,18 @@ class mail_compose
}
}
if(is_array($contacts)) {
foreach($contacts as $contact) {
$cfs = $contacts_obj->read_customfields($contact['id'], $cfs_type_email);
$cf_emails = $cfs ? (array)array_values(array_values($cfs)[0]) : array();
foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email) {
if (is_array($contacts))
{
foreach($contacts as $contact)
{
$cf_emails = [];
if ($cfs_type_email && ($cf_emails = $contacts_obj->read_customfields($contact['id'], $cfs_type_email)))
{
// cf_emails: [$contact['id'] => ['cf1'=>'email','cf2'=>'email2',...]]
$cf_emails = array_values(reset($cf_emails));
}
foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email)
{
// avoid wrong addresses, if an rfc822 encoded address is in addressbook
//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
$rfcAddr = Mail::parseAddressList($email);