[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /interface lonpdfupload.pm mydesk.tab
raeburn
raeburn@source.lon-capa.org
Thu, 18 Mar 2010 13:16:11 -0000
raeburn Thu Mar 18 13:16:11 2010 EDT
Modified files:
/loncom loncapa_apache.conf
/loncom/interface mydesk.tab lonpdfupload.pm
Log:
- Making pdfupload more like the rest of LON-CAPA.
- Authz handler: lonacc
- path: /adm/pdfupload
- remove "use package" for packages which are not actually used
- use routine in loncommon.pm to generate HTTP header.
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.194 loncom/loncapa_apache.conf:1.195
--- loncom/loncapa_apache.conf:1.194 Wed Mar 17 19:41:06 2010
+++ loncom/loncapa_apache.conf Thu Mar 18 13:16:06 2010
@@ -1,7 +1,7 @@
##
## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
##
-## $Id: loncapa_apache.conf,v 1.194 2010/03/17 19:41:06 raeburn Exp $
+## $Id: loncapa_apache.conf,v 1.195 2010/03/18 13:16:06 raeburn Exp $
##
#
@@ -105,17 +105,24 @@
PerlHandler Apache::portfolio
</Location>
+<Location /adm/pdfupload>
+AuthType LONCAPA
+Require valid-user
+PerlAuthzHandler Apache::lonacc
+SetHandler perl-script
+PerlHandler Apache::lonpdfupload
+ErrorDocument 403 /adm/login
+ErrorDocument 404 /adm/notfound.html
+ErrorDocument 406 /adm/roles
+ErrorDocument 500 /adm/errorhandler
+</Location>
+
<LocationMatch "^/+userfiles.*">
PerlAccessHandler Apache::lontokacc
PerlCleanupHandler Apache::lontokacc::removefile
PerlCleanupHandler Apache::lonacc::cleanup
</LocationMatch>
-<LocationMatch "^/pdfupload.*">
-SetHandler perl-script
-PerlHandler Apache::lonpdfupload
-</LocationMatch>
-
<LocationMatch "^/+uploaded.*">
AuthType LONCAPA
Require valid-user
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.129 loncom/interface/mydesk.tab:1.130
--- loncom/interface/mydesk.tab:1.129 Tue Mar 16 19:55:49 2010
+++ loncom/interface/mydesk.tab Thu Mar 18 13:16:11 2010
@@ -170,8 +170,8 @@
6:1:author:rca:cstr.png:co con-[_1]:struct[_2]:go('/priv/$caname/');:Enter construction space as a co-author:set
6:1:author:raa:cstr.png:co con-[_1]:struct[_2]:go('/priv/$caname/');:Enter construction space as an assistant co-author:set
6:1:pmau:$requested_domain:conf.png:domain[_1]:config[_1]:go('/adm/domainprefs');:Set domain configuration:dom
-6:1:courseenv_canuse_pdfforms:any:pdfupload.png:upload[_1]:pdf form[_1]:go('/pdfupload'):Upload a PDF Form with filled Form Fields:grd
-6:1:community_canuse_pdfforms:any:pdfupload.png:upload[_1]:pdf form[_1]:go('/pdfupload'):Upload a PDF Form with filled Form Fields:grd
+6:1:courseenv_canuse_pdfforms:any:pdfupload.png:upload[_1]:pdf form[_1]:go('/adm/pdfupload'):Upload a PDF Form with filled Form Fields:grd
+6:1:community_canuse_pdfforms:any:pdfupload.png:upload[_1]:pdf form[_1]:go('/adm/pdfupload'):Upload a PDF Form with filled Form Fields:grd
6:2:clear
6:2:pbro:/res/:res.png:resource[_1]:space[_1]:go('/res/?launch=1');:Browse own authored or co-authored resources:cnt
6:2:pbre:$requested_domain:res.png:resource[_1]:space[_1]:go('/res/$udom/?launch=1');:Browse published resources:cnt
Index: loncom/interface/lonpdfupload.pm
diff -u loncom/interface/lonpdfupload.pm:1.14 loncom/interface/lonpdfupload.pm:1.15
--- loncom/interface/lonpdfupload.pm:1.14 Sat Oct 17 03:13:35 2009
+++ loncom/interface/lonpdfupload.pm Thu Mar 18 13:16:11 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# PDF Form Upload Handler
#
-# $Id: lonpdfupload.pm,v 1.14 2009/10/17 03:13:35 raeburn Exp $
+# $Id: lonpdfupload.pm,v 1.15 2010/03/18 13:16:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -29,45 +29,22 @@
use lib '/home/httpd/lib/perl';
use Apache::Constants qw(:common :http);
-use LONCAPA;
-use LONCAPA::loncgi;
-use File::Path;
-use File::Basename;
-use File::Copy;
-use IO::File;
-use Image::Magick;
-use Apache::lonacc;
-use Apache::lonxml;
-use Apache::lonhtmlcommon();
use Apache::lonnet;
+use Apache::lonhtmlcommon();
use Apache::loncommon();
use Apache::lonlocal;
-use Apache::lonmsg();
-use Apache::lonhomework;
-use LONCAPA::Enrollment;
-use LONCAPA::Configuration;
use CAM::PDF;
use strict;
sub handler() {
my $r = shift;
-
- # check user permissions
- if(!&checkpermission($r)) {
- # stop processing
- return OK;
- }
-
- $Apache::lonxml::request=$r;
- $Apache::lonxml::debug=$env{'user.debug'};
-
- $env{'request.uri'}=$r->uri;
- $r->content_type('text/html');
- $r->send_http_header();
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ return OK if $r->header_only;
# Breadcrumbs
- my $brcrum = [{'href' => '/pdfupload',
+ my $brcrum = [{'href' => '/adm/pdfupload',
'text' => 'Upload PDF Form'}];
$r->print(&Apache::loncommon::start_page('Upload PDF Form',
@@ -75,9 +52,6 @@
{'bread_crumbs' => $brcrum,})
);
- #load post data into environment
- &Apache::lonacc::get_posted_cgi($r);
-
# if a file was upload
if($env{'form.Uploaded'} && $env{'form.file'}) {
$r->print(&processPDF);
@@ -101,33 +75,6 @@
return OK;
}
-
-sub checkpermission() {
- my $r = shift;
- if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
- my $result = <<END
-Content-type: text/html
-
-<html>
- <head>
- <title>
- Bad Cookie
- </title>
- </head>
- <body>
- Your cookie information is incorrect.
- </body>
-</html>
-END
-;
- $r->print($result);
- return 0;
- } else {
- return 1;
- }
-}
-
-
sub get_javascripts() {
my $message = &mt('Please choose a PDF-File.');
@@ -206,7 +153,7 @@
my $dict = $pdf->getFormFieldDict($pdf->getFormField($field)); # get formfield dictonary
#
- # this is nessesary 'cause CAM::PDF has a problem with formfieldnames which include a
+ # this is necessary because CAM::PDF has a problem with formfieldnames which include a
# dot in fieldnames. So a fieldname like "i.am.aFormfield" will offer three fieldnames "i", "i.am"
# and "i.am.aFormfield". The fragmentary names keep no values and will be ignored.
if($dict->{'V'}) {