From b11418429c627738ffaa9f2face1d6c68af3bd61 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Sat, 12 Mar 2022 11:36:58 -0500 Subject: [PATCH] revert 20476 --- CRM/Contribute/BAO/Contribution.php | 4 -- CRM/Core/SelectValues.php | 18 ----- CRM/Event/BAO/Event.php | 51 -------------- CRM/Event/BAO/Participant.php | 2 - CRM/Event/Form/ManageEvent/EventInfo.php | 16 +---- CRM/Event/Form/ManageEvent/Registration.php | 19 ------ CRM/Event/Form/Participant.php | 4 +- CRM/Event/Form/ParticipantFeeSelection.php | 4 +- CRM/Event/Form/Registration.php | 2 - CRM/Event/Form/SelfSvcTransfer.php | 2 - CRM/Event/ICalendar.php | 9 +-- CRM/Event/Page/EventInfo.php | 5 -- CRM/Event/Page/List.php | 14 ---- CRM/Event/Page/ManageEvent.php | 13 ---- CRM/Event/Tokens.php | 3 - CRM/Financial/BAO/Payment.php | 4 -- CRM/Upgrade/Incremental/MessageTemplates.php | 20 +++--- .../Incremental/php/FiveFortySeven.php | 17 ----- .../Incremental/sql/5.47.alpha1.mysql.tpl | 11 --- CRM/Utils/Check/Component/Env.php | 22 ------ CRM/Utils/Check/Component/Event.php | 61 ----------------- CRM/Utils/Date.php | 68 ------------------- .../Provider/EventCreationSpecProvider.php | 2 - api/v3/Event.php | 13 ---- templates/CRM/Core/Calendar/ICal.tpl | 8 +-- .../CRM/Event/Form/ManageEvent/EventInfo.tpl | 4 -- .../Event/Form/ManageEvent/Registration.tpl | 5 -- .../Form/Registration/EventInfoBlock.tpl | 31 ++++----- templates/CRM/Event/Page/EventInfo.tpl | 31 ++++----- templates/CRM/Event/Page/List.tpl | 10 ++- templates/CRM/Event/Page/ManageEvent.tpl | 4 +- .../Event/Form/ManageEvent/EventInfoTest.php | 59 ---------------- .../Form/ManageEvent/RegistrationTest.php | 56 --------------- tests/phpunit/CRM/Utils/DateTest.php | 22 ------ .../CRM/Utils/TokenConsistencyTest.php | 3 - .../api/v4/DataSets/ConformanceTest.json | 2 +- xml/schema/Event/Event.xml | 32 ++------- .../event_offline_receipt_html.tpl | 2 +- .../event_offline_receipt_text.tpl | 2 +- .../event_online_receipt_html.tpl | 2 +- .../event_online_receipt_text.tpl | 2 +- .../participant_cancelled_html.tpl | 2 +- .../participant_cancelled_text.tpl | 2 +- .../participant_confirm_html.tpl | 2 +- .../participant_confirm_text.tpl | 2 +- .../participant_expired_html.tpl | 2 +- .../participant_expired_text.tpl | 2 +- .../participant_transferred_html.tpl | 2 +- .../participant_transferred_text.tpl | 2 +- .../payment_or_refund_notification_html.tpl | 2 +- .../payment_or_refund_notification_text.tpl | 2 +- 51 files changed, 69 insertions(+), 610 deletions(-) delete mode 100644 CRM/Utils/Check/Component/Event.php delete mode 100644 tests/phpunit/CRM/Event/Form/ManageEvent/EventInfoTest.php delete mode 100644 tests/phpunit/CRM/Event/Form/ManageEvent/RegistrationTest.php diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index accc14ae80..b84a36269d 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2542,8 +2542,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac CRM_Event_BAO_Event::retrieve($eventParams, $values['event']); - CRM_Event_BAO_Event::setOutputTimeZone($values['event']); - //get location details $locationParams = [ 'entity_id' => $this->_relatedObjects['participant']->event_id, @@ -4724,8 +4722,6 @@ LIMIT 1;"; CRM_Event_BAO_Event::retrieve($eventParams, $values['event']); - CRM_Event_BAO_Event::setOutputTimeZone($values['event']); - // add custom fields for event $eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Event', NULL, $eventID); diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 31254a4dc7..a3c479ff28 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -1175,22 +1175,4 @@ class CRM_Core_SelectValues { ]; } - public static function timezone() { - $tzlist = &Civi::$statics[__CLASS__]['tzlist']; - - if (is_null($tzlist)) { - $tzlist = []; - foreach (timezone_identifiers_list() as $tz) { - // Actual timezone keys for PHP are mapped to human parts. - $tzlist[$tz] = str_replace('_', ' ', $tz); - } - - // Add 'Etc/UTC' specially, as timezone_identifiers_list() does - // not include it, but it is the IANA long name for 'UTC' - $tzlist['Etc/UTC'] = ts('Etc/UTC'); - } - - return $tzlist; - } - } diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index ca212da132..0aadbbae0d 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -15,7 +15,6 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event { - const tz_fields = ['event_start_date', 'event_end_date', 'start_date', 'end_date', 'registration_start_date', 'registration_end_date']; /** * Retrieve DB object and copy to defaults array. @@ -777,7 +776,6 @@ SELECT civicrm_email.email as email, civicrm_event.title as title, civicrm_event.summary as summary, - civicrm_event.event_tz as event_tz, civicrm_event.start_date as start, civicrm_event.end_date as end, civicrm_event.description as description, @@ -849,7 +847,6 @@ WHERE civicrm_event.is_active = 1 $info['event_id'] = $dao->event_id; $info['summary'] = $dao->summary; $info['description'] = $dao->description; - $info['tz'] = $dao->event_tz ?? CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); $info['start_date'] = $dao->start; $info['end_date'] = $dao->end; $info['contact_email'] = $dao->email; @@ -2434,52 +2431,4 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field return $return; } - /** - * Changes timezone-enabled fields to the correct zone for output and add local - * & UTC variants - * - * @param array $params - * @param $to_tz - * - * @return void - */ - public static function setOutputTimeZone(array &$params, $to_tz = NULL) { - $to_tz = $to_tz ?? ($params['event_tz'] ?? NULL); - - if (is_null($to_tz)) { - return; - } - - foreach (CRM_Event_BAO_Event::tz_fields as $field) { - if (!empty($params[$field]) && empty($params[$field . '_local'])) { - $params[$field . '_utc'] = CRM_Utils_Date::convertTimeZone($params[$field], 'UTC'); - $params[$field . '_local'] = $params[$field]; - $params[$field] = CRM_Utils_Date::convertTimeZone($params[$field], $to_tz); - } - } - - } - - public static function setTimezones(CRM_Event_DAO_Event $event) { - // Pre-process time zoned fields into the PHP time zone, which should be the same as the database, to save as timestamp. - $timezone_event = ($event->event_tz ?: (!empty($event->id) ? CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $event->id, 'event_tz') : NULL)); - - foreach (self::tz_fields as $field) { - if (!empty($event->{$field})) { - $event->{$field} = CRM_Utils_Date::convertTimeZone($event->{$field}, NULL, $timezone_event); - } - } - } - - public static function resetTimezones(CRM_Event_DAO_Event $event) { - // Process time zoned fields into their own time zone - $timezone_event = ($event->event_tz ?: (!empty($event->id) ? CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $event->id, 'event_tz') : NULL)); - - foreach (self::tz_fields as $field) { - if (!empty($event->{$field})) { - $event->{$field} = CRM_Utils_Date::convertTimeZone($event->{$field}, $timezone_event); - } - } - } - } diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index 8743339af5..ec9a4eb7af 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1392,8 +1392,6 @@ UPDATE civicrm_participant return $mailSent; } - CRM_Event_BAO_Event::setOutputTimeZone($eventDetails); - $toEmail = $contactDetails['email'] ?? NULL; if ($toEmail) { diff --git a/CRM/Event/Form/ManageEvent/EventInfo.php b/CRM/Event/Form/ManageEvent/EventInfo.php index cfaad1fa56..4e9ab1bd75 100644 --- a/CRM/Event/Form/ManageEvent/EventInfo.php +++ b/CRM/Event/Form/ManageEvent/EventInfo.php @@ -101,16 +101,6 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { $defaults['waitlist_text'] = CRM_Utils_Array::value('waitlist_text', $defaults, ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.')); $defaults['template_id'] = $this->_templateId; - $defaults['event_tz'] = CRM_Utils_Array::value('event_tz', $defaults, CRM_Core_Config::singleton()->userSystem->getTimeZoneString()); - - // Convert start and end date defaults to event time zone. - if (!empty($defaults['start_date'])) { - $defaults['start_date'] = CRM_Utils_Date::convertTimeZone($defaults['start_date'], $defaults['event_tz']); - } - if (!empty($defaults['end_date'])) { - $defaults['end_date'] = CRM_Utils_Date::convertTimeZone($defaults['end_date'], $defaults['event_tz']); - } - return $defaults; } @@ -170,8 +160,6 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { $this->addElement('checkbox', 'is_share', ts('Add footer region with Twitter, Facebook and LinkedIn share buttons and scripts?')); $this->addElement('checkbox', 'is_map', ts('Include Map to Event Location')); - $this->addSelect('event_tz', ['placeholder' => ts('- Select time zone -')], TRUE); - $this->add('datepicker', 'start_date', ts('Start'), [], !$this->_isTemplate, ['time' => TRUE]); $this->add('datepicker', 'end_date', ts('End'), [], FALSE, ['time' => TRUE]); @@ -228,8 +216,8 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { $params = array_merge($this->controller->exportValues($this->_name), $this->_submitValues); //format params - $params['start_date'] = !empty($params['start_date']) ? CRM_Utils_Date::convertTimeZone($params['start_date'], NULL, $params['event_tz'] ?? NULL) : $params['start_date']; - $params['end_date'] = !empty($params['end_date']) ? CRM_Utils_Date::convertTimeZone($params['end_date'], NULL, $params['event_tz'] ?? NULL) : $params['end_date']; + $params['start_date'] = $params['start_date'] ?? NULL; + $params['end_date'] = $params['end_date'] ?? NULL; $params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, FALSE); $params['is_map'] = CRM_Utils_Array::value('is_map', $params, FALSE); $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index ebde37ac6b..53a6d5e99a 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -29,8 +29,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent protected $_profilePostMultiple = []; protected $_profilePostMultipleAdd = []; - protected $_tz; - /** * Set variables up before form is built. */ @@ -168,14 +166,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering')); $defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.')); - // Convert start and end date defaults to event time zone. - if (!empty($defaults['registration_start_date'])) { - $defaults['registration_start_date'] = CRM_Utils_Date::convertTimeZone($defaults['registration_start_date'], $this->_tz ?? NULL); - } - if (!empty($defaults['registration_end_date'])) { - $defaults['registration_end_date'] = CRM_Utils_Date::convertTimeZone($defaults['registration_end_date'], $this->_tz ?? NULL); - } - return $defaults; } @@ -238,9 +228,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $this->add('text', 'registration_link_text', ts('Registration Link Text')); if (!$this->_isTemplate) { - $this->_tz = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'event_tz'); - $tz = CRM_Core_SelectValues::timezone()[$this->_tz]; - $this->assign('event_tz', $tz ?? '' . ts('%1 No timezone set', [1 => '']) . ''); $this->add('datepicker', 'registration_start_date', ts('Registration Start Date'), [], FALSE, ['time' => TRUE]); $this->add('datepicker', 'registration_end_date', ts('Registration End Date'), [], FALSE, ['time' => TRUE]); } @@ -789,10 +776,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $params['id'] = $this->_id; - if (!isset($this->_tz)) { - $this->_tz = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'event_tz') ?? CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); - } - // format params $params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, FALSE); // CRM-11182 @@ -800,8 +783,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, FALSE); $params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, FALSE); $params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, FALSE); - $params['registration_start_date'] = !empty($params['registration_start_date']) ? CRM_Utils_Date::convertTimeZone($params['registration_start_date'], NULL, $this->_tz ?? NULL) : $params['registration_start_date']; - $params['registration_end_date'] = !empty($params['registration_end_date']) ? CRM_Utils_Date::convertTimeZone($params['registration_end_date'], NULL, $this->_tz ?? NULL) : $params['registration_end_date']; // reset is_email confirm if not online reg if (!$params['is_online_registration']) { diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index e99eb186df..98666d186a 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1892,7 +1892,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment protected function assignEventDetailsToTpl($eventID, $participantRoles, $receiptText, $isPaidEvent) { //use of the message template below requires variables in different format $events = []; - $returnProperties = ['event_type_id', 'fee_label', 'start_date', 'end_date', 'event_tz', 'is_show_location', 'title']; + $returnProperties = ['event_type_id', 'fee_label', 'start_date', 'end_date', 'is_show_location', 'title']; //get all event details. CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $eventID, $events, $returnProperties); @@ -1900,8 +1900,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment unset($event['start_date']); unset($event['end_date']); - CRM_Event_BAO_Event::setOutputTimeZone($event); - $role = CRM_Event_PseudoConstant::participantRole(); if (is_array($participantRoles)) { diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index 19a0a1174e..d266851b36 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -285,7 +285,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $this->assign('module', 'Event Registration'); //use of the message template below requires variables in different format $event = $events = []; - $returnProperties = ['fee_label', 'start_date', 'end_date', 'event_tz', 'is_show_location', 'title']; + $returnProperties = ['fee_label', 'start_date', 'end_date', 'is_show_location', 'title']; //get all event details. CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties); @@ -293,8 +293,6 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { unset($event['start_date']); unset($event['end_date']); - CRM_Event_BAO_Event::setOutputTimeZone($event); - $role = CRM_Event_PseudoConstant::participantRole(); $participantRoles = $params['role_id'] ?? NULL; if (is_array($participantRoles)) { diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 6e0af92560..a34fcecd90 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -231,8 +231,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { $params = ['id' => $this->_eventId]; CRM_Event_BAO_Event::retrieve($params, $this->_values['event']); - CRM_Event_BAO_Event::setOutputTimeZone($this->_values['event'], $this->_values['event']['event_tz']); - // check for is_monetary status $isMonetary = $this->_values['event']['is_monetary'] ?? NULL; // check for ability to add contributions of type diff --git a/CRM/Event/Form/SelfSvcTransfer.php b/CRM/Event/Form/SelfSvcTransfer.php index 15659cfbab..a6db5abdd9 100644 --- a/CRM/Event/Form/SelfSvcTransfer.php +++ b/CRM/Event/Form/SelfSvcTransfer.php @@ -373,8 +373,6 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $eventParams = ['id' => $participant->event_id]; CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails); - CRM_Event_BAO_Event::setOutputTimeZone($eventDetails); - //get default participant role. $eventDetails['participant_role'] = $participantRoles[$eventDetails['default_role_id']] ?? NULL; //get the location info diff --git a/CRM/Event/ICalendar.php b/CRM/Event/ICalendar.php index c3e1b45aa5..a4cc998fd7 100644 --- a/CRM/Event/ICalendar.php +++ b/CRM/Event/ICalendar.php @@ -48,15 +48,8 @@ class CRM_Event_ICalendar { $info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end); - foreach ($info as &$event) { - $event['start_date'] = CRM_Utils_Date::convertTimeZone($event['start_date'], $event['tz']); - $event['end_date'] = !empty($event['end_date']) ? CRM_Utils_date::convertTimeZone($event['end_date'], $event['tz']) : NULL; - $event['registration_start_date'] = !empty($event['registration_start_date']) ? CRM_Utils_date::convertTimeZone($event['registration_start_date'], $event['tz']) : NULL; - $event['registration_end_date'] = !empty($event['registration_end_date']) ? CRM_Utils_date::convertTimeZone($event['registration_end_date'], $event['tz']) : NULL; - } - $template->assign('events', $info); - $template->assign('timezone', CRM_Core_Config::singleton()->userSystem->getTimeZoneString()); + $template->assign('timezone', @date_default_timezone_get()); // Send data to the correct template for formatting (iCal vs. gData) if ($rss) { diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index cffa121265..8f141a2a85 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -79,11 +79,6 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { $this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event'])); - // Reset event time zone info - CRM_Event_BAO_Event::setOutputTimeZone($values['event'], $values['event']['event_tz']); - - $values['event']['event_tz'] = CRM_Core_SelectValues::timezone()[$values['event']['event_tz']]; - // show event fees. if ($this->_id && !empty($values['event']['is_monetary'])) { CRM_Contribute_BAO_Contribution_Utils::overrideDefaultCurrency($values['event']); diff --git a/CRM/Event/Page/List.php b/CRM/Event/Page/List.php index ca4fae057b..9fbacab7c4 100644 --- a/CRM/Event/Page/List.php +++ b/CRM/Event/Page/List.php @@ -22,20 +22,6 @@ class CRM_Event_Page_List extends CRM_Core_Page { $info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end); - foreach ($info as &$event) { - $event['start_date_utc'] = CRM_Utils_Date::convertTimeZone($event['start_date'], 'UTC'); - $event['start_date'] = CRM_Utils_Date::convertTimeZone($event['start_date'], $event['tz']); - - $event['end_date_utc'] = !empty($event['end_date']) ? CRM_Utils_Date::convertTimeZone($event['end_date'], 'UTC') : NULL; - $event['end_date'] = !empty($event['end_date']) ? CRM_Utils_date::convertTimeZone($event['end_date'], $event['tz']) : NULL; - - $event['registration_start_date_utc'] = !empty($event['registration_start_date']) ? CRM_Utils_Date::convertTimeZone($event['registration_start_date'], 'UTC') : NULL; - $event['registration_start_date'] = !empty($event['registration_start_date']) ? CRM_Utils_date::convertTimeZone($event['registration_start_date'], $event['tz']) : NULL; - - $event['registration_end_date_utc'] = !empty($event['registration_end_date']) ? CRM_Utils_Date::convertTimeZone($event['registration_end_date'], 'UTC') : NULL; - $event['registration_end_date'] = !empty($event['registration_end_date']) ? CRM_Utils_date::convertTimeZone($event['registration_end_date'], $event['tz']) : NULL; - } - $this->assign('events', $info); // @todo Move this to eventcart extension diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 356710c81d..a39eb17a6a 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -361,19 +361,6 @@ ORDER BY start_date desc } CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]); - // avoid enotices - foreach (CRM_Event_BAO_Event::tz_fields as $field) { - $manageEvent[$dao->id][$field . '_with_tz'] = NULL; - } - if (!is_null($dao->event_tz) && $dao->event_tz != CRM_Core_Config::singleton()->userSystem->getTimeZoneString()) { - foreach (CRM_Event_BAO_Event::tz_fields as $field) { - if (!empty($dao->{$field})) { - $manageEvent[$dao->id][$field . '_with_tz'] = CRM_Utils_Date::convertTimeZone($dao->{$field}, $dao->event_tz); - } - } - } - $manageEvent[$dao->id]['event_tz'] = $dao->event_tz ? CRM_Core_SelectValues::timezone()[$dao->event_tz] : FALSE; - // form all action links $action = array_sum(array_keys($this->links())); diff --git a/CRM/Event/Tokens.php b/CRM/Event/Tokens.php index 44afb797f1..ca6fb553dd 100644 --- a/CRM/Event/Tokens.php +++ b/CRM/Event/Tokens.php @@ -144,8 +144,6 @@ 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])) { @@ -178,7 +176,6 @@ class CRM_Event_Tokens extends CRM_Core_EntityTokens { return ['event_type_id', 'title', 'id', - 'event_tz', 'start_date', 'end_date', 'summary', diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index 12439c2dfb..cec2c4425d 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -279,10 +279,6 @@ class CRM_Financial_BAO_Payment { $entities = self::loadRelatedEntities($params['id']); - if (!empty($entities['event'])) { - CRM_Event_BAO_Event::setOutputTimeZone($entities['event']); - } - $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'payment_or_refund_notification', diff --git a/CRM/Upgrade/Incremental/MessageTemplates.php b/CRM/Upgrade/Incremental/MessageTemplates.php index 09a87dd77f..a46359bb54 100644 --- a/CRM/Upgrade/Incremental/MessageTemplates.php +++ b/CRM/Upgrade/Incremental/MessageTemplates.php @@ -315,8 +315,16 @@ class CRM_Upgrade_Incremental_MessageTemplates { ], ], [ - 'version' => '5.47.alpha1', - 'upgrade_descriptor' => ts('Add time zone to Event dates'), + 'version' => '5.48.alpha1', + 'upgrade_descriptor' => ts('Replace {receipt_text_renewal} with {receipt_text}'), + 'templates' => [ + ['name' => 'membership_offline_receipt', 'type' => 'html'], + ['name' => 'membership_offline_receipt', 'type' => 'text'], + ], + ], + [ + 'version' => '5.48.beta1', + 'upgrade_descriptor' => ts('Revert time zone for Event dates'), 'templates' => [ ['name' => 'event_online_receipt', 'type' => 'html'], ['name' => 'event_online_receipt', 'type' => 'text'], @@ -334,14 +342,6 @@ class CRM_Upgrade_Incremental_MessageTemplates { ['name' => 'payment_or_refund_notification', 'type' => 'text'], ], ], - [ - 'version' => '5.48.alpha1', - 'upgrade_descriptor' => ts('Replace {receipt_text_renewal} with {receipt_text}'), - 'templates' => [ - ['name' => 'membership_offline_receipt', 'type' => 'html'], - ['name' => 'membership_offline_receipt', 'type' => 'text'], - ], - ], ]; } diff --git a/CRM/Upgrade/Incremental/php/FiveFortySeven.php b/CRM/Upgrade/Incremental/php/FiveFortySeven.php index ff2204c8c8..84fac95707 100644 --- a/CRM/Upgrade/Incremental/php/FiveFortySeven.php +++ b/CRM/Upgrade/Incremental/php/FiveFortySeven.php @@ -69,10 +69,6 @@ class CRM_Upgrade_Incremental_php_FiveFortySeven extends CRM_Upgrade_Incremental "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Relationship last modified.'" ); $this->addTask('Set initial value for relationship created_date and modified_date to start_date', 'updateRelationshipDates'); - $this->addTask('core-issue#2122 - Add timezone column to Events', 'addColumn', - 'civicrm_event', 'event_tz', "text NULL DEFAULT NULL COMMENT 'Event\'s native time zone'" - ); - $this->addTask('core-issue#2122 - Set the timezone to the default for existing Events', 'setEventTZDefault'); $this->addTask('Drop CustomGroup UI_name_extends index', 'dropIndex', 'civicrm_custom_group', 'UI_name_extends'); $this->addTask('Add CustomGroup UI_name index', 'addIndex', 'civicrm_custom_group', ['name'], 'UI'); if (CRM_Core_DAO::checkTableExists('civicrm_search_display')) { @@ -310,17 +306,4 @@ class CRM_Upgrade_Incremental_php_FiveFortySeven extends CRM_Upgrade_Incremental return TRUE; } - /** - * Set the timezone to the default for existing Events. - * - * @param \CRM_Queue_TaskContext $ctx - * @return bool - */ - public static function setEventTZDefault(CRM_Queue_TaskContext $ctx) { - // Set default for CiviCRM Events to user system timezone (most reasonable default); - $defaultTZ = CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); - CRM_Core_DAO::executeQuery('UPDATE `civicrm_event` SET `event_tz` = %1 WHERE `event_tz` IS NULL;', [1 => [$defaultTZ, 'String']]); - return TRUE; - } - } diff --git a/CRM/Upgrade/Incremental/sql/5.47.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.47.alpha1.mysql.tpl index 3943ae4308..c551271f12 100644 --- a/CRM/Upgrade/Incremental/sql/5.47.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.47.alpha1.mysql.tpl @@ -16,16 +16,5 @@ ALTER TABLE `civicrm_navigation` MODIFY COLUMN `is_active` tinyint NOT NULL DEFAULT 1 COMMENT 'Is this navigation item active?', MODIFY COLUMN `weight` int NOT NULL DEFAULT 0 COMMENT 'Ordering of the navigation items in various blocks.'; -{* https://lab.civicrm.org/dev/core/-/issues/2122 *} -UPDATE `civicrm_event` SET `start_date` = NULL WHERE `start_date` < 19700102; -UPDATE `civicrm_event` SET `end_date` = NULL WHERE `end_date` < 19700102; -UPDATE `civicrm_event` SET `registration_start_date` = NULL WHERE `registration_start_date` < 19700102; -UPDATE `civicrm_event` SET `registration_end_date` = NULL WHERE `registration_end_date` < 19700102; -ALTER TABLE `civicrm_event` - MODIFY COLUMN `start_date` timestamp NULL DEFAULT NULL COMMENT 'Date and time that event starts.', - MODIFY COLUMN `end_date` timestamp NULL DEFAULT NULL COMMENT 'Date and time that event ends. May be NULL if no defined end date/time', - MODIFY COLUMN `registration_start_date` timestamp NULL DEFAULT NULL COMMENT 'Date and time that online registration starts.', - MODIFY COLUMN `registration_end_date` timestamp NULL DEFAULT NULL COMMENT 'Date and time that online registration ends.'; - {* Ensure CustomGroup.name is unique *} UPDATE civicrm_custom_group g1, civicrm_custom_group g2 SET g1.name = CONCAT(g1.name, '_1') WHERE g1.name = g2.name AND g1.id > g2.id; diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 064f5f0122..39e1e3dde9 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -1042,26 +1042,4 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { return $messages; } - /** - * Ensure that the CMS is providing a supported timezone. - * - * @return CRM_Utils_Check_Message[] - */ - public function checkUFTimezoneValid() { - $messages = []; - $check_tz = CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); - - if (!array_key_exists($check_tz, CRM_Core_SelectValues::timezone())) { - $messages[] = new CRM_Utils_Check_Message( - __FUNCTION__, - ts('This system has an invalid timezone set. Please verify that your CMS has a timezone configured that is listed under the PHP List of Supported Timezones.', [1 => 'https://www.php.net/manual/en/timezones.php']), - ts('Missing or Invalid Timezone'), - \Psr\Log\LogLevel::ERROR, - 'fa-clock-o' - ); - } - - return $messages; - } - } diff --git a/CRM/Utils/Check/Component/Event.php b/CRM/Utils/Check/Component/Event.php deleted file mode 100644 index c84cc7c9cc..0000000000 --- a/CRM/Utils/Check/Component/Event.php +++ /dev/null @@ -1,61 +0,0 @@ -selectRowCount() - ->addWhere('event_tz', 'IS EMPTY') - ->execute() - ->rowCount; - - if ($count) { - $msg = new CRM_Utils_Check_Message( - __FUNCTION__, - '

