Index: openacs-4/packages/acs-lang/tcl/locale-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/locale-procs.tcl,v diff -u -r1.51.2.15 -r1.51.2.16 --- openacs-4/packages/acs-lang/tcl/locale-procs.tcl 8 Feb 2023 15:09:01 -0000 1.51.2.15 +++ openacs-4/packages/acs-lang/tcl/locale-procs.tcl 8 Feb 2023 15:25:31 -0000 1.51.2.16 @@ -152,47 +152,24 @@ @return a timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York) } { - if { ![lang::system::timezone_support_p] } { - return "" - } - set package_id [apm_package_id_from_key "acs-lang"] return [parameter::get -package_id $package_id -parameter SystemTimezone -default "Etc/UTC"] } -ad_proc -private lang::system::timezone_support_p {} { - Return 1 if this installation of acs-lang offers - timezone services and 0 otherwise. - - For the acs-lang package to offer timezone support the - ref-timezones and acs-reference packages need to be installed. - Those packages are currently not part of the OpenACS kernel. -} { - return [expr {[apm_package_id_from_key ref-timezones] != 0}] -} - ad_proc -public lang::system::set_timezone { timezone } { Tell OpenACS what timezone we think it's running in. @param timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York) } { - if { ![lang::system::timezone_support_p] } { - return "" - } - set package_id [apm_package_id_from_key "acs-lang"] parameter::set_value -package_id $package_id -parameter SystemTimezone -value $timezone } ad_proc -public lang::system::timezone_utc_offset { } { @return number of hours to subtract from local (database) time to get UTC } { - if { ![lang::system::timezone_support_p] } { - return "" - } - set system_timezone [timezone] return [db_string system_utc_offset {}] } @@ -479,7 +456,7 @@ @return a timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York) } { set user_id [ad_conn user_id] - if { ![lang::system::timezone_support_p] || $user_id == 0 } { + if { $user_id == 0 } { return "" } @@ -493,10 +470,6 @@ @param timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York) } { - if { ![lang::system::timezone_support_p] } { - return "" - } - set user_id [ad_conn user_id] if { $user_id == 0 } { @@ -763,10 +736,6 @@ @return a timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York) } { - if { ![lang::system::timezone_support_p] } { - return "" - } - set timezone {} if { [ad_conn isconnected] } { set timezone [lang::user::timezone] Index: openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl,v diff -u -r1.28.2.26 -r1.28.2.27 --- openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl 19 Aug 2022 13:15:06 -0000 1.28.2.26 +++ openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl 8 Feb 2023 15:25:31 -0000 1.28.2.27 @@ -872,7 +872,6 @@ lang::conn::timezone lang::system::set_timezone lang::system::timezone - lang::system::timezone_support_p lang::user::set_timezone lang::user::timezone lc_list_all_timezones @@ -881,104 +880,95 @@ Test that setting and getting user timezone works } { - # We cannot test timezones if they are not installed - if { [lang::system::timezone_support_p] } { + # Make sure we have a logged-in user + set org_user_id [ad_conn user_id] - # Make sure we have a logged-in user - set org_user_id [ad_conn user_id] + if { $org_user_id == 0 } { + set user_id [db_string user { select min(user_id) from users }] + ad_conn -set user_id $user_id + } else { + set user_id $org_user_id + } - if { $org_user_id == 0 } { - set user_id [db_string user { select min(user_id) from users }] - ad_conn -set user_id $user_id - } else { - set user_id $org_user_id - } + # Remember originals so we can restore them + set system_timezone [lang::system::timezone] + set user_timezone [lang::user::timezone] - # Remember originals so we can restore them - set system_timezone [lang::system::timezone] - set user_timezone [lang::user::timezone] + set timezones [lc_list_all_timezones] + set n [expr {[llength $timezones]-1}] - set timezones [lc_list_all_timezones] - set n [expr {[llength $timezones]-1}] + set desired_user_timezone [lindex $timezones [util::random_range $n] 0] + set desired_system_timezone [lindex $timezones [util::random_range $n] 0] - set desired_user_timezone [lindex $timezones [util::random_range $n] 0] - set desired_system_timezone [lindex $timezones [util::random_range $n] 0] + set error_p 0 + ad_try { + # User timezone + lang::user::set_timezone $desired_user_timezone + aa_equals "User timezone retrieved is the same as the one set" \ + [lang::user::timezone] \ + $desired_user_timezone - set error_p 0 - ad_try { - # User timezone - lang::user::set_timezone $desired_user_timezone - aa_equals "User timezone retrieved is the same as the one set" \ - [lang::user::timezone] \ - $desired_user_timezone + # Storage + set user_id [ad_conn user_id] + aa_equals "User timezone stored in user_preferences table" \ + [db_string user_prefs { select timezone from user_preferences where user_id = :user_id }] \ + $desired_user_timezone - # Storage - set user_id [ad_conn user_id] - aa_equals "User timezone stored in user_preferences table" \ - [db_string user_prefs { select timezone from user_preferences where user_id = :user_id }] \ - $desired_user_timezone + # System timezone + lang::system::set_timezone $desired_system_timezone + aa_equals "System timezone retrieved is the same as the one set" \ + [lang::system::timezone] \ + $desired_system_timezone - # System timezone - lang::system::set_timezone $desired_system_timezone - aa_equals "System timezone retrieved is the same as the one set" \ - [lang::system::timezone] \ - $desired_system_timezone + # Connection timezone + aa_equals "Using user timezone" \ + [lang::conn::timezone] \ + $desired_user_timezone - # Connection timezone - aa_equals "Using user timezone" \ - [lang::conn::timezone] \ - $desired_user_timezone + ad_conn -set isconnected 0 + aa_equals "Fallback to system timezone when no connection" \ + [lang::conn::timezone] \ + $desired_system_timezone + ad_conn -set isconnected 1 - ad_conn -set isconnected 0 - aa_equals "Fallback to system timezone when no connection" \ - [lang::conn::timezone] \ - $desired_system_timezone - ad_conn -set isconnected 1 + lang::user::set_timezone {} + aa_equals "Fallback to system timezone when no user pref" \ + [lang::conn::timezone] \ + $desired_system_timezone - lang::user::set_timezone {} - aa_equals "Fallback to system timezone when no user pref" \ - [lang::conn::timezone] \ - $desired_system_timezone + } on error {errorMsg} { + set error_p 1 + # rethrow the error + error $errorMsg $::errorInfo - } on error {errorMsg} { - set error_p 1 - # rethrow the error - error $errorMsg $::errorInfo - - } finally { - lang::system::set_timezone $system_timezone - lang::user::set_timezone $user_timezone - ad_conn -set user_id $org_user_id - } + } finally { + lang::system::set_timezone $system_timezone + lang::user::set_timezone $user_timezone + ad_conn -set user_id $org_user_id } } aa_register_case \ -procs { lang::conn::timezone lang::system::timezone - lang::system::timezone_support_p lang::user::set_timezone } set_timezone_not_logged_in { Test that setting and getting user timezone throws an error when user is not logged in } { - # We cannot test timezones if they are not installed - if { [lang::system::timezone_support_p] } { + set user_id [ad_conn user_id] - set user_id [ad_conn user_id] + ad_conn -set user_id 0 + aa_equals "Fallback to system timezone when no user" \ + [lang::conn::timezone] \ + [lang::system::timezone] - ad_conn -set user_id 0 - aa_equals "Fallback to system timezone when no user" \ - [lang::conn::timezone] \ - [lang::system::timezone] + set error_p [catch { lang::user::set_timezone [lang::system::timezone] } errmsg] + aa_true "Error when setting user timezone when user not logged in" $error_p - set error_p [catch { lang::user::set_timezone [lang::system::timezone] } errmsg] - aa_true "Error when setting user timezone when user not logged in" $error_p - - # Reset the user_id - ad_conn -set user_id $user_id - } + # Reset the user_id + ad_conn -set user_id $user_id } aa_register_case \ Index: openacs-4/packages/acs-lang/www/change-locale-include.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/change-locale-include.tcl,v diff -u -r1.19.2.4 -r1.19.2.5 --- openacs-4/packages/acs-lang/www/change-locale-include.tcl 11 Dec 2019 18:13:56 -0000 1.19.2.4 +++ openacs-4/packages/acs-lang/www/change-locale-include.tcl 8 Feb 2023 15:25:31 -0000 1.19.2.5 @@ -12,7 +12,7 @@ # check for package level locale support set package_level_locales_p [expr {[lang::system::use_package_level_locales_p] && $package_id ne "" && [ad_conn user_id] != 0}] # check for timezone setting support -set use_timezone_p [expr {[lang::system::timezone_support_p] && [ad_conn user_id]}] +set use_timezone_p [expr {[ad_conn user_id] != 0}] # Create a list of lists containing the possible locale choiches set list_of_locales [list] Index: openacs-4/packages/acs-lang/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/index.adp,v diff -u -r1.23.2.4 -r1.23.2.5 --- openacs-4/packages/acs-lang/www/admin/index.adp 15 Jul 2022 08:36:57 -0000 1.23.2.4 +++ openacs-4/packages/acs-lang/www/admin/index.adp 8 Feb 2023 15:25:31 -0000 1.23.2.5 @@ -14,10 +14,7 @@
  • #acs-lang.Change_system_locale#: #acs-lang.Current_system_locale_is#
  • - -
  • #acs-lang.Change_system_timezone#: #acs-lang.Current_system_timezone_is#
  • -
  • #acs-lang.Look_up_message#
  • #acs-lang.Edit_history#
  • Index: openacs-4/packages/acs-lang/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/index.tcl,v diff -u -r1.15.2.9 -r1.15.2.10 --- openacs-4/packages/acs-lang/www/admin/index.tcl 21 Nov 2022 09:47:00 -0000 1.15.2.9 +++ openacs-4/packages/acs-lang/www/admin/index.tcl 8 Feb 2023 15:25:31 -0000 1.15.2.10 @@ -32,7 +32,6 @@ # Timezones # set timezone [lang::system::timezone] -set timezone_p [lang::system::timezone_support_p] # # URLs # Index: openacs-4/packages/acs-lang/www/admin/set-system-timezone.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/set-system-timezone.tcl,v diff -u -r1.14.2.2 -r1.14.2.3 --- openacs-4/packages/acs-lang/www/admin/set-system-timezone.tcl 3 May 2020 17:22:20 -0000 1.14.2.2 +++ openacs-4/packages/acs-lang/www/admin/set-system-timezone.tcl 8 Feb 2023 15:25:31 -0000 1.14.2.3 @@ -13,12 +13,6 @@ utc_ansi } -if { ![lang::system::timezone_support_p] } { - ad_return_error "Timezone support not installed" \ - "This installation of the acs-lang package does not support timezone settings. The ref-timezones package needs to be installed first" - ad_script_abort -} - if { $timezone_recommended ne "" } { lang::system::set_timezone $timezone_recommended } elseif { $timezone_all ne "" } {