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 <mtompset@hotmail.com> Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
This commit is contained in:
parent
094092b111
commit
79168c011b
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,20 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<script type="text/javascript" src="[% interface %]/lib/jquery/jquery.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" />
|
||||
<script type="text/javascript">
|
||||
function _(s) { return s; }
|
||||
$(document).ready(function() {
|
||||
$('form').each(function() {
|
||||
$(this).submit(function() {
|
||||
var value = $(this).find('input[type="radio"][name="dir"]:checked').val();
|
||||
if (!value) {
|
||||
alert(_("Please select the destination of file"));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -59,6 +73,9 @@
|
|||
<p>Configuration variable 'upload_path' is not configured.</p>
|
||||
<p>Please configure it in your koha-conf.xml</p>
|
||||
[% ELSE %]
|
||||
[% IF (error_no_dir_selected) %]
|
||||
<p class="error">Error: You have to select the destination of uploaded file.<p>
|
||||
[% END %]
|
||||
<h2>Please select the file to upload : </h2>
|
||||
<form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl">
|
||||
[% filefield %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue