Bugzilla – Attachment 41665 Details for
Bug 14321
Merge UploadedFile and UploadedFiles into Koha::Upload
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14321: Switch to Upload in opac-retrieve
Bug-14321-Switch-to-Upload-in-opac-retrieve.patch (text/plain), 3.43 KB, created by
Marcel de Rooy
on 2015-08-19 13:50:57 UTC
(
hide
)
Description:
Bug 14321: Switch to Upload in opac-retrieve
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-08-19 13:50:57 UTC
Size:
3.43 KB
patch
obsolete
>From 3572fbe8eeb9d8385da506a5ec1bd8ae9c9c14ac Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Sat, 15 Aug 2015 14:00:58 +0200 >Subject: [PATCH] Bug 14321: Switch to Upload in opac-retrieve >Content-Type: text/plain; charset=utf-8 > >A last step to obsolete UploadedFiles.pm. >Note that we now also check for the public flag. If that flag is not set, >the uploaded file cannot be reached via the opac. > >This patch also the encode step to tools/upload for the http header that >could include a filename with special chars (just as in opac-retrieve). > >Test plan: >[1] Check downloading a file marked public in OPAC without logging in. > If possible, include some special chars in the filename. >[2] Check another file (not marked as public). Should not be possible. >--- > .../bootstrap/en/modules/opac-retrieve-file.tt | 6 ++++ > opac/opac-retrieve-file.pl | 36 ++++++++++++++------ > tools/upload.pl | 2 +- > 3 files changed, 32 insertions(+), 12 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-retrieve-file.tt > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-retrieve-file.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-retrieve-file.tt >new file mode 100644 >index 0000000..581d9ea >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-retrieve-file.tt >@@ -0,0 +1,6 @@ >+[%# This template is called only for a very simple error message %] >+<html> >+<body> >+Your search [% IF hash %]for [% hash %][% END %] was not successful. >+</body> >+</html> >diff --git a/opac/opac-retrieve-file.pl b/opac/opac-retrieve-file.pl >index 419f2bd..b443a7c 100755 >--- a/opac/opac-retrieve-file.pl >+++ b/opac/opac-retrieve-file.pl >@@ -19,19 +19,33 @@ > > use Modern::Perl; > use CGI; >+use Encode; > >+use C4::Auth; > use C4::Context; >-use C4::UploadedFiles; >+use C4::Output; >+use Koha::Upload; > >-my $input = new CGI; >+my $input = CGI::->new; >+my $hash = $input->param('id'); # historically called id (used in URLs?) > >-my $id = $input->param('id'); >-my $file = C4::UploadedFiles::GetUploadedFile($id); >-exit 1 if !$file || !-f $file->{filepath}; >- >-open my $fh, '<', $file->{filepath} or die "Can't open file: $!"; >-print $input->header( C4::UploadedFiles::httpheaders( $file->{filename} )); >-while(<$fh>) { >- print $_; >+my $upl = Koha::Upload->new({ public => 1 }); >+my $rec = $upl->get({ hashvalue => $hash, filehandle => 1 }); >+my $fh = $rec->{fh}; >+if( !$rec || !$fh ) { >+ my ( $template, $user, $cookie ) = get_template_and_user({ >+ query => $input, >+ template_name => 'opac-retrieve-file.tt', >+ type => 'opac', >+ authnotrequired => 1, >+ }); >+ $template->param( hash => $hash ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+} else { >+ my @hdr = $upl->httpheaders( $rec->{name} ); >+ print Encode::encode_utf8( $input->header( @hdr ) ); >+ while( <$fh> ) { >+ print $_; >+ } >+ $fh->close; > } >-close $fh; >diff --git a/tools/upload.pl b/tools/upload.pl >index 96d74b1..47c28f5 100755 >--- a/tools/upload.pl >+++ b/tools/upload.pl >@@ -89,7 +89,7 @@ if( $op eq 'new' ) { > output_html_with_http_headers $input, $cookie, $template->output; > } else { > my @hdr = $upl->httpheaders( $rec->{name} ); >- print $input->header( @hdr ); >+ print Encode::encode_utf8( $input->header( @hdr ) ); > while( <$fh> ) { > print $_; > } >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14321
:
41498
|
41499
|
41500
|
41501
|
41555
|
41556
|
41557
|
41558
|
41559
|
41560
|
41561
|
41562
|
41665
|
41666
|
41667
|
41668
|
41669
|
41677
|
41873
|
41874
|
41875
|
41876
|
41877
|
41878
|
41879
|
41880
|
41881
|
42411
|
42412
|
42413
|
42414
|
42558
|
42559
|
42560
|
42561
|
42584
|
42587
|
42588
|
42589
|
42590
|
42591
|
42660
|
42661
|
42662
|
42663
|
42664
|
42665
|
42666
|
42707
|
42726
|
42727
|
42728
|
42729
|
42730
|
42731
|
42732
|
42889
|
42890