Event tokens clean up
authorlarssandergreen <lars@wildsight.ca>
Thu, 7 Sep 2023 16:09:42 +0000 (10:09 -0600)
committerlarssandergreen <lars@wildsight.ca>
Thu, 7 Sep 2023 16:09:42 +0000 (10:09 -0600)
CRM/Core/EntityTokens.php
CRM/Event/Tokens.php
Civi/Token/TokenRow.php
tests/phpunit/CRM/Utils/TokenConsistencyTest.php
xml/templates/message_templates/event_online_receipt_html.tpl

index 908937cea0c4167623529aecb06ea12e53a042b3..070b903b0183068c5eaa77d0380652ae6383c896 100644 (file)
@@ -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';
   }
 
index 009bcfaaaad6a8e5197f12a9edabf7e40ec24e80..46869f4a11ef2e8d32f53b5550c6262a7d29de8a 100644 (file)
@@ -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])) {
index dbe2a5ad8e686cda5dbb6bbed281a78ae36b313c..0379febff25852deb232ff364efc611e5970b21b 100644 (file)
@@ -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");
               }
             }
           }
index 36e94388a9f90d505d83fff6e755a0f3107043c8..b7890f5003ab83a6b74191c0bebbd43164e0f367 100644 (file)
@@ -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<br />
-Emerald City, Maine 90210
+Emerald City, Maine 90210<br />
 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.
index 4b35b1487560fd30592ad3253d9f9f51145defb4..488dd8e506490e08ef69a387f3addfcedcd8c9e2 100644 (file)
@@ -48,7 +48,7 @@
       <p>{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}</p>
      {/if}
     {elseif !empty($is_pay_later) && empty($isAmountzero) && empty($isAdditionalParticipant)}
-     <p>{if {event.pay_later_receipt|boolean}}{event.pay_later_receipt}{/if}</p> {* FIXME: this might be text rather than HTML *}
+     <p>{if {event.pay_later_receipt|boolean}}{event.pay_later_receipt}{/if}</p>
     {/if}
 
    </td>