--- loncom/auth/lonroles.pm 2000/10/26 18:54:11 1.13 +++ loncom/auth/lonroles.pm 2001/02/27 20:44:18 1.22 @@ -5,8 +5,11 @@ # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14 Gerd Kortemeyer) # 11/23 Gerd Kortemeyer) # 1/14,03/06,06/01,07/22,07/24,07/25, -# 09/04,09/06,09/28,09/29,09/30,10/2,10/5,10/26 Gerd Kortemeyer -# +# 09/04,09/06,09/28,09/29,09/30,10/2,10/5,10/26,10/28, +# 12/08,12/28, +# 01/15/01 Gerd Kortemeyer +# 02/27/01 Scott Harrison + package Apache::lonroles; use strict; @@ -47,25 +50,41 @@ sub handler { } if ($tend) { if ($tend<$then) { $tstatus='expired'; } - if ($tend>$now) { $tstatus='will_not'; } + if ($tend<$now) { $tstatus='will_not'; } } if ($tstatus eq 'is') { $where=~s/^\///; my ($cdom,$cnum,$csec)=split(/\//,$where); &Apache::lonnet::appenv('request.role' => $trolecode, - 'request.sec' => $csec); + 'request.course.sec' => $csec); if ($cnum) { - &Apache::lonuserstate::readmap($cdom.'/'.$cnum); - if ($ENV{'form.orgurl'}) { + my ($furl,$ferr)= + &Apache::lonuserstate::readmap($cdom.'/'.$cnum); + if (($ENV{'form.orgurl'}) && + ($ENV{'form.orgurl'}!~/^\/adm\/flip/)) { $r->internal_redirect($ENV{'form.orgurl'}); return OK; - } + } else { + $r->content_type('text/html'); + $r->send_http_header; + print (<Entering Course + + + + +Entering course ... + + +ENDREDIR + return OK; + } } } } } } - } + } # =============================================================== No Roles Init @@ -79,6 +98,7 @@ sub handler { LON-CAPA User Roles + ENDHEADER # ------------------------------------------ Get Error Message from Environment @@ -99,10 +119,6 @@ ENDHEADER } } -# ---------------------------------------------- Get cached course descriptions - - my %cdes=Apache::lonnet::dump('nohist_coursedescriptions'); - # -------------------------------------------------------- Generate Page Output # --------------------------------------------------------------- Error Header? if ($error) { @@ -134,6 +150,9 @@ ENDHEADER } else { $r->print("

Enter a Course

\n"); } + if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { + $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; + } $r->print('
'); $r->print(''); $r->print(''); @@ -141,12 +160,8 @@ ENDHEADER # ----------------------------------------------------------------------- Table $r->print(''); unless ($nochoose) { $r->print(''); } - if ($advanced) { $r->print(''. ''."\n"); - } else { - $r->print(''."\n"); - } foreach $envkey (sort keys %ENV) { if ($envkey=~/^user\.role\./) { @@ -167,7 +182,7 @@ ENDHEADER } if ($tend) { if ($tend<$then) { $tstatus='expired'; } - if ($tend>$now) { $tstatus='will_not'; } + if ($tend<$now) { $tstatus='will_not'; } $tpend=localtime($tend); } if ($ENV{'request.role'} eq $trolecode) { @@ -187,7 +202,7 @@ ENDHEADER $tbg='#AAFF77'; $tremark.='Expired after logout. '; } elsif ($tstatus eq 'selected') { - $tbg='#33FF33'; + $tbg='#11CC55'; $tremark.='Currently selected. '; } my $trole; @@ -207,17 +222,17 @@ ENDHEADER if ($tsection) { $ttype.='
Section/Group: '.$tsection; } - my $tcourseid=$tdom.'/'.$trest; - if ($cdes{$tcourseid}) { - $twhere=$cdes{$tcourseid}; + my $tcourseid=$tdom.'_'.$trest; + if ($ENV{'course.'.$tcourseid.'.description'}) { + $twhere=$ENV{'course.'.$tcourseid.'.description'}; } else { my %newhash=Apache::lonnet::coursedescription($tcourseid); if (%newhash) { $twhere=$newhash{'description'}; } else { $twhere='Currently not available'; + $ENV{'course.'.$tcourseid.'.description'}=$twhere; } - $cdes{$tcourseid}=$twhere; } } elsif ($tdom) { $ttype='Domain'; @@ -242,26 +257,45 @@ ENDHEADER ''."\n"); } } + my $tremark=''; + if ($ENV{'request.role'} eq 'cm') { + $r->print(''); + $tremark='Currently selected.'; + } else { + $r->print(''); + } + unless ($nochoose) { + if ($ENV{'request.role'} ne 'cm') { + $r->print(''); + } else { + $r->print(''); + } + } + $r->print(''."\n"); $r->print('
 User RoleExtentStartEndRemark
Course
'.$tremark.' 
 No role specified'. + ''.$tremark.' 
'); unless ($nochoose) { $r->print("
\n"); } -# ------------------------------------------------------------ Priviledges Info +# ------------------------------------------------------------ Privileges Info if ($advanced) { - $r->print('

Priviledges

'); + $r->print('

Current Privileges

'); foreach $envkey (sort keys %ENV) { - if ($envkey=~/^user\.priv\./) { - my ($dum1,$dum2,@pwhere)=split(/\./,$envkey); - my $where=join('.',@pwhere); + if ($envkey=~/^user\.priv\.$ENV{'request.role'}\./) { + my $where=$envkey; + $where=~s/^user\.priv\.$ENV{'request.role'}\.//; my $ttype; my $twhere; - my ($tdom,$trest)= + my ($tdom,$trest,$tsec)= split(/\//,Apache::lonnet::declutter($where)); if ($trest) { $ttype='Course'; - $twhere=$cdes{$tdom.'/'.$trest}; + $twhere=$ENV{'course.'.$tdom.'_'.$trest.'.description'}; + if ($tsec) { + $twhere.=' (Section/Group: '.$tsec.')'; + } } elsif ($tdom) { $ttype='Domain'; $twhere=$tdom; @@ -292,15 +326,6 @@ ENDHEADER } } } -# -------------------------------------------------------------- Debug - remove - - $->print("

Debugging


\n"); - - foreach $envkey (sort keys %ENV) { - $r->print("$envkey ---- $ENV{$envkey}
"); - } - -# ------------------------------------------------------------------- End Debug $r->print("\n"); return OK;