' . ts('%count Event has no timezone set', ['count' => $count, 'plural' => '%count Events have no timezone set.']) . '

', - ts('Events with Missing Timezone'), - \Psr\Log\LogLevel::WARNING, - 'fa-calendar' - ); - $msg->addAction( - ts('Fix Events with Missing Timezone'), - ts('This will set the system default timezone "%1" for all Events with no timezone set.', [1 => CRM_Core_Config::singleton()->userSystem->getTimeZoneString()]), - 'api3', - ['Event', 'addMissingTimezones'] - ); - $messages[] = $msg; - } - } - catch (API_Exception $e) { - $messages[] = new CRM_Utils_Check_Message( - __FUNCTION__, - ts('API Exception: %1 while checking events for timezones.', ['1' => $e->getMessage()]), - ts('Event timezone check failed'), - \Psr\Log\LogLevel::ERROR, - 'fa-calendar' - ); - } - - return $messages; - } - -} diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index b050ace270..1802632da5 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -2215,72 +2215,4 @@ class CRM_Utils_Date { return $dateObject->format($format); } - /** - * Convert a date string between time zones - * - * @param string $date - date string using $format - * @param string $tz_to - new time zone for date - * @param string $tz_from - current time zone for date - * @param string $format - format string specification as per DateTime::createFromFormat; defaults to 'Y-m-d H:i:s' - * - * @throws \CRM_Core_Exception - * - * @return string; - */ - public static function convertTimeZone(string $date, string $tz_to = NULL, string $tz_from = NULL, $format = NULL) { - if (!$tz_from) { - $tz_from = CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); - } - if (!$tz_to) { - $tz_to = CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); - } - - // Return early if both timezones are the same. - if ($tz_from == $tz_to) { - return $date; - } - - $tz_from = new DateTimeZone($tz_from); - $tz_to = new DateTimeZone($tz_to); - - if (is_null($format)) { - // Detect "mysql" format dates and adjust format accordingly - $format = preg_match('/^(\d{4})(\d{2}){0,5}$/', $date, $m) ? 'YmdHis' : 'Y-m-d H:i:s'; - } - - try { - $date_object = DateTime::createFromFormat('!' . $format, $date, $tz_from); - $dt_errors = DateTime::getLastErrors(); - - if (!$date_object) { - Civi::log()->warning(ts('Attempted to convert time zone with incorrect date format %1', ['%1' => $date])); - - $dt_errors = DateTime::getLastErrors(); - - $date_object = new DateTime($date, $tz_from); - } - elseif ($dt_errors['warning_count'] && array_intersect($dt_errors['warnings'], ['The parsed date was invalid'])) { - throw new Exception('The parsed date was invalid'); - } - - $date_object->setTimezone($tz_to); - - return $date_object->format($format); - } - catch (Exception $e) { - if ($dt_errors['error_count'] || $dt_errors['warning_count']) { - throw new CRM_Core_Exception(ts( - 'Failed to parse date with %1 errors and %2 warnings', - [ - '%1' => $dt_errors['error_count'], - '%2' => $dt_errors['warning_count'], - ] - ), 0, ['format' => $format, 'date' => $date] + $dt_errors); - } - else { - throw $e; - } - } - } - } diff --git a/Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php b/Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php index e58d8752a4..d6c331cc47 100644 --- a/Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php +++ b/Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php @@ -31,8 +31,6 @@ class EventCreationSpecProvider implements Generic\SpecProviderInterface { ->setTitle('Template Id') ->setDescription('Template on which to base this new event'); $spec->addFieldSpec($template_id); - - $spec->getFieldByName('event_tz')->setDefaultValue(\CRM_Core_Config::singleton()->userSystem->getTimeZoneString()); } /** diff --git a/api/v3/Event.php b/api/v3/Event.php index c10266c680..f20d6702cf 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -59,7 +59,6 @@ function _civicrm_api3_event_create_spec(&$params) { $params['is_active']['api.default'] = 1; $params['financial_type_id']['api.aliases'] = ['contribution_type_id']; $params['is_template']['api.default'] = 0; - $params['event_tz']['api.default'] = CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); } /** @@ -262,15 +261,3 @@ function _civicrm_api3_event_getlist_output($result, $request) { } return $output; } - -/** - * Add missing timezones to all events. - * - * @return array - */ -function civicrm_api3_event_addmissingtimezones($params) { - $defaultTZ = CRM_Core_Config::singleton()->userSystem->getTimeZoneString(); - - CRM_Core_DAO::executeQuery('UPDATE civicrm_event SET event_tz = %1 WHERE event_tz IS NULL OR event_tz = ""', [1 => [$defaultTZ, 'String']]); - return civicrm_api3_create_success($events, $params, 'Event', 'addMissingTimezones'); -} diff --git a/templates/CRM/Core/Calendar/ICal.tpl b/templates/CRM/Core/Calendar/ICal.tpl index ab15f5e1c0..f38502d5ad 100644 --- a/templates/CRM/Core/Calendar/ICal.tpl +++ b/templates/CRM/Core/Calendar/ICal.tpl @@ -24,15 +24,15 @@ CATEGORIES:{$event.event_type|crmICalText} {/if} CALSCALE:GREGORIAN {if $event.start_date} -DTSTAMP;TZID={$event.tz|default:$timezone}:{$event.start_date|crmICalDate} -DTSTART;TZID={$event.tz|default:$timezone}:{$event.start_date|crmICalDate} +DTSTAMP;TZID={$timezone}:{$event.start_date|crmICalDate} +DTSTART;TZID={$timezone}:{$event.start_date|crmICalDate} {else} DTSTAMP;TZID={$timezone}:{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'|crmICalDate} {/if} {if $event.end_date} -DTEND;TZID={$event.tz|default:$timezone}:{$event.end_date|crmICalDate} +DTEND;TZID={$timezone}:{$event.end_date|crmICalDate} {else} -DTEND;TZID={$event.tz|default:$timezone}:{$event.start_date|crmICalDate} +DTEND;TZID={$timezone}:{$event.start_date|crmICalDate} {/if} {if $event.is_show_location EQ 1 && $event.location} LOCATION:{$event.location|crmICalText} diff --git a/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl b/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl index 1877ae26ad..5bb6b6a706 100644 --- a/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl +++ b/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl @@ -59,10 +59,6 @@ {$form.description.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='description' id=$eventID}{/if} {$form.description.html} - - {$form.event_tz.label} - {$form.event_tz.html} - {if !$isTemplate} {$form.start_date.label} diff --git a/templates/CRM/Event/Form/ManageEvent/Registration.tpl b/templates/CRM/Event/Form/ManageEvent/Registration.tpl index 9c62e3742d..c3db65bb90 100644 --- a/templates/CRM/Event/Form/ManageEvent/Registration.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Registration.tpl @@ -54,11 +54,6 @@ {$form.registration_link_text.html} {help id="id-link_text"} {if !$isTemplate} -
{ts 1=$event_tz}{/ts} - - -
{ts 1=$event_tz}Registration start and end dates must be specified in the Event's timezone, %1{/ts} - {$form.registration_start_date.label} {$form.registration_start_date.html} diff --git a/templates/CRM/Event/Form/Registration/EventInfoBlock.tpl b/templates/CRM/Event/Form/Registration/EventInfoBlock.tpl index f77f5dc5f6..8a0486b4c2 100644 --- a/templates/CRM/Event/Form/Registration/EventInfoBlock.tpl +++ b/templates/CRM/Event/Form/Registration/EventInfoBlock.tpl @@ -18,27 +18,20 @@ {/if} - - {ts}Event Start{/ts} - - - - - {if $event.event_end_date} - - {ts}Event End{/ts} - - + {ts}When{/ts} + + {$event.event_start_date|crmDate} + {if $event.event_end_date} +   {ts}through{/ts}   + {* Only show end time if end date = start date *} + {if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"} + {$event.event_end_date|crmDate:0:1} + {else} + {$event.event_end_date|crmDate} + {/if} + {/if} - {/if} {if $isShowLocation} {if $location.address.1} diff --git a/templates/CRM/Event/Page/EventInfo.tpl b/templates/CRM/Event/Page/EventInfo.tpl index 5d33dca43d..36bb493ccc 100644 --- a/templates/CRM/Event/Page/EventInfo.tpl +++ b/templates/CRM/Event/Page/EventInfo.tpl @@ -99,25 +99,20 @@ {/if}
-
{ts}Event Start{/ts}
+
{ts}When{/ts}
- -
-
-
- {if $event.event_end_date} -
-
{ts}Event End{/ts}
-
- - {/if} + {strip} + {$event.event_start_date|crmDate} + {if $event.event_end_date} +  {ts}through{/ts}  + {* Only show end time if end date = start date *} + {if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"} + {$event.event_end_date|crmDate:0:1} + {else} + {$event.event_end_date|crmDate} + {/if} + {/if} + {/strip}
diff --git a/templates/CRM/Event/Page/List.tpl b/templates/CRM/Event/Page/List.tpl index 5db5103dbb..50da60fd8b 100644 --- a/templates/CRM/Event/Page/List.tpl +++ b/templates/CRM/Event/Page/List.tpl @@ -30,15 +30,13 @@ {$event.title} {if $event.summary}{$event.summary|purify} ({ts}read more{/ts}...){else} {/if} - {if $event.start_date}{if $event.end_date}
{ts}through{/ts}
-{/if} + {$event.end_date|crmDate} + {/if}{/strip}{/if} {else}{ts}(not available){/ts}{/if} {if $event.is_show_location EQ 1 AND $event.location}{$event.location}{else}{ts}(not available){/ts}{/if} diff --git a/templates/CRM/Event/Page/ManageEvent.tpl b/templates/CRM/Event/Page/ManageEvent.tpl index 124ba7f13f..f0dbdea85c 100644 --- a/templates/CRM/Event/Page/ManageEvent.tpl +++ b/templates/CRM/Event/Page/ManageEvent.tpl @@ -62,8 +62,8 @@ {$row.state_province} {$row.event_type} {if $row.is_public eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} - {$row.start_date|crmDate:"%b %d, %Y %l:%M %P"}{if $row.start_date_with_tz}
{$row.start_date_with_tz|crmDate:"%b %d, %Y %l:%M %P"} {$row.event_tz}{elseif !$row.event_tz} {ts 1=''}%1 No timezone set{/ts}{/if} - {$row.end_date|crmDate:"%b %d, %Y %l:%M %P"}{if $row.end_date_with_tz}
{$row.end_date_with_tz|crmDate:"%b %d, %Y %l:%M %P"} {$row.event_tz}{/if} + {$row.start_date|crmDate:"%b %d, %Y %l:%M %P"} + {$row.end_date|crmDate:"%b %d, %Y %l:%M %P"} {if call_user_func(array('CRM_Campaign_BAO_Campaign','isCampaignEnable'))} {$row.campaign} {/if} diff --git a/tests/phpunit/CRM/Event/Form/ManageEvent/EventInfoTest.php b/tests/phpunit/CRM/Event/Form/ManageEvent/EventInfoTest.php deleted file mode 100644 index 942a6abb50..0000000000 --- a/tests/phpunit/CRM/Event/Form/ManageEvent/EventInfoTest.php +++ /dev/null @@ -1,59 +0,0 @@ -form, 'CRM_Event_Form_ManageEvent_EventInfo')) { - // EventInfo form redirects to the location form if the action is ADD - $event->form->setAction(CRM_Core_Action::NONE); - } - } - - public function testTimeZone() { - $formValues = [ - 'start_date' => '2022-06-22 12:00:00', - 'end_date' => '2022-06-22 20:00:00', - 'event_tz' => 'Australia/Sydney', - ]; - - Civi::dispatcher()->addListener('hook_civicrm_postProcess', [$this, 'preventCiviExit']); - - $event_id = $this->submitForm($formValues); - - $this->assertIsInt($event_id, 'Event creation success'); - - Civi::dispatcher()->removeListener('hook_civicrm_postProcess', [$this, 'preventCiviExit']); - - $event = Event::get(FALSE) - ->addWhere('id', '=', $event_id) - ->addSelect('id', 'start_date', 'end_date', 'event_tz') - ->execute()[0]; - - $this->assertEquals('2022-06-22 02:00:00', $event['start_date'], 'Event start date resolved by timezone.'); - $this->assertEquals('2022-06-22 10:00:00', $event['end_date'], 'Event end date resolved by timezone.'); - } - - public function getFormValues() { - if (empty(Civi::$statics[__CLASS__])) { - Civi::$statics[__CLASS__] = $this->eventCreate(); - Civi::$statics[__CLASS__]['id'] = NULL; - } - - return Civi::$statics[__CLASS__]; - } - - public function submitForm(array $formValues, ?int $eventID = NULL): int { - $form = $this->getFormObject(CRM_Event_Form_ManageEvent_EventInfo::class, array_merge($this->getFormValues(), $formValues)); - if ($eventID) { - $form->set('id', $eventID); - } - - $form->preProcess(); - $form->buildQuickForm(); - $form->postProcess(); - return $form->get('id'); - } - -} diff --git a/tests/phpunit/CRM/Event/Form/ManageEvent/RegistrationTest.php b/tests/phpunit/CRM/Event/Form/ManageEvent/RegistrationTest.php deleted file mode 100644 index 44a3f26787..0000000000 --- a/tests/phpunit/CRM/Event/Form/ManageEvent/RegistrationTest.php +++ /dev/null @@ -1,56 +0,0 @@ -form, 'CRM_Event_Form_ManageEvent_Registration')) { - // EventInfo form redirects to the location form if the action is ADD - $event->form->setAction(CRM_Core_Action::NONE); - } - } - - public function testTimeZone() { - $event_id = $this->eventCreate([ - 'event_tz' => 'Australia/Sydney', - 'start_date' => '2022-06-22 12:00:00', - 'end_date' => '2022-06-22 20:00:00', - ])['id']; - - $formValues = [ - 'registration_start_date' => '2022-05-23 09:00:00', - 'registration_end_date' => '2022-06-20 17:00:00', - ]; - - Civi::dispatcher()->addListener('hook_civicrm_postProcess', [$this, 'preventCiviExit']); - - $this->submitForm($formValues, $event_id); - - $this->assertIsInt($event_id, 'Event creation success'); - - Civi::dispatcher()->removeListener('hook_civicrm_postProcess', [$this, 'preventCiviExit']); - - $event = Event::get(FALSE) - ->addWhere('id', '=', $event_id) - ->addSelect('id', 'registration_start_date', 'registration_end_date', 'event_tz') - ->execute()[0]; - - $this->assertEquals('2022-05-22 23:00:00', $event['registration_start_date'], 'Registration start date resolved by timezone.'); - $this->assertEquals('2022-06-20 07:00:00', $event['registration_end_date'], 'Registration end date resolved by timezone.'); - - } - - public function submitForm(array $formValues, int $eventID): int { - $form = $this->getFormObject(CRM_Event_Form_ManageEvent_Registration::class, $formValues); - if ($eventID) { - $form->set('id', $eventID); - } - - $form->preProcess(); - $form->buildQuickForm(); - $form->postProcess(); - return $form->get('id'); - } - -} diff --git a/tests/phpunit/CRM/Utils/DateTest.php b/tests/phpunit/CRM/Utils/DateTest.php index 9f17b77322..b0917741ef 100644 --- a/tests/phpunit/CRM/Utils/DateTest.php +++ b/tests/phpunit/CRM/Utils/DateTest.php @@ -324,26 +324,4 @@ class CRM_Utils_DateTest extends CiviUnitTestCase { } } - /** - * Test timezone conversion function - */ - public function testConvertTimeZone() { - $tests = [ - [['1970-01-01 00:00:00', 'Atlantic/Azores', 'UTC'], '1969-12-31 23:00:00'], - [['1970-01-01 00:00:00', 'Europe/Berlin'], '1970-01-01 01:00:00'], - [['2022-06-22 12:00:00', 'Atlantic/Azores'], '2022-06-22 12:00:00'], - [['2022-06-22 12:00:00', 'Europe/Berlin', 'UTC'], '2022-06-22 14:00:00'], - [['2022-06-22 12:00:00', 'Europe/Berlin', 'Australia/Sydney'], '2022-06-22 04:00:00'], - ]; - - foreach ($tests as $i => [$params, $result]) { - $this->assertEquals($result, CRM_Utils_Date::convertTimeZone(...$params), "convertTimeZone $i"); - } - - //0000-00-00 00:00:00 is not an actual time, so we should expect an exception. - $this->expectException(CRM_Core_Exception::class); - $this->expectExceptionMessageMatches('{^Failed to parse date}'); - CRM_Utils_Date::convertTimeZone('0000-00-00 00:00:00', 'Europe/Berlin'); - } - } diff --git a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php index 0f625f4dd7..14738efaef 100644 --- a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php +++ b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php @@ -608,7 +608,6 @@ 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 @@ -895,7 +894,6 @@ 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', @@ -956,7 +954,6 @@ 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' diff --git a/tests/phpunit/api/v4/DataSets/ConformanceTest.json b/tests/phpunit/api/v4/DataSets/ConformanceTest.json index e1a32c3bc2..0b5bf5597c 100644 --- a/tests/phpunit/api/v4/DataSets/ConformanceTest.json +++ b/tests/phpunit/api/v4/DataSets/ConformanceTest.json @@ -30,7 +30,7 @@ ], "Event": [ { - "start_date": "20371010000000", + "start_date": "20401010000000", "title": "The Singularity", "event_type_id": "major_historical_event" } diff --git a/xml/schema/Event/Event.xml b/xml/schema/Event/Event.xml index 067a3a528c..a90b01446b 100644 --- a/xml/schema/Event/Event.xml +++ b/xml/schema/Event/Event.xml @@ -124,15 +124,13 @@ start_date - timestamp + datetime event_start_date Event Start Date /^start|(s(tart\s)?date)$/i true Date and time that event starts. 1.7 - false - NULL Select Date activityDateTime @@ -140,15 +138,13 @@ end_date - timestamp + datetime event_end_date Event End Date /^end|(e(nd\s)?date)$/i true Date and time that event ends. May be NULL if no defined end date/time 1.7 - false - NULL Select Date activityDateTime @@ -179,11 +175,9 @@ registration_start_date - timestamp + datetime Date and time that online registration starts. 1.8 - false - NULL Select Date activityDateTime @@ -192,11 +186,9 @@ registration_end_date - timestamp + datetime Date and time that online registration ends. 1.8 - false - NULL Select Date activityDateTime @@ -902,20 +894,4 @@ CheckBox - - event_tz - text - event_tz - Event Time Zone - true - Event's native time zone - 5.47 - NULL - - Select - - - CRM_Core_SelectValues::timezone - - diff --git a/xml/templates/message_templates/event_offline_receipt_html.tpl b/xml/templates/message_templates/event_offline_receipt_html.tpl index 2554ff6798..69fae2eb55 100644 --- a/xml/templates/message_templates/event_offline_receipt_html.tpl +++ b/xml/templates/message_templates/event_offline_receipt_html.tpl @@ -53,7 +53,7 @@ {$event.event_title}
- {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} + {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} diff --git a/xml/templates/message_templates/event_offline_receipt_text.tpl b/xml/templates/message_templates/event_offline_receipt_text.tpl index 81ce8dca5a..adaf909654 100644 --- a/xml/templates/message_templates/event_offline_receipt_text.tpl +++ b/xml/templates/message_templates/event_offline_receipt_text.tpl @@ -42,7 +42,7 @@ ==========================================================={if !empty($pricesetFieldsCount) }===================={/if} {$event.event_title} -{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} +{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$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} diff --git a/xml/templates/message_templates/event_online_receipt_html.tpl b/xml/templates/message_templates/event_online_receipt_html.tpl index 1b416a8072..7b771d41b1 100644 --- a/xml/templates/message_templates/event_online_receipt_html.tpl +++ b/xml/templates/message_templates/event_online_receipt_html.tpl @@ -64,7 +64,7 @@ {$event.event_title}
- {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} + {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if} diff --git a/xml/templates/message_templates/event_online_receipt_text.tpl b/xml/templates/message_templates/event_online_receipt_text.tpl index affb31472b..22473002a2 100644 --- a/xml/templates/message_templates/event_online_receipt_text.tpl +++ b/xml/templates/message_templates/event_online_receipt_text.tpl @@ -47,7 +47,7 @@ ==========================================================={if !empty($pricesetFieldsCount)}===================={/if} {$event.event_title} -{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} +{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if} {if !empty($conference_sessions)} diff --git a/xml/templates/message_templates/participant_cancelled_html.tpl b/xml/templates/message_templates/participant_cancelled_html.tpl index 24637e0922..c0da77d4d5 100644 --- a/xml/templates/message_templates/participant_cancelled_html.tpl +++ b/xml/templates/message_templates/participant_cancelled_html.tpl @@ -35,7 +35,7 @@ {$event.event_title}
- {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|crmDate:"shortdate" == $event.event_start_date|crmDate:"shortdate"}{$event.event_end_date|crmDate:"Time"}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} + {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|crmDate:"shortdate" == $event.event_start_date|crmDate:"shortdate"}{$event.event_end_date|crmDate:"Time"}{else}{$event.event_end_date|crmDate}{/if}{/if} diff --git a/xml/templates/message_templates/participant_cancelled_text.tpl b/xml/templates/message_templates/participant_cancelled_text.tpl index b60ce46af6..dedf895d88 100644 --- a/xml/templates/message_templates/participant_cancelled_text.tpl +++ b/xml/templates/message_templates/participant_cancelled_text.tpl @@ -8,7 +8,7 @@ =========================================================== {$event.event_title} -{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|crmDate:"shortdate" == $event.event_start_date|crmDate:"shortdate"}{$event.event_end_date|crmDate:"Time"}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} +{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|crmDate:"shortdate" == $event.event_start_date|crmDate:"shortdate"}{$event.event_end_date|crmDate:"Time"}{else}{$event.event_end_date|crmDate}{/if}{/if} {ts}Participant Role{/ts}: {participant.role_id:label} diff --git a/xml/templates/message_templates/participant_confirm_html.tpl b/xml/templates/message_templates/participant_confirm_html.tpl index 7b7d04b175..bd8b599b16 100644 --- a/xml/templates/message_templates/participant_confirm_html.tpl +++ b/xml/templates/message_templates/participant_confirm_html.tpl @@ -53,7 +53,7 @@ {$event.event_title}
- {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} + {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {if $conference_sessions} diff --git a/xml/templates/message_templates/participant_confirm_text.tpl b/xml/templates/message_templates/participant_confirm_text.tpl index 3d685d4944..0ccf6ad260 100644 --- a/xml/templates/message_templates/participant_confirm_text.tpl +++ b/xml/templates/message_templates/participant_confirm_text.tpl @@ -22,7 +22,7 @@ Click this link to go to a web page where you can confirm your registration onli =========================================================== {$event.event_title} -{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} +{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {if $conference_sessions} diff --git a/xml/templates/message_templates/participant_expired_html.tpl b/xml/templates/message_templates/participant_expired_html.tpl index 2a7edf991d..57804d1429 100644 --- a/xml/templates/message_templates/participant_expired_html.tpl +++ b/xml/templates/message_templates/participant_expired_html.tpl @@ -38,7 +38,7 @@ or want to inquire about reinstating your registration for this event.{/ts}

{$event.event_title}
- {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} + {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} diff --git a/xml/templates/message_templates/participant_expired_text.tpl b/xml/templates/message_templates/participant_expired_text.tpl index b9fdd3f217..e6ec27f026 100644 --- a/xml/templates/message_templates/participant_expired_text.tpl +++ b/xml/templates/message_templates/participant_expired_text.tpl @@ -12,7 +12,7 @@ or want to inquire about reinstating your registration for this event.{/ts} =========================================================== {$event.event_title} -{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} +{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {ts}Participant Role{/ts}: {$participant.role} diff --git a/xml/templates/message_templates/participant_transferred_html.tpl b/xml/templates/message_templates/participant_transferred_html.tpl index 22520519f7..a5e2b927a7 100644 --- a/xml/templates/message_templates/participant_transferred_html.tpl +++ b/xml/templates/message_templates/participant_transferred_html.tpl @@ -35,7 +35,7 @@ {$event.event_title}
- {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} + {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} diff --git a/xml/templates/message_templates/participant_transferred_text.tpl b/xml/templates/message_templates/participant_transferred_text.tpl index 87c9bb3225..5c62b00570 100644 --- a/xml/templates/message_templates/participant_transferred_text.tpl +++ b/xml/templates/message_templates/participant_transferred_text.tpl @@ -7,7 +7,7 @@ =========================================================== {$event.event_title} -{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} +{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {ts}Participant Role{/ts}: {$participant.role} diff --git a/xml/templates/message_templates/payment_or_refund_notification_html.tpl b/xml/templates/message_templates/payment_or_refund_notification_html.tpl index 8690a759b8..d1d5983faa 100644 --- a/xml/templates/message_templates/payment_or_refund_notification_html.tpl +++ b/xml/templates/message_templates/payment_or_refund_notification_html.tpl @@ -177,7 +177,7 @@ {$event.event_title}
- {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} + {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} diff --git a/xml/templates/message_templates/payment_or_refund_notification_text.tpl b/xml/templates/message_templates/payment_or_refund_notification_text.tpl index 649e088e11..3499b2f9f6 100644 --- a/xml/templates/message_templates/payment_or_refund_notification_text.tpl +++ b/xml/templates/message_templates/payment_or_refund_notification_text.tpl @@ -90,7 +90,7 @@ =============================================================================== {$event.event_title} -{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {$event.event_tz} +{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if} {if !empty($event.participant_role)} {ts}Participant Role{/ts}: {$event.participant_role} -- 2.25.1