From 05a5a54df83900cede0f9f3540ad48698799dc17 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Wed, 16 Apr 2014 00:23:40 -0400 Subject: [PATCH] Bug 6874 - Clean up file URL generation This adds a dependency on bug 5010, particularly the OPAC system preference: OpacProtocol. This is used to generate the http or https for the OPACBaseURL. This now checks for proper configuration of the system preference. --- cataloguing/value_builder/upload.pl | 12 ++++++++---- .../en/modules/cataloguing/value_builder/upload.tt | 7 +++++-- .../value_builder/upload_delete_file.tt | 7 +++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cataloguing/value_builder/upload.pl b/cataloguing/value_builder/upload.pl index 211a588..a3ad2d3 100755 --- a/cataloguing/value_builder/upload.pl +++ b/cataloguing/value_builder/upload.pl @@ -100,10 +100,14 @@ sub plugin { my $fh = $input->upload('uploaded_file'); $id = C4::UploadedFiles::UploadFile($uploaded_file, $dir, $fh->handle); - if($id) { - my $OPACBaseURL = C4::Context->preference('OPACBaseURL'); - $OPACBaseURL =~ s#/$##; - my $return = "$OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=$id"; + my $OPACBaseURL = C4::Context->preference('OPACBaseURL') // ''; + $OPACBaseURL =~ s#/$##; + if (!$OPACBaseURL) { + $template->param(MissingURL => 1); + } + if($id && $OPACBaseURL) { + my $OpacProtocol = C4::Context->preference('OpacProtocol') // 'http://'; + my $return = "$OpacProtocol$OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=$id"; $template->param( success => 1, return => $return, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt index 2f002af..e08e424 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt @@ -56,9 +56,12 @@ [% ELSE %] - [% IF ( error ) %] + [% IF ( MissingURL ) %] +

Error: The OPAC system preference OPACBaseURL is not configured.

+

+ [% ELSIF ( error ) %]

Error: Failed to upload file. See logs for details.

- +

[% ELSE %] [%# This block display recursively a directory tree in variable 'dirs' %] [% BLOCK list_dirs %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt index 928b954..7f5e05d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt @@ -38,8 +38,11 @@ [% ELSE %] - [% IF ( error ) %] - Error: Unable to delete the file. + [% IF ( MissingURL ) %] +

Error: The OPAC system preference OPACBaseURL is not configured.

+

+ [% ELSIF ( error ) %] +

Error: Unable to delete the file.

[% ELSE %]

File deletion

-- 1.7.9.5