--- loncom/auth/lonroles.pm 2000/09/06 14:25:17 1.5 +++ loncom/auth/lonroles.pm 2000/09/30 19:19:34 1.8 @@ -4,12 +4,14 @@ # (Login Screen # 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 Gerd Kortemeyer +# 1/14,03/06,06/01,07/22,07/24,07/25, +# 09/04,09/06,09/28,09/29,09/30 Gerd Kortemeyer # package Apache::lonroles; use strict; use Apache::lonnet(); +use Apache::lonuserstate(); use Apache::Constants qw(:common); use Apache::File(); @@ -28,14 +30,68 @@ sub handler {
ENDHEADER + my $now=time; + my $then=$ENV{'user.login.time'}; + my $envkey; + +# ================================================================== Roles Init + + if ($ENV{'form.selectrole'}) { + foreach $envkey (keys %ENV) { + if ($envkey=~/^user\.role\./) { + my ($dum1,$dum2,$role,@pwhere)=split(/\./,$envkey); + my $where=join('.',@pwhere); + my $trolecode=$role.'.'.$where; + if ($ENV{'form.'.$trolecode}) { + my ($tstart,$tend)=split(/\./,$ENV{$envkey}); + my $tstatus='is'; + if ($tstart) { + if ($tstart>$then) { + $tstatus='future'; + } + } + if ($tend) { + if ($tend<$then) { $tstatus='expired'; } + if ($tend>$now) { $tstatus='will_not'; } + } + if ($tstatus eq 'is') { + &Apache::lonnet::appenv('request.role' => $trolecode); + my ($cdom,$cnum)=split(/\//,$where); + if ($cnum) { + $r->print( &Apache::lonuserstate::readmap($where) ); + } + } + } + } + } + + $r->print('