Marcel de Rooy
158442eb9e
The get routine actually returns records from uploaded_files. It should be possible to replace its calls by direct calls of Koha::UploadedFiles. This patch is the crux of this patch set. It deals with all scripts that use Koha::Upload. In the process we do: [1] Add a file_handle method to Koha::UploadedFile. This was previously arranged via the fh parameter of get. [2] Add a full_path method to UploadedFile. Previously returned in the path hash key of get. (Name is replaced by filename.) [3] Add a search_term method too (implementing get({ term => .. }). This logic came from _lookup. [4] Add a keep_file parameter to delete method. Only used in test now. Test plan: [1] Run t/db_dependent/Upload.t [2] Go to Tools/Upload. Add an upload, download and delete. [3] Add another public upload , search for it. Use the hashvalue to download via opac with URL: cgi-bin/koha/opac-retrieve-file.pl?id=[hashvalue] [4] Go to Tools/Stage MARC for import. Import a marc file. [5] Go to Tools/Upload local cover image. Import an image file. Enable OPACLocalCoverImages to see result. [6] Test uploading a offline circulation file: Enable AllowOfflineCirculation, and create a koc file (plain text): Line1: Version=1.0\tA=1\tB=2 Line2: 2016-11-23 16:00:00 345\treturn\t[barcode] Note: Replace tabs and barcode. The number of tabs is essential! Checkout the item with your barcode. Go to Circulation/Offline circulation file upload. Upload and click Apply directly. Checkout again. Repeat Offline circulation file upload. Now click Add to offline circulation queue. [7] Connect the upload plugin to field 856$u. Enable HTML5MediaEnabled. Upload a webm file via the plugin. Click Choose to save the URL, and put 'video/webm' into 856$q. Save the biblio record. Check if you see the media tab with player on staff detail. (See also: Bug 17673 about empty OPACBaseURL.) Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
55 lines
1.6 KiB
Prolog
Executable file
55 lines
1.6 KiB
Prolog
Executable file
#!/usr/bin/perl
|
|
|
|
# This file is part of Koha.
|
|
#
|
|
# Copyright (C) 2011-2012 BibLibre
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
|
|
|
use Modern::Perl;
|
|
use CGI;
|
|
use Encode;
|
|
|
|
use C4::Auth;
|
|
use C4::Context;
|
|
use C4::Output;
|
|
use Koha::Upload;
|
|
use Koha::UploadedFiles;
|
|
|
|
my $input = CGI::->new;
|
|
my $hash = $input->param('id'); # historically called id (used in URLs?)
|
|
|
|
my $rec = Koha::UploadedFiles->search({
|
|
hashvalue => $hash, public => 1,
|
|
# DO NOT REMOVE the public flag: this is an opac script !
|
|
})->next;
|
|
my $fh = $rec? $rec->file_handle: undef;
|
|
|
|
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 = Koha::Upload->httpheaders( $rec->filename );
|
|
print Encode::encode_utf8( $input->header( @hdr ) );
|
|
while( <$fh> ) {
|
|
print $_;
|
|
}
|
|
$fh->close;
|
|
}
|