*/
public $_toContactIds = [];
- /**
- * Store only "cc" contact ids.
- * @var array
- */
- public $_ccContactIds = [];
-
- /**
- * Store only "bcc" contact ids.
- *
- * @var array
- */
- public $_bccContactIds = [];
-
/**
* Is the form being loaded from a search action.
*
* @throws \API_Exception
*/
protected function traitPreProcess() {
- CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
+ $this->preProcessFromAddress();
if ($this->isSearchContext()) {
// Currently only the contact email form is callable outside search context.
parent::preProcess();
}
}
+ /**
+ * Pre Process Form Addresses to be used in Quickform
+ *
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ */
+ protected function preProcessFromAddress(): void {
+ $form = $this;
+ $form->_emails = [];
+
+ // @TODO remove these line and to it somewhere more appropriate. Currently some classes (e.g Case
+ // are having to re-write contactIds afterwards due to this inappropriate variable setting
+ // If we don't have any contact IDs, use the logged in contact ID
+ $form->_contactIds = $form->_contactIds ?: [CRM_Core_Session::getLoggedInContactID()];
+
+ $fromEmailValues = CRM_Core_BAO_Email::getFromEmail();
+
+ if (empty($fromEmailValues)) {
+ CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address and no from addresses have been configured.'));
+ }
+
+ $form->_emails = $fromEmailValues;
+ $defaults = [];
+ $form->_fromEmails = $fromEmailValues;
+ if (is_numeric(key($form->_fromEmails))) {
+ $emailID = (int) key($form->_fromEmails);
+ $defaults = CRM_Core_BAO_Email::getEmailSignatureDefaults($emailID);
+ }
+ if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) {
+ $defaults['from_email_address'] = current(CRM_Core_BAO_Domain::getNameAndEmail(FALSE, TRUE));
+ }
+ $form->setDefaults($defaults);
+ }
+
/**
* Build the form object.
*