From a6408148bac38b8ed782e944c7ad68dc8882df2a 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, 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 Signed-off-by: Tomas Cohen Arazi --- cataloguing/value_builder/upload.pl | 9 ++++++--- .../prog/en/modules/cataloguing/value_builder/upload.tt | 7 +++++-- .../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 211a5886fb..2cebadf2f4 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 2f002af676..e08e424107 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 928b954b79..7f5e05d855 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

-- 2.39.5