--- loncom/interface/lonpreferences.pm 2022/09/19 19:49:26 1.196.4.28.2.1 +++ loncom/interface/lonpreferences.pm 2024/07/04 23:13:07 1.196.4.29 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.196.4.28.2.1 2022/09/19 19:49:26 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.196.4.29 2024/07/04 23:13:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,6 +31,7 @@ package Apache::lonpreferences; use strict; +use LONCAPA; use Apache::Constants qw(:common); use Apache::File; use Apache::loncommon(); @@ -39,7 +40,6 @@ use Apache::lonlocal; use Apache::lonnet; use LONCAPA::lonauthcgi(); use LONCAPA(); -use DateTime::TimeZone(); ################################################################ # Handler subroutines # @@ -2183,120 +2183,6 @@ sub verify_and_change_lockednames { &print_main_menu($r,$message); } -sub timezonechanger { - my $r = shift; - my $uname = $env{'user.name'}; - my $udom = $env{'user.domain'}; - if (&Apache::lonnet::usertools_access($uname,$udom,'timezone')) { - my $js = <<"ENDSCRIPT"; - -ENDSCRIPT - my %loaditems = ( - onload => 'javascript:toggleTZdisplay(document.prefs);', - ); - my $args = { 'add_entries' => \%loaditems }; - &Apache::lonhtmlcommon::add_breadcrumb( - { href => '/adm/preferences?action=', - text => 'Set Your Time Zone'}); - $r->print(Apache::loncommon::start_page('Set Your Time Zone',$js,$args)); - $r->print(Apache::lonhtmlcommon::breadcrumbs('Set Your Time Zone')); - my %userenv = &Apache::lonnet::get('environment',['timezone']); - my $timezone = $userenv{'timezone'}; - my %lt = &Apache::lonlocal::texthash( - lctz => 'Use Time Zone set by LON-CAPA', - owntz => 'Use Time Zone set by you', - save => 'Save', - ); - my (%checked,$tzsty); - if ($userenv{'timezone'} ne '') { - $checked{'owntz'} = ' checked="checked"'; - $tzsty = 'inline-block'; - } else { - $checked{'lctz'} = ' checked="checked"'; - $tzsty = 'none'; - } - my $onclick = ' onclick="javascript:toggleTZdisplay(this.form);"'; - my $selector = &Apache::loncommon::select_timezone('timezone',$timezone,undef,1); - $r->print(<<"END"); -
-END - } - return; -} - -sub verify_and_change_timezone { - my $r = shift; - my $currtimezone = $env{'environment.timezone'}; - my $newtimezone; - if ($env{'form.settimezone'}) { - $newtimezone = $env{'form.timezone'}; - if (DateTime::TimeZone->is_valid_name($env{'form.timezone'})) { - $newtimezone = $env{'form.timezone'}; - } - } - my $message=''; - if ($newtimezone) { - if ($newtimezone eq $currtimezone) { - $message = &mt('Time Zone settings unchanged'); - } else { - &Apache::lonnet::put('environment',{'timezone' => $newtimezone}); - &Apache::lonnet::appenv({'environment.timezone' => $newtimezone}); - $message=&Apache::lonhtmlcommon::confirm_success( - &mt('Set [_1] to [_2]', - ''.&mt('Your Time Zone').'', - '"'.$newtimezone.'".')). - '