version 1.85, 2004/01/31 00:46:45
|
version 1.92, 2004/05/21 19:16:35
|
Line 47 sub redirect_user {
|
Line 47 sub redirect_user {
|
$r->send_http_header; |
$r->send_http_header; |
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $swinfo=&Apache::lonmenu::rawconfig(); |
my $bodytag=&Apache::loncommon::bodytag('Switching Role'); |
my $bodytag=&Apache::loncommon::bodytag('Switching Role'); |
$r->print (<<ENDREDIR); |
# Note to style police: |
|
# This must only replace the spaces, nothing else, or it bombs elsewhere. |
|
$url=~s/ /\%20/g; |
|
$r->print (<<ENDREDIR); |
<head><title>$title</title> |
<head><title>$title</title> |
<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url"> |
<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url"> |
</head> |
</head> |
Line 109 sub handler {
|
Line 112 sub handler {
|
# check for keyed access |
# check for keyed access |
if (($role eq 'st') && |
if (($role eq 'st') && |
($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { |
($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}, |
$ENV{'environment.key.'.$cdom.'_'.$cnum}, |
$cdom,$cnum)) { |
$authdom,$authnum)) { |
# there is no valid key |
# there is no valid key |
if ($ENV{'form.newkey'}) { |
if ($ENV{'form.newkey'}) { |
# student attempts to register a new key |
# 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). |
|
'<br /><a href="/adm/logout">'. |
|
&mt('Logout').'</a>'; |
|
$buttontext=&mt('Re-Enter Key'); |
|
} |
|
$r->print(<<ENDENTEREDKEY); |
|
<head><title>Verifying Course Access Key</title> |
|
</head> |
|
<html> |
|
$bodytag |
|
<script> |
|
$swinfo |
|
</script> |
|
<form method="post"> |
|
<input type="hidden" name="selectrole" value="1" /> |
|
<input type="hidden" name="$trolecode" value="1" /> |
|
<font size="+2">$message</font><br /> |
|
<input type="submit" value="$buttontext" /> |
|
</form> |
|
</body></html> |
|
ENDENTEREDKEY |
|
return OK; |
} else { |
} else { |
# print form to enter a new key |
# print form to enter a new key |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
Line 132 $bodytag
|
Line 184 $bodytag
|
$swinfo |
$swinfo |
</script> |
</script> |
<form method="post"> |
<form method="post"> |
<input type="hidden" name="selectrole" value="$ENV{'form.selectrole'}" /> |
<input type="hidden" name="selectrole" value="1" /> |
|
<input type="hidden" name="$trolecode" value="1" /> |
<input type="text" size="20" name="newkey" value="$ENV{'form.newkey'}" /> |
<input type="text" size="20" name="newkey" value="$ENV{'form.newkey'}" /> |
<input type="submit" value="Enter key" /> |
<input type="submit" value="Enter key" /> |
</form> |
</form> |
Line 142 ENDENTERKEY
|
Line 195 ENDENTERKEY
|
} |
} |
} |
} |
} |
} |
|
&Apache::lonnet::log($ENV{'user.domain'}, |
|
$ENV{'user.name'}, |
|
$ENV{'user.home'}, |
|
"Role ".$trolecode); |
my $tadv=0; |
my $tadv=0; |
if (($trolecode!~/^st/) && |
if (($trolecode!~/^st/) && |
($trolecode!~/^ta/) && |
($trolecode!~/^ta/) && |
Line 370 ENDHEADER
|
Line 427 ENDHEADER
|
$tbg='#11CC55'; |
$tbg='#11CC55'; |
$tfont='#002200'; |
$tfont='#002200'; |
$inrole=1; |
$inrole=1; |
|
$countactive++; |
$tremark.=&mt('Currently selected. '); |
$tremark.=&mt('Currently selected. '); |
} |
} |
my $trole; |
my $trole; |
Line 524 ENDHEADER
|
Line 582 ENDHEADER
|
$r->print('</form></body></html>'); |
$r->print('</form></body></html>'); |
return OK; |
return OK; |
# Is there only one choice? |
# Is there only one choice? |
} elsif ($countactive==1) { |
} elsif (($countactive==1) && ($ENV{'request.role'} eq 'cm')) { |
$r->print('<h3>'.&mt('Please stand by.').'</h3>'. |
$r->print('<h3>'.&mt('Please stand by.').'</h3>'. |
'<input type="hidden" name="'.$possiblerole.'" value="1" />'); |
'<input type="hidden" name="'.$possiblerole.'" value="1" />'); |
$r->print("</form>\n"); |
$r->print("</form>\n"); |