version 1.16, 2005/02/17 08:29:42
|
version 1.18, 2006/03/16 22:42:58
|
Line 31
|
Line 31
|
package Apache::lonmanagekeys; |
package Apache::lonmanagekeys; |
|
|
use strict; |
use strict; |
use Apache::lonnet(); |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::Constants qw(:common :http REDIRECT); |
use Apache::Constants qw(:common :http REDIRECT); |
Line 41 use Apache::lonlocal;
|
Line 41 use Apache::lonlocal;
|
############################################################### |
############################################################### |
############################################################### |
############################################################### |
sub header { |
sub header { |
my $html=&Apache::lonxml::xmlbegin(); |
my $start_page=&Apache::loncommon::start_page('Access Key Management'); |
my $bodytag=&Apache::loncommon::bodytag('Access Key Management'); |
|
return(<<ENDHEAD); |
return(<<ENDHEAD); |
$html |
$start_page |
<head> |
|
<title>LON-CAPA Access Key Management</title> |
|
</head> |
|
$bodytag |
|
<form method="post" enctype="multipart/form-data" |
<form method="post" enctype="multipart/form-data" |
action="/adm/managekeys" name="keyform"> |
action="/adm/managekeys" name="keyform"> |
ENDHEAD |
ENDHEAD |
Line 158 sub addcom {
|
Line 153 sub addcom {
|
my %cenv=@_; |
my %cenv=@_; |
my %newcomment=(); |
my %newcomment=(); |
undef %newcomment; |
undef %newcomment; |
foreach (keys %ENV) { |
foreach (keys %env) { |
if ($_=~/^form\.com\_(.+)$/) { |
if ($_=~/^form\.com\_(.+)$/) { |
my $key=$1; |
my $key=$1; |
my $comment=$ENV{$_}; |
my $comment=$env{$_}; |
$comment=~s/^\s+//gs; |
$comment=~s/^\s+//gs; |
if ($comment) { |
if ($comment) { |
&Apache::lonnet::comment_access_key |
&Apache::lonnet::comment_access_key |
Line 182 sub handler {
|
Line 177 sub handler {
|
} |
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['state','cid']); |
['state','cid']); |
if (($ENV{'form.domain'}) && ($ENV{'form.course'})) { |
if (($env{'form.domain'}) && ($env{'form.course'})) { |
$ENV{'form.cid'}=$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'}) { |
if ($env{'form.cid'}) { |
my %cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
my %cenv=&Apache::lonnet::coursedescription($env{'form.cid'}); |
my $keytype=''; |
my $keytype=''; |
if ($cenv{'url'} eq '/res/') { |
if ($cenv{'url'} eq '/res/') { |
($cenv{'domain'},$cenv{'num'})=split(/\_/,$ENV{'form.cid'}); |
($cenv{'domain'},$cenv{'num'})=split(/\_/,$env{'form.cid'}); |
$keytype='auth'; |
$keytype='auth'; |
} elsif ($cenv{'keyauth'}) { |
} elsif ($cenv{'keyauth'}) { |
($cenv{'num'},$cenv{'domain'})=split(/\W/,$cenv{'keyauth'}); |
($cenv{'num'},$cenv{'domain'})=split(/\W/,$cenv{'keyauth'}); |
Line 203 sub handler {
|
Line 198 sub handler {
|
} else { |
} else { |
$keytype='course'; |
$keytype='course'; |
} |
} |
if ($ENV{'form.listkeyscsv'}) { |
if ($env{'form.listkeyscsv'}) { |
# |
# |
# CSV Output |
# CSV Output |
# |
# |
Line 212 sub handler {
|
Line 207 sub handler {
|
# |
# |
# Do CSV |
# Do CSV |
# |
# |
&show_key_list($r,1,$ENV{'form.listcom'}, |
&show_key_list($r,1,$env{'form.listcom'}, |
$ENV{'form.newonly'},$ENV{'form.checkonly'},%cenv); |
$env{'form.newonly'},$env{'form.checkonly'},%cenv); |
|
|
} else { |
} else { |
# |
# |
Line 224 sub handler {
|
Line 219 sub handler {
|
$r->print(&header()); |
$r->print(&header()); |
|
|
$r->print( |
$r->print( |
'<input type="hidden" name="cid" value="'.$ENV{'form.cid'}.'" />'); |
'<input type="hidden" name="cid" value="'.$env{'form.cid'}.'" />'); |
# --- Actions |
# --- Actions |
if ($ENV{'form.toggle'}) { |
if ($env{'form.toggle'}) { |
$r->print(&togglekeyaccess(%cenv).'<br />'); |
$r->print(&togglekeyaccess(%cenv).'<br />'); |
%cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
%cenv=&Apache::lonnet::coursedescription($env{'form.cid'}); |
} |
} |
my $batchnumber=''; |
my $batchnumber=''; |
if ($ENV{'form.genkeys'}) { |
if ($env{'form.genkeys'}) { |
(my $msg,$batchnumber)= |
(my $msg,$batchnumber)= |
&genkeys($ENV{'form.num'},$ENV{'form.comments'},%cenv); |
&genkeys($env{'form.num'},$env{'form.comments'},%cenv); |
$r->print($msg.'<br />'); |
$r->print($msg.'<br />'); |
} |
} |
if ($ENV{'form.listkeys'}) { |
if ($env{'form.listkeys'}) { |
&show_key_list($r,0,$ENV{'form.listcom'}, |
&show_key_list($r,0,$env{'form.listcom'}, |
$ENV{'form.newonly'},$ENV{'form.checkonly'},%cenv); |
$env{'form.newonly'},$env{'form.checkonly'},%cenv); |
} |
} |
if ($ENV{'form.addcom'}) { |
if ($env{'form.addcom'}) { |
&addcom(%cenv); |
&addcom(%cenv); |
} |
} |
# --- Menu |
# --- Menu |
Line 269 Comments/Remarks/Notes/User/Batch Number
|
Line 264 Comments/Remarks/Notes/User/Batch Number
|
<input type="submit" name="listkeys" value="List Keys/Add Comments" /> |
<input type="submit" name="listkeys" value="List Keys/Add Comments" /> |
<input type="submit" name="listkeyscsv" value="CSV List of Keys" /> |
<input type="submit" name="listkeyscsv" value="CSV List of Keys" /> |
ENDKEYMENU |
ENDKEYMENU |
$r->print('</form></body></html>'); |
$r->print('</form>'.&Apache::loncommon::end_page()); |
} |
} |
} else { |
} else { |
# Start page no course id |
# Start page no course id |
Line 279 ENDKEYMENU
|
Line 274 ENDKEYMENU
|
$r->print( |
$r->print( |
&mt('Course ID of Key Authority').': <input input type="text" size="25" name="course" value="" />'); |
&mt('Course ID of Key Authority').': <input input type="text" size="25" name="course" value="" />'); |
$r->print(&mt('Domain').': '.&Apache::loncommon::select_dom_form( |
$r->print(&mt('Domain').': '.&Apache::loncommon::select_dom_form( |
$ENV{'request.role.domain'},'domain')); |
$env{'request.role.domain'},'domain')); |
$r->print(&Apache::loncommon::selectcourse_link( |
$r->print(&Apache::loncommon::selectcourse_link( |
'keyform','course','domain')); |
'keyform','course','domain')); |
$r->print('<br /><input type="submit" value="'.&mt('Manage Access Keys').'" />'); |
$r->print('<br /><input type="submit" value="'.&mt('Manage Access Keys').'" />'); |
$r->print('</form></body></html>'); |
$r->print('</form>'.&Apache::loncommon::end_page()); |
} |
} |
return OK; |
return OK; |
} |
} |