--- loncom/auth/lonroles.pm 2005/03/03 07:16:44 1.116 +++ loncom/auth/lonroles.pm 2005/06/16 22:25:34 1.124 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.116 2005/03/03 07:16:44 albertel Exp $ +# $Id: lonroles.pm,v 1.124 2005/06/16 22:25:34 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,7 +30,7 @@ package Apache::lonroles; use strict; -use Apache::lonnet(); +use Apache::lonnet; use Apache::lonuserstate(); use Apache::Constants qw(:common); use Apache::File(); @@ -39,6 +39,7 @@ use Apache::loncommon; use Apache::lonhtmlcommon; use Apache::lonannounce; use Apache::lonlocal; +use GDBM_File; sub redirect_user { my ($r,$title,$url,$msg,$launch_nav) = @_; @@ -80,29 +81,29 @@ sub handler { my $r = shift; my $now=time; - my $then=$ENV{'user.login.time'}; + my $then=$env{'user.login.time'}; my $envkey; my %dcroles = (); my $numdc = &check_fordc(\%dcroles,$then); # ================================================================== Roles Init - if ($ENV{'form.selectrole'}) { - if ($ENV{'request.course.id'}) { - my %temp=('logout_'.$ENV{'request.course.id'} => time); + if ($env{'form.selectrole'}) { + if ($env{'request.course.id'}) { + my %temp=('logout_'.$env{'request.course.id'} => time); &Apache::lonnet::put('email_status',\%temp); - &Apache::lonnet::delenv('user.state.'.$ENV{'request.course.id'}); + &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'}); } &Apache::lonnet::appenv("request.course.id" => '', "request.course.fn" => '', "request.course.uri" => '', "request.course.sec" => '', "request.role" => 'cm', - "request.role.adv" => $ENV{'user.adv'}, - "request.role.domain" => $ENV{'user.domain'}); + "request.role.adv" => $env{'user.adv'}, + "request.role.domain" => $env{'user.domain'}); # Check if user is a DC trying to enter a course and needs privs to be created if ($numdc > 0) { - foreach my $envkey (keys %ENV) { + foreach my $envkey (keys %env) { if ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-) { if ($dcroles{$1}) { my $cckey = 'user.role.cc./'.$1.'/'.$2; @@ -113,16 +114,16 @@ sub handler { } } - foreach $envkey (keys %ENV) { + foreach $envkey (keys %env) { next if ($envkey!~/^user\.role\./); my ($where,$trolecode,$role,$tstatus,$tend,$tstart); &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); - if ($ENV{'form.'.$trolecode}) { + if ($env{'form.'.$trolecode}) { if ($tstatus eq 'is') { $where=~s/^\///; my ($cdom,$cnum,$csec)=split(/\//,$where); # store role if recent_role list being kept - if ($ENV{'environment.recentroles'}) { + if ($env{'environment.recentroles'}) { &Apache::lonhtmlcommon::store_recent('roles', $trolecode,' '); } @@ -130,20 +131,20 @@ sub handler { # check for keyed access if (($role eq 'st') && - ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { + ($env{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { # who is key authority? my $authdom=$cdom; my $authnum=$cnum; - if ($ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'}) { + if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) { ($authnum,$authdom)= - split(/\W/,$ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'}); + split(/\W/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'}); } # check with key authority unless (&Apache::lonnet::validate_access_key( - $ENV{'environment.key.'.$cdom.'_'.$cnum}, + $env{'environment.key.'.$cdom.'_'.$cnum}, $authdom,$authnum)) { # there is no valid key - if ($ENV{'form.newkey'}) { + if ($env{'form.newkey'}) { # student attempts to register a new key &Apache::loncommon::content_type($r,'text/html'); &Apache::loncommon::no_cache($r); @@ -155,11 +156,11 @@ sub handler { my $message=&mt('Successfully registered key'); my $assignresult= &Apache::lonnet::assign_access_key( - $ENV{'form.newkey'}, + $env{'form.newkey'}, $authdom,$authnum, $cdom,$cnum, - $ENV{'user.domain'}, - $ENV{'user.name'}, + $env{'user.domain'}, + $env{'user.name'}, 'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '. $trolecode); unless ($assignresult eq 'ok') { @@ -205,7 +206,7 @@ $swinfo