Fix a couple more places to use tokens
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 21 Sep 2023 19:03:12 +0000 (07:03 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 24 Sep 2023 07:26:08 +0000 (20:26 +1300)
I could make no sense of the whole default role ID thing

I removed it

CRM/Core/EntityTokens.php
CRM/Event/WorkflowMessage/EventExamples.php
tests/templates/message_templates/event_online_receipt_text.tpl
xml/templates/message_templates/event_offline_receipt_html.tpl
xml/templates/message_templates/event_offline_receipt_text.tpl
xml/templates/message_templates/event_online_receipt_html.tpl
xml/templates/message_templates/event_online_receipt_text.tpl

index 070b903b0183068c5eaa77d0380652ae6383c896..850f5848debcc9a380126288fac147ac96b6631e 100644 (file)
@@ -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)) {
index dbbdb6f589c38702a73d54d1b7507c1c2256d680..b5a505868c1138ad597ccfa62abeba88926a3474 100644 (file)
@@ -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]);
   }
 
   /**
index b66a190e0847c00a9729e71274b6160770eede46..0ef11134d829b81277a9ea12a2b9b195548ef77c 100644 (file)
@@ -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}
index 75654e606fa8851b6af65422422fb83153e066f7..fecd700118b1ae1e2fec0b6cc5e46be62be653ce 100644 (file)
       </td>
      </tr>
 
-     {if !empty($event.participant_role) and $event.participant_role neq 'Attendee' and !empty($defaultRole)}
+     {if "{participant.role_id:label}" neq 'Attendee'}
       <tr>
        <td {$labelStyle}>
         {ts}Participant Role{/ts}
        </td>
        <td {$valueStyle}>
-        {$event.participant_role}
+         {participant.role_id:label}
        </td>
       </tr>
      {/if}
index c110c5f1b371081fb6524bcda6ef801bd498a55b..03de2f48bd7cff3551e59ecb90a34fba7b175c9b 100644 (file)
@@ -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)}
index 58c49181f6fb668a1d5c7cb2246bcd206f00481b..fa44cb0588c144f73cd60f8973468a7d128369d4 100644 (file)
           </td>
         </tr>
 
-        {if !empty($event.participant_role) and $event.participant_role neq 'Attendee' and !empty($defaultRole)}
+        {if "{participant.role_id:label}" neq 'Attendee'}
           <tr>
             <td {$labelStyle}>
               {ts}Participant Role{/ts}
             </td>
             <td {$valueStyle}>
-              {$event.participant_role}
+              {participant.role_id:label}
             </td>
           </tr>
         {/if}
                 </tr>
               {/if}
 
-              {if $register_date}
+              {if {participant.register_date|boolean}}
                 <tr>
                   <td {$labelStyle}>
                     {ts}Registration Date{/ts}
                   </td>
                   <td {$valueStyle}>
-                    {$register_date|crmDate}
+                    {participant.register_date}
                   </td>
                 </tr>
               {/if}
index 19b9c989671f71583d97d992ba3ee843bf514ea8..c17e7f971d3ed25c0fb99c078b94f7bcf74bfedd 100644 (file)
@@ -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)}