Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Copy preProcessFromAddress back into the pdf function #21306

Merged
merged 1 commit into from
Aug 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
eileenmcnaughton committed Aug 29, 2021
commit ca5f0b933840f74db4103fb43825a1a3d37920d0
21 changes: 20 additions & 1 deletion CRM/Contact/Form/Task/PDFLetterCommon.php
Original file line number Diff line number Diff line change
@@ -46,7 +46,26 @@ public static function preProcess(&$form) {
// @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();