@@ -, +, @@ --- koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt | 9 +++++++++ tools/export.pl | 13 +++++++++++++ 2 files changed, 22 insertions(+) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt @@ -47,6 +47,15 @@ $(document).ready(function() {
+[% FOR m IN messages %] +
+ [% SWITCH m.code %] + [% CASE 'invalid_mimetype' %]The file used does not have a valid format. Only csv and txt are allowed. + [% CASE %][% m.code %] + [% END %] +
+[% END %] +
  • Export bibliographic records
  • --- a/tools/export.pl +++ a/tools/export.pl @@ -69,6 +69,18 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( my @branch = $query->multi_param("branch"); +my @messages; +if ( $op eq 'export' ) { + my $filename = $query->param('id_list_file'); + my $mimetype = $query->uploadInfo($filename)->{'Content-Type'}; + my @valid_mimetypes = qw( application/octet-stream text/csv text/plain ); + warn $mimetype; + unless ( grep { /^$mimetype$/ } @valid_mimetypes ) { + push @messages, { type => 'alert', code => 'invalid_mimetype' }; + $op = ''; + } +} + if ( $op eq "export" ) { my $export_remove_fields = $query->param("export_remove_fields") || q||; @@ -302,6 +314,7 @@ else { authority_types => $authority_types, export_remove_fields => C4::Context->preference("ExportRemoveFields"), csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ], + messages => \@messages, ); output_html_with_http_headers $query, $cookie, $template->output; --