version 1.1, 2003/04/12 15:57:30
|
version 1.3, 2003/04/23 01:55:52
|
Line 48 sub header {
|
Line 48 sub header {
|
</head> |
</head> |
$bodytag |
$bodytag |
<form method="post" enctype="multipart/form-data" |
<form method="post" enctype="multipart/form-data" |
action="/adm/keymanage" name="keyform"> |
action="/adm/managekeys" name="keyform"> |
ENDHEAD |
ENDHEAD |
} |
} |
|
|
Line 62 sub show_key_list {
|
Line 62 sub show_key_list {
|
# |
# |
# |
# |
# |
# |
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'form.cid'}; |
# |
# |
# Variables for excel output |
# Variables for excel output |
my ($excel_workbook, $excel_sheet, $excel_filename,$row); |
my ($excel_workbook, $excel_sheet, $excel_filename,$row); |
Line 111 sub show_key_list {
|
Line 111 sub show_key_list {
|
} elsif ($mode eq 'excel') { |
} elsif ($mode eq 'excel') { |
$excel_workbook->close(); |
$excel_workbook->close(); |
$r->print('<p><a href="'.$excel_filename.'">'. |
$r->print('<p><a href="'.$excel_filename.'">'. |
'Your Excel spreadsheet</a> is ready for download.</p>'."\n"); |
'Your Excel spreadsheet</a> is ready for download.</p>'."\n"); |
} |
} |
} |
} |
|
|
|
|
|
# ----------------------------------------------------------- Toggle Key Access |
|
|
|
sub togglekeyaccess { |
|
my %cenv=@_; |
|
unless ($cenv{'domain'}) { return; } |
|
if ($cenv{'keyaccess'} eq 'yes') { |
|
return 'Removing key access: '. |
|
&Apache::lonnet::del('environment',['keyaccess'], |
|
$cenv{'domain'},$cenv{'num'}); |
|
} else { |
|
return 'Establishing key access: '. |
|
&Apache::lonnet::put('environment',{'keyaccess' => 'yes'}, |
|
$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{'number'},$comments).' access keys.'; |
|
} |
|
|
################################################################### |
################################################################### |
################################################################### |
################################################################### |
sub handler { |
sub handler { |
Line 124 sub handler {
|
Line 153 sub handler {
|
$r->send_http_header; |
$r->send_http_header; |
return OK; |
return OK; |
} |
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['state']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['state','cid']); |
|
if (($ENV{'form.domain'}) && ($ENV{'form.course'})) { |
|
$ENV{'form.cid'}=$ENV{'form.domain'}.'_'.$ENV{'form.course'}; |
|
} |
|
|
unless (&Apache::lonnet::allowed('mky',$ENV{'request.role.domain'})) { |
unless (&Apache::lonnet::allowed('mky',$ENV{'request.role.domain'})) { |
$ENV{'user.error.msg'}= |
$ENV{'user.error.msg'}= |
"/adm/managekeys:mky:0:0:Cannot manage access keys"; |
"/adm/managekeys:mky:0:0:Cannot manage access keys"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
# |
if ($ENV{'form.cid'}) { |
# Only output the header information if they did not request csv format |
my %cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
# |
if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) { |
if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) { |
|
$r->content_type('text/csv'); |
|
} else { |
|
# Start page |
|
$r->content_type('text/html'); |
|
$r->send_http_header; |
|
$r->print(&header()); |
|
} |
|
# |
# |
# do stuff here. |
# CSV Output |
# |
# |
|
$r->content_type('text/csv'); |
if (exists($ENV{'form.state'}) && ($ENV{'form.state'} eq 'csv')) { |
# |
$r->print("\n"); |
# Do CSV |
|
# |
|
} else { |
|
# |
|
# Normal web stuff |
|
# |
|
$r->content_type('text/html'); |
|
$r->send_http_header; |
|
$r->print(&header()); |
|
|
|
$r->print( |
|
'<input type="hidden" name="cid" value="'.$ENV{'form.cid'}.'" />'); |
|
# --- 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>'); |
|
} |
} else { |
} else { |
$r->print('</form></body></html>'); |
# Start page no course id |
|
$r->content_type('text/html'); |
|
$r->send_http_header; |
|
$r->print(&header().&Apache::loncommon::coursebrowser_javascript()); |
|
$r->print( |
|
'Course ID: <input input type="text" size="25" name="course" value="" />'); |
|
$r->print('Domain: '.&Apache::loncommon::select_dom_form( |
|
$ENV{'request.role.domain'},'domain')); |
|
$r->print(&Apache::loncommon::selectcourse_link( |
|
'keyform','course','domain')); |
|
$r->print('<br /><input type="submit" value="Manage Access Keys" />'); |
|
$r->print('</form></body></html>'); |
} |
} |
return OK; |
return OK; |
} |
} |