--- loncom/auth/lonroles.pm 2008/12/15 16:37:53 1.214 +++ loncom/auth/lonroles.pm 2009/01/03 00:16:10 1.215 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.214 2008/12/15 16:37:53 raeburn Exp $ +# $Id: lonroles.pm,v 1.215 2009/01/03 00:16:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -646,6 +646,7 @@ ENDHEADER my $possiblerole=''; my %futureroles; my %roles_nextlogin; + my %timezones; foreach $envkey (sort keys %env) { my $button = 1; my $switchserver=''; @@ -655,14 +656,15 @@ ENDHEADER my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend); &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); next if (!defined($role) || $role eq '' || $role =~ /^gr/); + my $timezone = &role_timezone($where,\%timezones); $tremark=''; $tpstart=' '; $tpend=' '; if ($tstart) { - $tpstart=&Apache::lonlocal::locallocaltime($tstart); + $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone); } if ($tend) { - $tpend=&Apache::lonlocal::locallocaltime($tend); + $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone); } if ($env{'request.role'} eq $trolecode) { $tstatus='selected'; @@ -938,6 +940,56 @@ ENDHEADER return OK; } +sub role_timezone { + my ($where,$timezones) = @_; + my $timezone; + if (ref($timezones) eq 'HASH') { + if ($where =~ m{^/($match_domain)/($match_courseid)}) { + my $cdom = $1; + my $cnum = $2; + if ($cdom && $cnum) { + if (!exists($timezones->{$cdom.'_'.$cnum})) { + my %timehash = + &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum); + if ($timehash{'timezone'} eq '') { + if (!exists($timezones->{$cdom})) { + my %domdefaults = + &Apache::lonnet::get_domain_defaults($cdom); + if ($domdefaults{'timezone_def'} eq '') { + $timezones->{$cdom} = 'local'; + } else { + $timezones->{$cdom} = $domdefaults{'timezone_def'}; + } + } + $timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom}; + } else { + $timezones->{$cdom.'_'.$cnum} = + &Apache::lonlocal::gettimezone($timehash{'timezone'}); + } + } + $timezone = $timezones->{$cdom.'_'.$cnum}; + } + } else { + my ($tdom) = ($where =~ m{^/($match_domain)}); + if ($tdom) { + if (!exists($timezones->{$tdom})) { + my %domdefaults = &Apache::lonnet::get_domain_defaults($tdom); + if ($domdefaults{'timezone_def'} eq '') { + $timezones->{$tdom} = 'local'; + } else { + $timezones->{$tdom} = $domdefaults{'timezone_def'}; + } + } + $timezone = $timezones->{$tdom}; + } + } + if ($timezone eq 'local') { + $timezone = undef; + } + } + return $timezone; +} + sub roletable_headers { my ($r,$roleclass,$sortrole,$nochoose) = @_; my $doheaders;