From ca862d56a6263e8c164b9bb7791390bea91be12a Mon Sep 17 00:00:00 2001 From: Jaap Jansma Date: Tue, 5 Dec 2023 16:24:41 +0100 Subject: [PATCH] dev/core#4410: fixed timezone support for standalone --- CRM/Utils/System/Standalone.php | 7 +++++++ ext/standaloneusers/CRM/Standaloneusers/BAO/User.php | 8 ++++++++ ext/standaloneusers/CRM/Standaloneusers/DAO/User.php | 7 +++++-- ext/standaloneusers/ang/afformEditUserAccount.aff.html | 2 +- .../xml/schema/CRM/Standaloneusers/User.xml | 5 ++++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CRM/Utils/System/Standalone.php b/CRM/Utils/System/Standalone.php index b58bcbb3de..18f5b7bfc7 100644 --- a/CRM/Utils/System/Standalone.php +++ b/CRM/Utils/System/Standalone.php @@ -540,6 +540,13 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { */ public function getTimeZoneString() { $timezone = date_default_timezone_get(); + $userId = Security::singleton()->getLoggedInUfID(); + if ($userId) { + $user = Security::singleton()->loadUserByID($userId); + if ($user && !empty($user['timezone'])) { + $timezone = $user['timezone']; + } + } return $timezone; } diff --git a/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php b/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php index 2522b9d91f..b66d9c4bc0 100644 --- a/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php +++ b/ext/standaloneusers/CRM/Standaloneusers/BAO/User.php @@ -33,4 +33,12 @@ class CRM_Standaloneusers_BAO_User extends CRM_Standaloneusers_DAO_User implemen return CRM_Core_I18n::uiLanguages(FALSE); } + public static function getTimeZones(): array { + $timeZones = []; + foreach (\DateTimeZone::listIdentifiers() as $timezoneId) { + $timeZones[$timezoneId] = $timezoneId; + } + return $timeZones; + } + } diff --git a/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php b/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php index f06e5c4a56..4cc9d4b608 100644 --- a/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php +++ b/ext/standaloneusers/CRM/Standaloneusers/DAO/User.php @@ -6,7 +6,7 @@ * * Generated from standaloneusers/xml/schema/CRM/Standaloneusers/User.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:08b152ee7b327be88d44e2fce7c528ea) + * (GenCodeChecksum:889ac5b24fb6913d046bd2e52dcb65ea) */ use CRM_Standaloneusers_ExtensionUtil as E; @@ -505,7 +505,10 @@ class CRM_Standaloneusers_DAO_User extends CRM_Core_DAO { 'bao' => 'CRM_Standaloneusers_DAO_User', 'localizable' => 0, 'html' => [ - 'type' => 'Text', + 'type' => 'Select', + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Standaloneusers_BAO_User::getTimeZones', ], 'add' => NULL, ], diff --git a/ext/standaloneusers/ang/afformEditUserAccount.aff.html b/ext/standaloneusers/ang/afformEditUserAccount.aff.html index 209509dde5..ef1eb4be19 100644 --- a/ext/standaloneusers/ang/afformEditUserAccount.aff.html +++ b/ext/standaloneusers/ang/afformEditUserAccount.aff.html @@ -5,7 +5,7 @@ - + diff --git a/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml b/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml index 4013223680..1fc8cbcb35 100644 --- a/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml +++ b/ext/standaloneusers/xml/schema/CRM/Standaloneusers/User.xml @@ -173,8 +173,11 @@ 32 false User's timezone + + CRM_Standaloneusers_BAO_User::getTimeZones + - Text + Select -- 2.25.1