version 1.2, 2003/04/22 21:00:42
|
version 1.4, 2003/04/23 13:11:45
|
Line 122 sub togglekeyaccess {
|
Line 122 sub togglekeyaccess {
|
my %cenv=@_; |
my %cenv=@_; |
unless ($cenv{'domain'}) { return; } |
unless ($cenv{'domain'}) { return; } |
if ($cenv{'keyaccess'} eq 'yes') { |
if ($cenv{'keyaccess'} eq 'yes') { |
|
return 'Removing key access: '. |
&Apache::lonnet::del('environment',['keyaccess'], |
&Apache::lonnet::del('environment',['keyaccess'], |
$cenv{'domain'},$cenv{'num'}); |
$cenv{'domain'},$cenv{'num'}); |
} else { |
} else { |
|
return 'Establishing key access: '. |
&Apache::lonnet::put('environment',{'keyaccess' => 'yes'}, |
&Apache::lonnet::put('environment',{'keyaccess' => 'yes'}, |
$cenv{'domain'},$cenv{'num'}); |
$cenv{'domain'},$cenv{'num'}); |
} |
} |
} |
} |
|
|
|
# --------------------------------------------------------------- Generate Keys |
|
|
|
sub genkeys { |
|
my ($num,$comments,%cenv)=@_; |
|
unless ($num) { return 'No number of keys given.'; } |
|
unless (($num=~/^\d+$/) && ($num>0)) { |
|
return 'Invalid number of keys given.'; |
|
} |
|
return 'Generated '.&Apache::lonnet::generate_access_keys |
|
($num,$cenv{'domain'},$cenv{'num'},$comments).' of '.$num. |
|
' access keys.'; |
|
} |
|
|
################################################################### |
################################################################### |
################################################################### |
################################################################### |
sub handler { |
sub handler { |
Line 151 sub handler {
|
Line 166 sub handler {
|
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
if ($ENV{'form.cid'}) { |
if ($ENV{'form.cid'}) { |
# |
my %cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
# Only output the header information if they did not request csv format |
|
# |
|
if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) { |
if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) { |
|
# |
|
# CSV Output |
|
# |
$r->content_type('text/csv'); |
$r->content_type('text/csv'); |
|
# |
|
# Do CSV |
|
# |
} else { |
} else { |
# Start page |
# |
|
# Normal web stuff |
|
# |
$r->content_type('text/html'); |
$r->content_type('text/html'); |
$r->send_http_header; |
$r->send_http_header; |
$r->print(&header()); |
$r->print(&header()); |
} |
|
$r->print('<input type="hidden" name="cid" value="'.$ENV{'form.cid'}. |
|
'" />'); |
|
my %cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
|
if ($ENV{'form.toggle'}) { |
|
&togglekeyaccess(%cenv); |
|
%cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
|
} |
|
if ($cenv{'keyaccess'} eq 'yes') { |
|
$r->print('Access to this course is key controlled. <input type="submit" name="toggle" value="Open Access" />') |
|
} else { |
|
$r->print('Access to this course is open, no access keys. <input type="submit" name="toggle" value="Control Access" />'); |
|
} |
|
$r->print('<hr />'); |
|
# |
|
# do stuff here. |
|
# |
|
|
|
if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) { |
$r->print( |
$r->print("\n"); |
'<input type="hidden" name="cid" value="'.$ENV{'form.cid'}.'" />'); |
} else { |
# --- Actions |
|
if ($ENV{'form.toggle'}) { |
|
$r->print(&togglekeyaccess(%cenv).'<br />'); |
|
%cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
|
} |
|
if ($ENV{'form.genkeys'}) { |
|
$r->print( |
|
&genkeys($ENV{'form.num'},$ENV{'form.comments'},%cenv).'<br />'); |
|
} |
|
# --- Menu |
|
$r->print('<h3>Key Access</h3>'); |
|
if ($cenv{'keyaccess'} eq 'yes') { |
|
$r->print('Access to this course is key controlled. <input type="submit" name="toggle" value="Open Access" />') |
|
} else { |
|
$r->print('Access to this course is open, no access keys. <input type="submit" name="toggle" value="Control Access" />'); |
|
} |
|
$r->print(<<ENDKEYGEN); |
|
<hr /><h3>Generate New Keys</h3> |
|
Number of keys to be generated: <input type="text" name="num" size="6" /><br /> |
|
Comments/Remarks/Notes: <input type="text" name="comments" size="30" /><br /> |
|
<input type="submit" name="genkeys" value="Generate Keys" /> |
|
ENDKEYGEN |
$r->print('</form></body></html>'); |
$r->print('</form></body></html>'); |
} |
} |
} else { |
} else { |