--- loncom/auth/lonroles.pm 2003/01/29 15:22:06 1.49 +++ loncom/auth/lonroles.pm 2003/03/24 14:45:09 1.54 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.49 2003/01/29 15:22:06 www Exp $ +# $Id: lonroles.pm,v 1.54 2003/03/24 14:45:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,9 +36,7 @@ # 12/08,12/28, # YEAR=2001 # 01/15/01 Gerd Kortemeyer -# 02/27/01 Scott Harrison # 03/02,05/03,05/25,05/30,06/01,07/06,08/06 Gerd Kortemeyer -# 12/21 Scott Harrison # 12/29 Gerd Kortemeyer # ### @@ -95,6 +93,42 @@ sub handler { if ($tstatus eq 'is') { $where=~s/^\///; my ($cdom,$cnum,$csec)=split(/\//,$where); +# check for keyed access + if (($role eq 'st') && + ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { + unless (&Apache::lonnet::validate_access_key( + $ENV{'environment.key.'.$cdom.'_'.$cnum}, + $cdom,$cnum)) { +# there is no valid key + if ($ENV{'form.newkey'}) { +# student attempts to register a new key + } else { +# print form to enter a new key + $r->content_type('text/html'); + &Apache::loncommon::no_cache($r); + $r->send_http_header; + my $swinfo=&Apache::lonmenu::rawconfig(); + my $bodytag=&Apache::loncommon::bodytag + ('Enter Access Key to Unlock this Course'); + $r->print(<Entering Course Access Key + + +$bodytag + +
+ + + +
+ +ENDENTERKEY + return OK; + } + } + } &Apache::lonnet::appenv('request.role' => $trolecode, 'request.role.domain' => $cdom, 'request.course.sec' => $csec); @@ -117,7 +151,7 @@ sub handler { $r->content_type('text/html'); &Apache::loncommon::no_cache($r); $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig($r); + my $swinfo=&Apache::lonmenu::rawconfig(); my $bodytag=&Apache::loncommon::bodytag('Switching Role'); print (<Entering Course @@ -148,10 +182,10 @@ ENDREDIR $r->send_http_header; return OK if $r->header_only; - my $swinfo=&Apache::lonmenu::rawconfig($r); + my $swinfo=&Apache::lonmenu::rawconfig(); my $bodytag=&Apache::loncommon::bodytag('User Roles'); my $helptag=&Apache::loncommon::help_open_topic - ("General_Intro","CLICK HERE FOR HELP"); + ("General_Intro","Click here for help"); $r->print(< @@ -312,8 +346,11 @@ ENDHEADER my $home = &Apache::lonnet::homeserver($trest,$tdom); if ($home ne $r->dir_config('lonHostID')) { $button=0; - $switchserver='http://'. - $Apache::lonnet::hostname{$home}.'/priv/'.$trest; + $switchserver=&Apache::lonnet::escape('http://'. + $Apache::lonnet::hostname{$home}. + '/adm/login?domain='.$ENV{'user.domain'}. + '&username='.$ENV{'user.name'}. + '&firsturl=/priv/'.$trest); } #next if ($home eq 'no_host'); $home = $Apache::lonnet::hostname{$home}; @@ -327,9 +364,11 @@ ENDHEADER ($ENV{'user.name'},$ENV{'user.domain'}); if ($home ne $r->dir_config('lonHostID')) { $button=0; - $switchserver='http://'. - $Apache::lonnet::hostname{$home}.'/priv/'. - $ENV{'user.name'}; + $switchserver=&Apache::lonnet::escape('http://'. + $Apache::lonnet::hostname{$home}. + '/adm/login?domain='.$ENV{'user.domain'}. + '&username='.$ENV{'user.name'}. + '&firsturl=/priv/'.$ENV{'user.name'}); } #next if ($home eq 'no_host'); $home = $Apache::lonnet::hostname{$home};