Remove 'bad' tokens from badge tokens
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 17 Sep 2021 20:39:14 +0000 (08:39 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 18 Sep 2021 01:22:22 +0000 (13:22 +1200)
These tokens are
a) non-standard, not easily supported
b) illogical in the only current core usage context
that currently uses these tokens (event badges)
c) partially broken - currency returns nothing, note doesn't make sense

CRM/Core/SelectValues.php
CRM/Upgrade/Incremental/MessageTemplates.php
tests/phpunit/CRM/Event/Form/Task/BadgeTest.php
tests/phpunit/CRM/Utils/TokenConsistencyTest.php

index ead38069eb1200e251aca0d5e8d8b6259e49abab..46c63961c662af29a066705dae66ea3409c5ba5c 100644 (file)
@@ -598,8 +598,6 @@ class CRM_Core_SelectValues {
       '{participant.fee_label}' => 'Fee Label',
       '{participant.default_role_id}' => 'Default Role',
       '{participant.template_title}' => 'Event Template Title',
-      '{participant.currency}' => 'Currency',
-      '{participant.participant_note}' => 'Participant Note',
     ];
     $customFields = CRM_Core_BAO_CustomField::getFields('Participant');
 
index ff81310c259c777cfddf9c75e196880b364517f4..a4a0076a8f068afc191459f49377671fe2748636 100644 (file)
@@ -322,7 +322,7 @@ class CRM_Upgrade_Incremental_MessageTemplates {
   public function replaceTokenInPrintLabel(string $old, string $new): void {
     $oldToken = '{' . $old . '}';
     $newToken = '{' . $new . '}';
-    CRM_Core_DAO::executeQuery("UPDATE civicrm_action_schedule
+    CRM_Core_DAO::executeQuery("UPDATE civicrm_print_label
       SET
         data = REPLACE(data, '$oldToken', '$newToken')
     ");
index d5b68ad348cde138cce80839fe12f553725263f3..aa0c19763f87c747cd6f19697d89365487ff655e 100644 (file)
@@ -12,6 +12,11 @@ class CRM_Event_Form_Task_BadgeTest extends CiviUnitTestCase {
 
   use CRMTraits_Custom_CustomDataTrait;
 
+  public function tearDown(): void {
+    $this->quickCleanup(['civicrm_participant', 'civicrm_print_label'], TRUE);
+    parent::tearDown();
+  }
+
   /**
    * Test the the submit function on the event participant submit function.
    */
@@ -25,7 +30,7 @@ class CRM_Event_Form_Task_BadgeTest extends CiviUnitTestCase {
 
     $badgeLayout = PrintLabel::get()->addSelect('data')->execute()->first();
     $values = [
-      'data' => array_merge($badgeLayout['data'], ['token' => [], 'font_name' => [''], 'font_size' => [], 'text_alignment' => []])
+      'data' => array_merge($badgeLayout['data'], ['token' => [], 'font_name' => [''], 'font_size' => [], 'text_alignment' => []]),
     ];
     foreach (array_keys($this->getAvailableTokens()) as $id => $token) {
       $index = $id + 1;
@@ -65,7 +70,7 @@ class CRM_Event_Form_Task_BadgeTest extends CiviUnitTestCase {
         'text_alignment' => 'C',
         'token' => '{event.title}',
       ], $tokens[1]);
-      $index =1;
+      $index = 1;
       foreach ($this->getAvailableTokens() as $token => $expected) {
         $this->assertEquals($expected, $tokens[$index]['value'], 'failure in token ' . $token);
         $index++;
index 91445ed6ed5f97dd93889ce5b58c810eb323d825..fa9b57ae4cb3ac3a9b97aa278ec0163e129ce2b0 100644 (file)
@@ -495,8 +495,6 @@ December 21st, 2007
       '{participant.fee_label}' => 'Fee Label',
       '{participant.default_role_id}' => 'Default Role',
       '{participant.template_title}' => 'Event Template Title',
-      '{participant.currency}' => 'Currency',
-      '{participant.participant_note}' => 'Participant Note',
       '{participant.' . $this->getCustomFieldName('text') . '}' => 'Enter text here :: Group with field text',
     ];
   }