From 2de68f744c160d514ac4bc179723d7e7e3f2b2b7 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 3 Oct 2019 08:55:33 +0200 Subject: [PATCH 1/4] Fix regression in handling of post profiles in email --- CRM/Event/BAO/Event.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 09f06ac9cc7a..16d3632aa5e9 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1143,6 +1143,10 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F // @todo - the goal is that all params available to the message template are explicitly defined here rather than // 'in a smattering of places'. Note that leakage can happen between mailings when not explicitly defined. + $customPostTitles = empty($profilePost[1]) ? NULL : []; + foreach ($postProfileID as $id) { + $customPostTitles[$id] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $postProfileID); + } $tplParams = array_merge($values, $participantParams, [ 'email' => $email, 'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']), @@ -1152,7 +1156,7 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F 'customPre' => $profilePre[0], 'customPre_grouptitle' => empty($profilePre[1]) ? NULL : [CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $preProfileID)], 'customPost' => $profilePost[0], - 'customPost_grouptitle' => empty($profilePost[1]) ? NULL : [CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $postProfileID)], + 'customPost_grouptitle' => $customPostTitles, 'participantID' => $participantId, 'conference_sessions' => $sessions, 'credit_card_number' => CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $participantParams)), From d0882c75fbcfa4b6091aac2f70e56dd2d62fcca4 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 3 Oct 2019 08:19:21 +0100 Subject: [PATCH 2/4] Event::sendEmail() - Fix profile ID for realz this time --- CRM/Event/BAO/Event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 16d3632aa5e9..8f7ab1c1857b 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1145,7 +1145,7 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F // 'in a smattering of places'. Note that leakage can happen between mailings when not explicitly defined. $customPostTitles = empty($profilePost[1]) ? NULL : []; foreach ($postProfileID as $id) { - $customPostTitles[$id] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $postProfileID); + $customPostTitles[$id] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $id); } $tplParams = array_merge($values, $participantParams, [ 'email' => $email, From 1fe8b46755d123b01b4fe545758d42f2e0440883 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 3 Oct 2019 09:30:52 +0100 Subject: [PATCH 3/4] Event::sendEmail() - Fix displaying of heading. Use same key. The message templates use this loop: ``` {foreach from=$customPost item=customPos key=j} {$customPost_grouptitle.$j} ``` Note that the keys in `$customPost` and `$customPost_grouptitle` need to match. --- CRM/Event/BAO/Event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 8f7ab1c1857b..4765a29b1c02 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1144,8 +1144,8 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F // @todo - the goal is that all params available to the message template are explicitly defined here rather than // 'in a smattering of places'. Note that leakage can happen between mailings when not explicitly defined. $customPostTitles = empty($profilePost[1]) ? NULL : []; - foreach ($postProfileID as $id) { - $customPostTitles[$id] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $id); + foreach ($postProfileID as $offset => $id) { + $customPostTitles[$offset] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $id); } $tplParams = array_merge($values, $participantParams, [ 'email' => $email, From 91a4b4c67e1b11add121cf85cdbfd8a1c84db5d9 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 3 Oct 2019 11:28:43 +0100 Subject: [PATCH 4/4] Event::sendMail() - Don't assume $postProfileID has content The unit-test suite includes cases in which the value is actually NULL. --- CRM/Event/BAO/Event.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 4765a29b1c02..ec9d0e6b485d 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -1143,9 +1143,14 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F // @todo - the goal is that all params available to the message template are explicitly defined here rather than // 'in a smattering of places'. Note that leakage can happen between mailings when not explicitly defined. - $customPostTitles = empty($profilePost[1]) ? NULL : []; - foreach ($postProfileID as $offset => $id) { - $customPostTitles[$offset] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $id); + if ($postProfileID) { + $customPostTitles = empty($profilePost[1]) ? NULL : []; + foreach ($postProfileID as $offset => $id) { + $customPostTitles[$offset] = CRM_Core_BAO_UFGroup::getFrontEndTitle((int) $id); + } + } + else { + $customPostTitles = NULL; } $tplParams = array_merge($values, $participantParams, [ 'email' => $email,