Bug 17501: Remove Koha::Upload::get from Koha::Upload
commit158442eb9e3658e22c54a3315caa57673e6940ab
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tue, 22 Nov 2016 15:57:21 +0000 (22 16:57 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 20 Jan 2017 14:20:05 +0000 (20 14:20 +0000)
tree6fe5c918f55f07eb3a8bfcaa63b5ebb2c6ec7f4f
parent7a620054684e4ab0dfdbb5bd285a9c70928a7e14
Bug 17501: Remove Koha::Upload::get from Koha::Upload

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>
12 files changed:
C4/HTML5Media.pm
Koha/Upload.pm
Koha/UploadedFile.pm
Koha/UploadedFiles.pm
koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
offline_circ/enqueue_koc.pl
offline_circ/process_koc.pl
opac/opac-retrieve-file.pl
t/db_dependent/Upload.t
tools/stage-marc-import.pl
tools/upload-cover-image.pl
tools/upload.pl