[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /lonnet/perl lonnet.pm
www
lon-capa-cvs@mail.lon-capa.org
Sun, 23 Mar 2003 01:46:51 -0000
www Sat Mar 22 20:46:51 2003 EDT
Modified files:
/loncom/auth lonroles.pm
/loncom/lonnet/perl lonnet.pm
Log:
Continued work on access keys
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.52 loncom/auth/lonroles.pm:1.53
--- loncom/auth/lonroles.pm:1.52 Thu Feb 13 13:11:26 2003
+++ loncom/auth/lonroles.pm Sat Mar 22 20:46:51 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.52 2003/02/13 18:11:26 www Exp $
+# $Id: lonroles.pm,v 1.53 2003/03/23 01:46:51 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -93,6 +93,41 @@
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(<<ENDENTERKEY);
+<head><title>Entering Course Access Key</title>
+</head>
+<html>
+$bodytag
+<script>
+$swinfo
+</script>
+<form method="post">
+<input type="hidden" name="selectrole" value="$ENV{'form.selectrole'}" />
+<input type="text" size="20" name="newkey" value="$ENV{'form.newkey'}" />
+<input type="submit" value="Enter key" />
+</form>
+</body></html>
+ENDENTERKEY
+ }
+ }
+ }
&Apache::lonnet::appenv('request.role' => $trolecode,
'request.role.domain' => $cdom,
'request.course.sec' => $csec);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.345 loncom/lonnet/perl/lonnet.pm:1.346
--- loncom/lonnet/perl/lonnet.pm:1.345 Sat Mar 22 16:23:35 2003
+++ loncom/lonnet/perl/lonnet.pm Sat Mar 22 20:46:51 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.345 2003/03/22 21:23:35 www Exp $
+# $Id: lonnet.pm,v 1.346 2003/03/23 01:46:51 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -607,7 +607,7 @@
} elsif (!$existing{$ckey}) {
if (&put('accesskey',{$ckey=>$udom.':'.$uname},$cdom,$cnum) eq 'ok') {
# key now belongs to user
- my $envkey='key.'.$cdom.'.'.$cnum;
+ my $envkey='key.'.$cdom.'_'.$cnum;
if (&put('environment',{$envkey => $ckey}) eq 'ok') {
&appenv('environment.'.$envkey => $ckey);
return 'ok';