From 5f25235b9ea4838cf1a875b10f873dc68c00ba0b Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 14 May 2020 04:00:32 +0000 Subject: [PATCH] Bug 25476: Add ability to browse file uploads by category This patch adds the ability to search/browse files by category. (Note it doesn't include temporary uploads since they don't have a "category" per se.) Test Plan: 0) Apply patch 1) Go to /cgi-bin/koha/admin/authorised_values.pl 2) Create "UPLOAD" authorized value category 3) Create "test" authorized value in "UPLOAD" category 4) Go to /cgi-bin/koha/tools/upload.pl 5) Note "Search uploads by category" fieldset 6) Upload new file to "test" category 7) Click "Back" 8) Choose "test" category in "Search uploads by category" 9) Click "Search" 10) Note that your file upload is displayed in result list Signed-off-by: Mazen Khallaf Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- .../prog/en/modules/tools/upload.tt | 26 +++++++++++++++++++ tools/upload.pl | 17 ++++++++++++ 2 files changed, 43 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt index 847940f628..6c402550bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt @@ -109,6 +109,31 @@ [% END %] +[% BLOCK form_browse %] + [% IF uploadcategories %] +
+ [% PROCESS plugin_pars %] + +
+ Search uploads by category +
    +
  1. + + +
  2. +
+
+ +
+
+
+ [% END %] +[% END %] + [% BLOCK form_search %]
[% PROCESS plugin_pars %] @@ -236,6 +261,7 @@ [% PROCESS submitter %] [% IF mode == 'new' || mode == 'deleted' %] [% PROCESS form_new %] + [% PROCESS form_browse %] [% PROCESS form_search %] [% PROCESS closer %] [% ELSIF mode == 'report' %] diff --git a/tools/upload.pl b/tools/upload.pl index 61e8a22ee4..cf9a2c6053 100755 --- a/tools/upload.pl +++ b/tools/upload.pl @@ -36,6 +36,7 @@ my $index = $input->param('index'); # MARC editor input field id my $term = $input->param('term'); my $id = $input->param('id'); my $msg = $input->param('msg'); +my $browsecategory = $input->param('browsecategory'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "tools/upload.tt", @@ -58,6 +59,22 @@ if ( $op eq 'new' ) { ); output_html_with_http_headers $input, $cookie, $template->output; +} elsif ( $op eq 'browse' ) { + my $uploads; + if ($browsecategory){ + $uploads = Koha::UploadedFiles->search({ + uploadcategorycode => $browsecategory, + $plugin? ( public => 1 ): (), + })->unblessed; + } + + $template->param( + mode => 'report', + msg => $msg, + uploads => $uploads, + ); + output_html_with_http_headers $input, $cookie, $template->output; + } elsif ( $op eq 'search' ) { my $uploads; if( $id ) { # might be a comma separated list -- 2.39.5