[LON-CAPA-cvs] cvs: loncom(version_2_8_X) /auth lonroles.pm
raeburn
raeburn@source.lon-capa.org
Mon, 05 Jan 2009 16:50:02 -0000
raeburn Mon Jan 5 16:50:02 2009 EDT
Modified files: (Branch: version_2_8_X)
/loncom/auth lonroles.pm
Log:
- Backport 1.215.
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.209 loncom/auth/lonroles.pm:1.209.2.1
--- loncom/auth/lonroles.pm:1.209 Mon Oct 20 03:25:48 2008
+++ loncom/auth/lonroles.pm Mon Jan 5 16:50:02 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.209 2008/10/20 03:25:48 raeburn Exp $
+# $Id: lonroles.pm,v 1.209.2.1 2009/01/05 16:50:02 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -548,6 +548,7 @@
my $possiblerole='';
my %futureroles;
my %roles_nextlogin;
+ my %timezones;
foreach $envkey (sort keys %env) {
my $button = 1;
my $switchserver='';
@@ -557,15 +558,16 @@
my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
&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=' ';
$tfont='#000000';
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';
@@ -833,6 +835,56 @@
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;