From cc4b5ba9fad4ce9d48ba25becf9bd90f489b5ace Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Thu, 7 Sep 2023 10:09:42 -0600 Subject: [PATCH] Event tokens clean up --- CRM/Core/EntityTokens.php | 1 - CRM/Event/Tokens.php | 9 --------- Civi/Token/TokenRow.php | 2 +- tests/phpunit/CRM/Utils/TokenConsistencyTest.php | 2 +- .../message_templates/event_online_receipt_html.tpl | 2 +- 5 files changed, 3 insertions(+), 13 deletions(-) diff --git a/CRM/Core/EntityTokens.php b/CRM/Core/EntityTokens.php index 908937cea0..070b903b01 100644 --- a/CRM/Core/EntityTokens.php +++ b/CRM/Core/EntityTokens.php @@ -152,7 +152,6 @@ class CRM_Core_EntityTokens extends AbstractTokenSubscriber { * @return bool */ public function isHTMLTextField(string $fieldName): bool { - $metadata = $this->getMetadataForField($fieldName); return ($this->getMetadataForField($fieldName)['input_type'] ?? NULL) === 'RichTextEditor'; } diff --git a/CRM/Event/Tokens.php b/CRM/Event/Tokens.php index 009bcfaaaa..46869f4a11 100644 --- a/CRM/Event/Tokens.php +++ b/CRM/Event/Tokens.php @@ -191,20 +191,15 @@ class CRM_Event_Tokens extends CRM_Core_EntityTokens { 'loc_block_id.phone_2_id.phone_type_id', 'loc_block_id.phone_2_id.phone_ext', 'loc_block_id.phone_2_id.phone_type_id:label', - 'confirm_email_text', - 'is_show_location', 'is_show_location:label', - 'is_public', 'is_public:label', 'is_share', 'is_share:label', 'requires_approval', 'requires_approval:label', 'is_monetary:label', - 'event_type_id:label', 'event_type_id:name', 'pay_later_text', - 'pay_later_receipt', 'fee_label', 'custom.*', ], $this->getExposedFields())) @@ -215,16 +210,12 @@ class CRM_Event_Tokens extends CRM_Core_EntityTokens { 'state_province' => $event['loc_block_id.address_id.state_province_id:label'], 'postal_code' => $event['loc_block_id.address_id.postal_code'], ]); - $tokens['location']['text/html'] = nl2br(trim($tokens['location']['text/plain'])); $tokens['info_url']['text/html'] = \CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $eventID, TRUE, NULL, FALSE, TRUE); $tokens['registration_url']['text/html'] = \CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $eventID, TRUE, NULL, FALSE, TRUE); $tokens['start_date']['text/html'] = !empty($event['start_date']) ? new DateTime($event['start_date']) : ''; $tokens['end_date']['text/html'] = !empty($event['end_date']) ? new DateTime($event['end_date']) : ''; $tokens['contact_email']['text/html'] = $event['loc_block_id.email_id.email']; $tokens['contact_phone']['text/html'] = $event['loc_block_id.phone_id.phone']; - // We use text/plain for fields which should be converted to html when used in html content. - $tokens['confirm_email_text']['text/plain'] = $event['confirm_email_text']; - $tokens['pay_later_text']['text/plain'] = $event['pay_later_text']; foreach ($this->getTokenMetadata() as $fieldName => $fieldSpec) { if (!isset($tokens[$fieldName])) { diff --git a/Civi/Token/TokenRow.php b/Civi/Token/TokenRow.php index dbe2a5ad8e..0379febff2 100644 --- a/Civi/Token/TokenRow.php +++ b/Civi/Token/TokenRow.php @@ -286,7 +286,7 @@ class TokenRow { $htmlTokens[$entity][$field] = \CRM_Utils_String::purifyHTML($value); } else { - $htmlTokens[$entity][$field] = is_object($value) ? $value : rtrim(nl2br(htmlentities($value, ENT_QUOTES))); + $htmlTokens[$entity][$field] = is_object($value) ? $value : rtrim(nl2br(htmlentities($value, ENT_QUOTES)), "\r\n"); } } } diff --git a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php index 36e94388a9..b7890f5003 100644 --- a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php +++ b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php @@ -715,7 +715,7 @@ event.loc_block_id.email_id.email :event@example.com event.loc_block_id.phone_id.phone :456 789 event.description :event description event.location :15 Walton St
-Emerald City, Maine 90210 +Emerald City, Maine 90210
event.info_url :' . CRM_Utils_System::url('civicrm/event/info', NULL, TRUE) . '&reset=1&id=1 event.registration_url :' . CRM_Utils_System::url('civicrm/event/register', NULL, TRUE) . '&reset=1&id=1 event.pay_later_receipt :Please transfer funds to our bank account. diff --git a/xml/templates/message_templates/event_online_receipt_html.tpl b/xml/templates/message_templates/event_online_receipt_html.tpl index 4b35b14875..488dd8e506 100644 --- a/xml/templates/message_templates/event_online_receipt_html.tpl +++ b/xml/templates/message_templates/event_online_receipt_html.tpl @@ -48,7 +48,7 @@

{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}

{/if} {elseif !empty($is_pay_later) && empty($isAmountzero) && empty($isAdditionalParticipant)} -

{if {event.pay_later_receipt|boolean}}{event.pay_later_receipt}{/if}

{* FIXME: this might be text rather than HTML *} +

{if {event.pay_later_receipt|boolean}}{event.pay_later_receipt}{/if}

{/if} -- 2.25.1