From ca5f0b933840f74db4103fb43825a1a3d37920d0 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 29 Aug 2021 17:02:10 +1200 Subject: [PATCH] REF Copy preProcessFromAddress back into the pdf function This is really hard to unravel without splitting it between classes - mostly because it does stuff to do with setting properties on the form that are not even relevant to all forms. This is a divide & conquer case to cleaning up the function from the deprecated class Note that I removed the bounce on no-email. It felt like we would still want to be able to download pdfs if the logged in user had no email. The bounce param seems to have been added as an after thought - presumably to block the bounce in a flow where they realised it made no sense --- CRM/Contact/Form/Task/PDFLetterCommon.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Form/Task/PDFLetterCommon.php b/CRM/Contact/Form/Task/PDFLetterCommon.php index 9bfcfa7e77..f87eb267d0 100644 --- a/CRM/Contact/Form/Task/PDFLetterCommon.php +++ b/CRM/Contact/Form/Task/PDFLetterCommon.php @@ -46,7 +46,26 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter // @todo ensure this is already set. $form->_single = FALSE; } - CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($form); + $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(); + + $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); $messageText = []; $messageSubject = []; $dao = new CRM_Core_BAO_MessageTemplate(); -- 2.25.1