--- loncom/auth/lonroles.pm 2004/02/19 21:45:22 1.86 +++ loncom/auth/lonroles.pm 2004/08/03 18:55:46 1.94.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.86 2004/02/19 21:45:22 albertel Exp $ +# $Id: lonroles.pm,v 1.94.2.1 2004/08/03 18:55:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,7 +47,10 @@ sub redirect_user { $r->send_http_header; my $swinfo=&Apache::lonmenu::rawconfig(); my $bodytag=&Apache::loncommon::bodytag('Switching Role'); - $r->print (<print(<$title @@ -109,12 +112,61 @@ sub handler { # check for keyed access if (($role eq 'st') && ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { - unless (&Apache::lonnet::validate_access_key( +# who is key authority? + my $authdom=$cdom; + my $authnum=$cnum; + if ($ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'}) { + ($authnum,$authdom)= + split(/\W/,$ENV{'course.'.$cdom.'_'.$cnum.'.keyauth'}); + } +# check with key authority + unless (&Apache::lonnet::validate_access_key( $ENV{'environment.key.'.$cdom.'_'.$cnum}, - $cdom,$cnum)) { + $authdom,$authnum)) { # there is no valid key if ($ENV{'form.newkey'}) { # student attempts to register a new key + &Apache::loncommon::content_type($r,'text/html'); + &Apache::loncommon::no_cache($r); + $r->send_http_header; + my $swinfo=&Apache::lonmenu::rawconfig(); + my $bodytag=&Apache::loncommon::bodytag + ('Verifying Access Key to Unlock this Course'); + my $buttontext=&mt('Enter Course'); + my $message=&mt('Successfully registered key'); + my $assignresult= + &Apache::lonnet::assign_access_key( + $ENV{'form.newkey'}, + $authdom,$authnum, + $cdom,$cnum, + $ENV{'user.domain'}, + $ENV{'user.name'}, + 'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '. + $trolecode); + unless ($assignresult eq 'ok') { + $assignresult=~s/^error\:\s*//; + $message=&mt($assignresult). + '
'. + &mt('Logout').''; + $buttontext=&mt('Re-Enter Key'); + } + $r->print(<Verifying Course Access Key + + +$bodytag + +
+ + +$message
+ +
+ +ENDENTEREDKEY + return OK; } else { # print form to enter a new key &Apache::loncommon::content_type($r,'text/html'); @@ -132,7 +184,8 @@ $bodytag $swinfo
- + +
@@ -142,6 +195,10 @@ ENDENTERKEY } } } + &Apache::lonnet::log($ENV{'user.domain'}, + $ENV{'user.name'}, + $ENV{'user.home'}, + "Role ".$trolecode); my $tadv=0; if (($trolecode!~/^st/) && ($trolecode!~/^ta/) && @@ -223,10 +280,7 @@ ENDENTERKEY my $swinfo=&Apache::lonmenu::rawconfig(); my $bodytag=&Apache::loncommon::bodytag('User Roles'); - my $helptag='
'.&Apache::loncommon::help_open_topic - ("General_Intro",&mt("Click here for help")).''. - &Apache::loncommon::help_open_faq(1,&mt('Click here for FAQ')).''. - &Apache::loncommon::help_open_bug('',&mt('Click here to report bugs')).'
'; + my $helptag='
'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'
'; $r->print(< @@ -398,7 +452,7 @@ ENDHEADER $Apache::lonnet::hostname{$home}. '/adm/login?domain='.$ENV{'user.domain'}. '&username='.$ENV{'user.name'}. - '&firsturl=/priv/'.$trest); + '&firsturl=/priv/'.$trest.'/'); } #next if ($home eq 'no_host'); $home = $Apache::lonnet::hostname{$home}; @@ -422,7 +476,7 @@ ENDHEADER $Apache::lonnet::hostname{$home}. '/adm/login?domain='.$ENV{'user.domain'}. '&username='.$ENV{'user.name'}. - '&firsturl=/priv/'.$ENV{'user.name'}); + '&firsturl=/priv/'.$ENV{'user.name'}.'/'); } #next if ($home eq 'no_host'); $home = $Apache::lonnet::hostname{$home}; @@ -525,7 +579,7 @@ ENDHEADER $r->print(''); return OK; # Is there only one choice? - } elsif ($countactive==1) { + } elsif (($countactive==1) && ($ENV{'request.role'} eq 'cm')) { $r->print('

'.&mt('Please stand by.').'

'. ''); $r->print("\n");