--- loncom/auth/lonroles.pm 2010/08/26 04:43:10 1.256.2.3
+++ loncom/auth/lonroles.pm 2010/09/02 17:08:28 1.256.2.4
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.256.2.3 2010/08/26 04:43:10 raeburn Exp $
+# $Id: lonroles.pm,v 1.256.2.4 2010/09/02 17:08:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -142,7 +142,7 @@ use Apache::loncoursequeueadmin;
use GDBM_File;
use LONCAPA qw(:DEFAULT :match);
use HTML::Entities;
-
+
sub redirect_user {
my ($r,$title,$url,$msg,$launch_nav) = @_;
@@ -748,6 +748,7 @@ ENDHEADER
$r->print('');
$r->print('');
}
+ $r->rflush();
my (%roletext,%sortrole,%roleclass,%futureroles,%timezones);
my ($countactive,$countfuture,$inrole,$possiblerole) =
@@ -863,12 +864,16 @@ ENDHEADER
} elsif ($numdc > 0) {
unless ($role =~/^error\:/) {
my ($roletext,$role_text_end) = &display_cc_role('user.role.'.$role);
- $output.= &Apache::loncommon::start_data_table_row().
- $roletext.
- &Apache::loncommon::end_data_table_row().
- &Apache::loncommon::continue_data_table_row().
- $role_text_end.
- &Apache::loncommon::end_data_table_row();
+ if ($roletext) {
+ $output.= &Apache::loncommon::start_data_table_row().
+ $roletext.
+ &Apache::loncommon::end_data_table_row();
+ if ($role_text_end) {
+ $output .= &Apache::loncommon::continue_data_table_row().
+ $role_text_end.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
}
}
}
@@ -949,16 +954,9 @@ sub gather_roles {
&Apache::lonnet::role_status($envkey,$then,$refresh,$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,$timezone);
- }
- if ($tend) {
- $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
- }
if ($env{'request.role'} eq $trolecode) {
$tstatus='selected';
}
@@ -967,6 +965,13 @@ sub gather_roles {
|| ($tstatus eq 'selected')
|| ($tstatus eq 'future')
|| ($env{'form.showall'})) {
+ my $timezone = &role_timezone($where,$timezones);
+ if ($tstart) {
+ $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
+ }
+ if ($tend) {
+ $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
+ }
if ($tstatus eq 'is') {
$tbg='LC_roles_is';
$possiblerole=$trolecode;
@@ -1050,10 +1055,12 @@ sub gather_roles {
'';
unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
- ($switchserver,$switchwarning) =
- &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
- if ($switchserver || $switchwarning) {
- $button = 0;
+ if ($required ne '') {
+ ($switchserver,$switchwarning) =
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ if ($switchserver || $switchwarning) {
+ $button = 0;
+ }
}
}
}
@@ -1071,10 +1078,12 @@ sub gather_roles {
my $home = $newhash{'home'};
unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
my $required = $newhash{'internal.releaserequired'};
- ($switchserver,$switchwarning) =
- &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
- if ($switchserver || $switchwarning) {
- $button = 0;
+ if ($required ne '') {
+ ($switchserver,$switchwarning) =
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ if ($switchserver || $switchwarning) {
+ $button = 0;
+ }
}
}
} else {
@@ -1120,9 +1129,15 @@ sub role_timezone {
my $cnum = $2;
if ($cdom && $cnum) {
if (!exists($timezones->{$cdom.'_'.$cnum})) {
- my %timehash =
- &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum);
- if ($timehash{'timezone'} eq '') {
+ my $tz;
+ if ($env{'course.'.$cdom.'_'.$cnum.'.description'}) {
+ $tz = $env{'course.'.$cdom.'_'.$cnum.'.timezone'};
+ } else {
+ my %timehash =
+ &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum);
+ $tz = $timehash{'timezone'};
+ }
+ if ($tz eq '') {
if (!exists($timezones->{$cdom})) {
my %domdefaults =
&Apache::lonnet::get_domain_defaults($cdom);
@@ -1135,7 +1150,7 @@ sub role_timezone {
$timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom};
} else {
$timezones->{$cdom.'_'.$cnum} =
- &Apache::lonlocal::gettimezone($timehash{'timezone'});
+ &Apache::lonlocal::gettimezone($tz);
}
}
$timezone = $timezones->{$cdom.'_'.$cnum};