From 7cc5c1277ac5c37ef0be44d1e6d7be741de28163 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 Content-Type: text/plain; charset=utf-8 This adds a dependency on bug 5010, in that the protocol is assumed in the OpacBaseURL system preference. It also adds improved error handling. Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Marcel de Rooy --- cataloguing/value_builder/upload.pl | 9 ++++++--- .../prog/en/modules/cataloguing/value_builder/upload.tt | 7 +++++-- .../modules/cataloguing/value_builder/upload_delete_file.tt | 7 +++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cataloguing/value_builder/upload.pl b/cataloguing/value_builder/upload.pl index 211a588..2cebadf 100755 --- a/cataloguing/value_builder/upload.pl +++ b/cataloguing/value_builder/upload.pl @@ -100,9 +100,12 @@ 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 $OPACBaseURL = C4::Context->preference('OPACBaseURL') // ''; + $OPACBaseURL =~ s#/$##; + if (!$OPACBaseURL) { + $template->param(MissingURL => 1); + } + if($id && $OPACBaseURL) { my $return = "$OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=$id"; $template->param( success => 1, 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.10.4