From 79168c011bb32439f487832231e7dac8335b669c Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 30 Sep 2013 09:34:01 +0200 Subject: [PATCH] Bug 6874: Force user to select a directory This patch adds a javascript and a server-side checks Test plan: 1/ Choose a file, leave the radios not selected and submit 2/ You have a javascript alert which prevents form to be submitted 3/ Disable javascript and repeat step 1 4/ Form is submitted but form is redisplayed with an error message telling you to choose a directory. Signed-off-by: Mark Tompsett Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- cataloguing/value_builder/upload.pl | 8 ++++++-- .../modules/cataloguing/value_builder/upload.tt | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cataloguing/value_builder/upload.pl b/cataloguing/value_builder/upload.pl index 4e6683afef..966f0b36ac 100755 --- a/cataloguing/value_builder/upload.pl +++ b/cataloguing/value_builder/upload.pl @@ -80,9 +80,9 @@ sub plugin { ); # Dealing with the uploaded file - if ($uploaded_file) { + my $dir = $input->param('dir'); + if ($uploaded_file and $dir) { my $fh = $input->upload('uploaded_file'); - my $dir = $input->param('dir'); $id = C4::UploadedFiles::UploadFile($uploaded_file, $dir, $fh->handle); if($id) { @@ -128,6 +128,10 @@ sub plugin { } else { $template->param( error_upload_path_not_configured => 1 ); } + + if ($uploaded_file and not $dir) { + $template->param(error_no_dir_selected => 1); + } } $template->param( 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 cd983ade8d..63849f8d68 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 @@ -6,6 +6,20 @@ + @@ -59,6 +73,9 @@

Configuration variable 'upload_path' is not configured.

Please configure it in your koha-conf.xml

[% ELSE %] + [% IF (error_no_dir_selected) %] +

Error: You have to select the destination of uploaded file.

+ [% END %]

Please select the file to upload :

[% filefield %] -- 2.39.5