From 61e6b4b1555473ae32070e83e163aa986fe92bb5 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 22 Sep 2023 07:03:12 +1200 Subject: [PATCH] Fix a couple more places to use tokens I could make no sense of the whole default role ID thing I removed it --- CRM/Core/EntityTokens.php | 2 +- CRM/Event/WorkflowMessage/EventExamples.php | 3 ++- .../message_templates/event_online_receipt_text.tpl | 9 ++------- .../message_templates/event_offline_receipt_html.tpl | 4 ++-- .../message_templates/event_offline_receipt_text.tpl | 4 ++-- .../message_templates/event_online_receipt_html.tpl | 8 ++++---- .../message_templates/event_online_receipt_text.tpl | 4 ++-- 7 files changed, 15 insertions(+), 19 deletions(-) diff --git a/CRM/Core/EntityTokens.php b/CRM/Core/EntityTokens.php index 070b903b01..850f5848de 100644 --- a/CRM/Core/EntityTokens.php +++ b/CRM/Core/EntityTokens.php @@ -99,7 +99,7 @@ class CRM_Core_EntityTokens extends AbstractTokenSubscriber { $fieldValue = $this->getFieldValue($row, $field); if (is_array($fieldValue)) { // eg. role_id for participant would be an array here. - $fieldValue = implode(',', $fieldValue); + $fieldValue = implode(', ', $fieldValue); } if ($this->isPseudoField($field)) { diff --git a/CRM/Event/WorkflowMessage/EventExamples.php b/CRM/Event/WorkflowMessage/EventExamples.php index dbbdb6f589..b5a505868c 100644 --- a/CRM/Event/WorkflowMessage/EventExamples.php +++ b/CRM/Event/WorkflowMessage/EventExamples.php @@ -115,7 +115,8 @@ class CRM_Event_WorkflowMessage_EventExamples extends WorkflowMessageExample { $messageTemplate->setContribution($contribution); $messageTemplate->setOrder($mockOrder); $messageTemplate->setParticipantContacts($participantContacts); - $messageTemplate->setParticipant(['id' => $isPrimary ? $primaryParticipantID : $otherParticipantID, 'registered_by_id' => $isPrimary ? NULL : $primaryParticipantID, 'register_date' => date('Y-m-d')]); + $roleID = Event::get(FALSE)->addWhere('id', '=', $example['event_id'])->addSelect('default_role_id')->execute()->first()['default_role_id']; + $messageTemplate->setParticipant(['id' => $isPrimary ? $primaryParticipantID : $otherParticipantID, 'registered_by_id' => $isPrimary ? NULL : $primaryParticipantID, 'register_date' => date('Y-m-d'), 'role_id' => $roleID]); } /** diff --git a/tests/templates/message_templates/event_online_receipt_text.tpl b/tests/templates/message_templates/event_online_receipt_text.tpl index b66a190e08..0ef11134d8 100644 --- a/tests/templates/message_templates/event_online_receipt_text.tpl +++ b/tests/templates/message_templates/event_online_receipt_text.tpl @@ -29,14 +29,9 @@ pay_later_receipt:::{$pay_later_receipt} event.event_title:::{$event.event_title} event.event_start_date:::{$event.event_start_date|crmDate:"%A"} event.event_end_date:::{event.end_date|crmDate:"%Y%m%d"} -{if !empty($event.is_monetary)} -event.is_monetary:::{$event.is_monetary} -{/if} +event.is_monetary:::{event.is_monetary|boolean} event.fee_label:::{event.fee_label} -{if !empty($event.participant_role)} - event.participant_role::{$event.participant_role} - defaultRole:::{$defaultRole} -{/if} +event.participant_role::{event.participant_role_id:label} {if !empty($isShowLocation)} isShowLocation:::{$isShowLocation} location.address.1.display:::{$location.address.1.display} diff --git a/xml/templates/message_templates/event_offline_receipt_html.tpl b/xml/templates/message_templates/event_offline_receipt_html.tpl index 75654e606f..fecd700118 100644 --- a/xml/templates/message_templates/event_offline_receipt_html.tpl +++ b/xml/templates/message_templates/event_offline_receipt_html.tpl @@ -53,13 +53,13 @@ - {if !empty($event.participant_role) and $event.participant_role neq 'Attendee' and !empty($defaultRole)} + {if "{participant.role_id:label}" neq 'Attendee'} {ts}Participant Role{/ts} - {$event.participant_role} + {participant.role_id:label} {/if} diff --git a/xml/templates/message_templates/event_offline_receipt_text.tpl b/xml/templates/message_templates/event_offline_receipt_text.tpl index c110c5f1b3..03de2f48bd 100644 --- a/xml/templates/message_templates/event_offline_receipt_text.tpl +++ b/xml/templates/message_templates/event_offline_receipt_text.tpl @@ -40,8 +40,8 @@ {event.title} {event.start_date|crmDate}{if {event.end_date|boolean}}-{if '{event.end_date|crmDate:"%Y%m%d"}' === '{event.start_date|crmDate:"%Y%m%d"}'}{event.end_date|crmDate:"Time"}{else}{event.end_date}{/if}{/if} -{if !empty($event.participant_role) and $event.participant_role neq 'Attendee' and empty($defaultRole)} -{ts}Participant Role{/ts}: {$event.participant_role} +{if "{participant.role_id:label}" neq 'Attendee'} +{ts}Participant Role{/ts}: {participant.role_id:label} {/if} {if !empty($isShowLocation)} diff --git a/xml/templates/message_templates/event_online_receipt_html.tpl b/xml/templates/message_templates/event_online_receipt_html.tpl index 58c49181f6..fa44cb0588 100644 --- a/xml/templates/message_templates/event_online_receipt_html.tpl +++ b/xml/templates/message_templates/event_online_receipt_html.tpl @@ -66,13 +66,13 @@ - {if !empty($event.participant_role) and $event.participant_role neq 'Attendee' and !empty($defaultRole)} + {if "{participant.role_id:label}" neq 'Attendee'} {ts}Participant Role{/ts} - {$event.participant_role} + {participant.role_id:label} {/if} @@ -317,13 +317,13 @@ {/if} - {if $register_date} + {if {participant.register_date|boolean}} {ts}Registration Date{/ts} - {$register_date|crmDate} + {participant.register_date} {/if} diff --git a/xml/templates/message_templates/event_online_receipt_text.tpl b/xml/templates/message_templates/event_online_receipt_text.tpl index 19b9c98967..c17e7f971d 100644 --- a/xml/templates/message_templates/event_online_receipt_text.tpl +++ b/xml/templates/message_templates/event_online_receipt_text.tpl @@ -50,8 +50,8 @@ {event.title} {event.start_date|crmDate:"%A"} {event.start_date|crmDate}{if {event.end_date|boolean}}-{if $event.event_end_date|crmDate:"%Y%m%d" == $event.event_start_date|crmDate:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate:"%A"} {$event.event_end_date|crmDate}{/if}{/if} -{if !empty($event.participant_role) and $event.participant_role neq 'Attendee' and !empty($defaultRole)} -{ts}Participant Role{/ts}: {$event.participant_role} +{if "{participant.role_id:label}" neq 'Attendee'} +{ts}Participant Role{/ts}: {participant.role_id:label} {/if} {if !empty($isShowLocation)} -- 2.25.1