From a93fca9303a215763d910a4d4546c8bce936e2d3 Mon Sep 17 00:00:00 2001 From: Francis Whittle Date: Fri, 7 May 2021 13:08:53 +1000 Subject: [PATCH] CIVICRM-1758 Add timezone output for Event Tokens. --- CRM/Event/Tokens.php | 3 +++ tests/phpunit/CRM/Utils/TokenConsistencyTest.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CRM/Event/Tokens.php b/CRM/Event/Tokens.php index ca6fb553dd..44afb797f1 100644 --- a/CRM/Event/Tokens.php +++ b/CRM/Event/Tokens.php @@ -144,6 +144,8 @@ class CRM_Event_Tokens extends CRM_Core_EntityTokens { $tokens['event_type_id:name']['text/html'] = CRM_Core_PseudoConstant::getName('CRM_Event_BAO_Event', 'event_type_id', $event['event_type_id']); $tokens['contact_phone']['text/html'] = $event['loc_block_id.phone_id.phone']; $tokens['contact_email']['text/html'] = $event['loc_block_id.email_id.email']; + $tokens['event_tz:label']['text/html'] = !empty($event['event_tz']) ? CRM_Core_SelectValues::timezone()[$event['event_tz']] : ''; + $tokens['event_tz:name']['text/html'] = $event['event_tz'] ?? ''; foreach ($this->getTokenMetadata() as $fieldName => $fieldSpec) { if (!isset($tokens[$fieldName])) { @@ -176,6 +178,7 @@ class CRM_Event_Tokens extends CRM_Core_EntityTokens { return ['event_type_id', 'title', 'id', + 'event_tz', 'start_date', 'end_date', 'summary', diff --git a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php index c72c6b8733..9c1343afcf 100644 --- a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php +++ b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php @@ -588,6 +588,7 @@ participant.must_wait : event.title :Annual CiviCRM meet event.start_date :October 21st, 2008 event.end_date :October 23rd, 2008 +event.event_tz:label :America/New York event.event_type_id:label :Conference event.summary :If you have any CiviCRM related issues or want to track where CiviCRM is heading, Sign up now event.contact_email :event@example.com @@ -874,6 +875,7 @@ December 21st, 2007 '{event.title}' => 'Event Title', '{event.start_date}' => 'Event Start Date', '{event.end_date}' => 'Event End Date', + '{event.event_tz:label}' => 'Event Time Zone', '{event.event_type_id:label}' => 'Event Type', '{event.summary}' => 'Event Summary', '{event.contact_email}' => 'Event Contact Email', @@ -934,6 +936,7 @@ December 21st, 2007 'description' => 'event description', $this->getCustomFieldName('text') => 'my field', 'loc_block_id' => $locationBlockID, + 'event_tz' => 'America/New_York', ])['id']; // Create an unrelated participant record so that the ids don't match. // this prevents things working just because the id 'happens to be valid' -- 2.25.1