--- loncom/auth/lonroles.pm 2003/08/05 12:52:23 1.65
+++ loncom/auth/lonroles.pm 2004/05/08 16:26:32 1.90
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.65 2003/08/05 12:52:23 www Exp $
+# $Id: lonroles.pm,v 1.90 2004/05/08 16:26:32 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,20 +25,6 @@
#
# http://www.lon-capa.org/
#
-# (Directory Indexer
-# (Login Screen
-# YEAR=1999
-# 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)
-# YEAR=2000
-# 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,10/28,
-# 12/08,12/28,
-# YEAR=2001
-# 01/15/01 Gerd Kortemeyer
-# 03/02,05/03,05/25,05/30,06/01,07/06,08/06 Gerd Kortemeyer
-# 12/29 Gerd Kortemeyer
-#
###
package Apache::lonroles;
@@ -51,11 +37,12 @@ use Apache::File();
use Apache::lonmenu;
use Apache::loncommon;
use Apache::lonannounce;
+use Apache::lonlocal;
sub redirect_user {
my ($r,$title,$url,$msg) = @_;
$msg = $title if (! defined($msg));
- $r->content_type('text/html');
+ &Apache::loncommon::content_type($r,'text/html');
&Apache::loncommon::no_cache($r);
$r->send_http_header;
my $swinfo=&Apache::lonmenu::rawconfig();
@@ -122,15 +109,63 @@ 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,
+ $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
+
+
+