diff --git a/CRM/Contact/Form/Task/EmailTrait.php b/CRM/Contact/Form/Task/EmailTrait.php index ba0e4903d307..7583ef742864 100644 --- a/CRM/Contact/Form/Task/EmailTrait.php +++ b/CRM/Contact/Form/Task/EmailTrait.php @@ -156,8 +156,12 @@ public function buildQuickForm() { ]; $to = $this->add('text', 'to', ts('To'), $emailAttributes, TRUE); $cc = $this->add('text', 'cc_id', ts('CC'), $emailAttributes); - $bcc = $this->add('text', 'bcc_id', ts('BCC'), $emailAttributes); + $this->addEntityRef('bcc_id', ts('BCC'), [ + 'entity' => 'Email', + 'multiple' => TRUE, + 'api'=> ['params' => ['on_hold' => 0, 'contact_id.do_not_email' => 0]] + ]); $setDefaults = TRUE; if (property_exists($this, '_context') && $this->_context === 'standalone') { $setDefaults = FALSE; @@ -183,13 +187,6 @@ public function buildQuickForm() { } } - if ($bcc->getValue()) { - foreach ($this->getEmails($bcc) as $value) { - if (!empty($value['contact_id'])) { - $this->_bccContactIds[] = $value['contact_id']; - } - } - } $this->_allContactIds = array_unique(array_merge($this->_contactIds, $this->_ccContactIds, $this->_bccContactIds)); $setDefaults = empty($this->_allContactIds) ? $setDefaults: TRUE; diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index c8bcb650cf88..209b77989650 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -345,4 +345,24 @@ public static function del($id) { return CRM_Contact_BAO_Contact::deleteObjectWithPrimary('Email', $id); } + /** + * Get filters for entity reference fields. + * + * @return array + */ + public static function getEntityRefFilters() { + $contactFields = CRM_Contact_BAO_Contact::getEntityRefFilters(); + foreach ($contactFields as $index => &$contactField) { + if (!empty($contactField['entity'])) { + // For now email_getlist can't parse state, country etc. + unset($contactFields[$index]); + } + elseif ($contactField['key'] !== 'contact_id') { + $contactField['entity'] = 'Contact'; + $contactField['key'] = 'contact_id.' . $contactField['key']; + } + } + return $contactFields; + } + } diff --git a/templates/CRM/Contact/Form/Task/Email.tpl b/templates/CRM/Contact/Form/Task/Email.tpl index 825dfaf8bc44..963fe6b3f651 100644 --- a/templates/CRM/Contact/Form/Task/Email.tpl +++ b/templates/CRM/Contact/Form/Task/Email.tpl @@ -130,7 +130,7 @@ CRM.$(function($) { {literal} emailSelect('#to', toContact); emailSelect('#cc_id', ccContact); - emailSelect('#bcc_id', bccContact); + //emailSelect('#bcc_id', bccContact); });