--- loncom/auth/restrictedaccess.pm 2006/07/17 19:49:14 1.3 +++ loncom/auth/restrictedaccess.pm 2006/07/22 23:10:45 1.6 @@ -45,32 +45,41 @@ sub handler { if (!defined($origurl)) { $origurl = $r->uri; } + my $msg=''; if (exists($env{'form.pass1'})) { my ($result,$end) = &check_pass($r,$origurl); if ($result eq 'ok') { - &Apache::lonnet::appenv(('user.passphrase_access_'.$origurl => - $end)); + &Apache::lonnet::allowuploaded('/adm/restrictedaccess', + $origurl); $env{'request.state'} = "published"; $env{'request.filename'} = $origurl; $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$origurl); return REDIRECT; } else { - &print_entryform($r,$origurl,"Invalid passphrase"); - } - } else { - &print_entryform($r,$origurl); + $msg = 'Invalid passphrase'; + } } - return OK; -} -sub print_entryform { - my ($r,$origurl,$msg) = @_; - &Apache::lonlocal::get_language_handle($r); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; $r->print(&Apache::loncommon::start_page('Passphrase protected file')); + &print_entryform($r,$origurl,$msg); + + return OK; +} + +sub setup_handler { + my ($r) = @_; + $r->set_handlers('PerlHandler'=> + [\&Apache::restrictedaccess::handler]); + $r->handler('perl-script'); +} + +sub print_entryform { + my ($r,$origurl,$msg) = @_; + $r->print(''); - $r->print(''.$msg.''); + if ($msg ne '') { + $r->print(''.$msg.''); + } $r->print('
'); $r->print('


'); $r->print(&Apache::loncommon::start_data_table()); $r->print(&Apache::loncommon::start_data_table_row()); $r->print(''.&mt('Passphrase: ').''. - ''); + ''); $r->print(&Apache::loncommon::end_data_table_row()); $r->print(&Apache::loncommon::start_data_table_row()); $r->print('
'. @@ -103,7 +114,7 @@ function verify() { sub check_pass { my ($r,$origurl) = @_; my (undef,$udom,$unum,$file_name,$group) = - &Apache::lonacc::parse_portfolio_url($origurl); + &Apache::lonnet::parse_portfolio_url($origurl); my $curr_perms = &Apache::lonnet::get_portfile_permissions($udom,$unum); my %acc_controls = &Apache::lonnet::get_access_controls($curr_perms,