Bugzilla – Attachment 60177 Details for
Bug 18087
Clarification on File type when using file of biblionumbers to export data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18087: Handle invalid filetypes
Bug-18087-Handle-invalid-filetypes.patch (text/plain), 2.54 KB, created by
Jonathan Druart
on 2017-02-14 10:08:56 UTC
(
hide
)
Description:
Bug 18087: Handle invalid filetypes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-02-14 10:08:56 UTC
Size:
2.54 KB
patch
obsolete
>From 0b285d9b1ba3c165711692d5743237250e3dd1ca Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 14 Feb 2017 10:52:14 +0100 >Subject: [PATCH] Bug 18087: Handle invalid filetypes > >If an invalid file is used as biblionumber list, we should display a >message. > >Test plan: >1/ Use csv, plain text files >=> Should work >2/ Use invalid files (binary files like pdf, doc*, xsl*, etc.) >=> Should not work and see a warning message. >--- > koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt | 9 +++++++++ > tools/export.pl | 13 +++++++++++++ > 2 files changed, 22 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >index 470c588..cfa252c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt >@@ -47,6 +47,15 @@ $(document).ready(function() { > <div id="yui-main"> > <div class="yui-b"> > >+[% FOR m IN messages %] >+ <div class="dialog [% m.type %]"> >+ [% 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 %] >+ </div> >+[% END %] >+ > <div id="exporttype" class="toptabs"> > <ul> > <li><a href="#bibs">Export bibliographic records</a></li> >diff --git a/tools/export.pl b/tools/export.pl >index b1ce09c..411a84d 100755 >--- a/tools/export.pl >+++ b/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; >-- >2.9.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18087
:
60094
|
60105
|
60120
|
60124
|
60177
|
60431
|
60564
|
60567
|
60568
|
60643
|
60644
|
60645
|
60646