--- loncom/auth/lonroles.pm 2010/09/02 17:08:28 1.256.2.4 +++ loncom/auth/lonroles.pm 2010/08/24 13:18:26 1.258 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.256.2.4 2010/09/02 17:08:28 raeburn Exp $ +# $Id: lonroles.pm,v 1.258 2010/08/24 13:18:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -57,8 +57,7 @@ course they should act on, etc. Both in handler determines via C's C<&allowed> function that a certain action is not allowed, C is used as error handler. This allows the user to select another role which may have permission to do -what they were trying to do. C can also be accessed via the -B button in the Remote Control. +what they were trying to do. =begin latex @@ -142,22 +141,14 @@ use Apache::loncoursequeueadmin; use GDBM_File; use LONCAPA qw(:DEFAULT :match); use HTML::Entities; - + sub redirect_user { - my ($r,$title,$url,$msg,$launch_nav) = @_; + my ($r,$title,$url,$msg) = @_; $msg = $title if (! defined($msg)); &Apache::loncommon::content_type($r,'text/html'); &Apache::loncommon::no_cache($r); $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig(); - my $navwindow; - if ($launch_nav eq 'on') { - $navwindow.=&Apache::lonnavdisplay::launch_win('now',undef,undef, - ($url =~ m-^/adm/whatsnew-)); - } else { - $navwindow.=&Apache::lonnavmaps::close(); - } # Breadcrumbs my $brcrum = [{'href' => $url, @@ -172,12 +163,6 @@ sub redirect_user { $url=~s/ /\%20/g; $r->print(< -// - -$navwindow

$msg

$end_page ENDREDIR @@ -557,8 +542,7 @@ ENDENTERKEY } &redirect_user($r, &mt('Entering [_1]', $env{'course.'.$courseid.'.description'}), - $dest, $msg, - $env{'environment.remotenavmap'}); + $dest, $msg); return OK; } if (&Apache::lonnet::allowed('whn', @@ -571,9 +555,8 @@ ENDENTERKEY unless ($startpage eq 'firstres') { $msg = &mt('Entering [_1] ...', $env{'course.'.$courseid.'.description'}); - &redirect_user($r,&mt('New in course'), - '/adm/whatsnew?refpage=start',$msg, - $env{'environment.remotenavmap'}); + &redirect_user($r, &mt('New in course'), + '/adm/whatsnew?refpage=start', $msg); return OK; } } @@ -585,10 +568,9 @@ ENDENTERKEY } $msg = &mt('Entering [_1] ...', $env{'course.'.$courseid.'.description'}); - &redirect_user($r,&mt('Entering [_1]', - $env{'course.'.$courseid.'.description'}), - $furl,$msg, - $env{'environment.remotenavmap'}); + &redirect_user($r, &mt('Entering [_1]', + $env{'course.'.$courseid.'.description'}), + $furl, $msg); } return OK; } @@ -748,7 +730,6 @@ ENDHEADER $r->print(''); $r->print(''); } - $r->rflush(); my (%roletext,%sortrole,%roleclass,%futureroles,%timezones); my ($countactive,$countfuture,$inrole,$possiblerole) = @@ -864,16 +845,12 @@ ENDHEADER } elsif ($numdc > 0) { unless ($role =~/^error\:/) { my ($roletext,$role_text_end) = &display_cc_role('user.role.'.$role); - 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(); - } - } + $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(); } } } @@ -954,9 +931,16 @@ 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'; } @@ -965,13 +949,6 @@ 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; @@ -1055,12 +1032,10 @@ sub gather_roles { ''; unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') { my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'}; - if ($required ne '') { - ($switchserver,$switchwarning) = - &check_release_required($loncaparev,$tcourseid,$trolecode,$required); - if ($switchserver || $switchwarning) { - $button = 0; - } + ($switchserver,$switchwarning) = + &check_release_required($loncaparev,$tcourseid,$trolecode,$required); + if ($switchserver || $switchwarning) { + $button = 0; } } } @@ -1078,12 +1053,10 @@ sub gather_roles { my $home = $newhash{'home'}; unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') { my $required = $newhash{'internal.releaserequired'}; - if ($required ne '') { - ($switchserver,$switchwarning) = - &check_release_required($loncaparev,$tcourseid,$trolecode,$required); - if ($switchserver || $switchwarning) { - $button = 0; - } + ($switchserver,$switchwarning) = + &check_release_required($loncaparev,$tcourseid,$trolecode,$required); + if ($switchserver || $switchwarning) { + $button = 0; } } } else { @@ -1129,15 +1102,9 @@ sub role_timezone { my $cnum = $2; if ($cdom && $cnum) { if (!exists($timezones->{$cdom.'_'.$cnum})) { - 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 '') { + 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); @@ -1150,7 +1117,7 @@ sub role_timezone { $timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom}; } else { $timezones->{$cdom.'_'.$cnum} = - &Apache::lonlocal::gettimezone($tz); + &Apache::lonlocal::gettimezone($timehash{'timezone'}); } } $timezone = $timezones->{$cdom.'_'.$cnum}; @@ -1847,8 +1814,7 @@ course they should act on, etc. Both in handler determines via C's C<&allowed> function that a certain action is not allowed, C is used as error handler. This allows the user to select another role which may have permission to do -what they were trying to do. C can also be accessed via the -B button in the Remote Control. +what they were trying to do. =begin latex