Bugzilla – Attachment 50182 Details for
Bug 15451
Move the CSV related code to Koha::CsvProfile[s]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15451: Koha::CsvProfiles - Remove GetCsvProfileId
Bug-15451-KohaCsvProfiles---Remove-GetCsvProfileId.patch (text/plain), 5.21 KB, created by
Jonathan Druart
on 2016-04-13 08:37:25 UTC
(
hide
)
Description:
Bug 15451: Koha::CsvProfiles - Remove GetCsvProfileId
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-04-13 08:37:25 UTC
Size:
5.21 KB
patch
obsolete
>From e764d4bdeb3b7097c13b0f16cef12f8a15b7a9a8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 30 Dec 2015 18:23:24 +0000 >Subject: [PATCH] Bug 15451: Koha::CsvProfiles - Remove GetCsvProfileId > >This subroutine returned the export_format_id for a given profile name. >This can be done easily with the Koha::CsvProfiles->search method. > >Test plan: >Export records using the misc/export_records.pl script and the >export tool. >If you are exporting using the MARC format, the profile filled in the pref >ExportWithCsvProfile will be used (or the one passed in parameter of >misc/export_records.pl). >If you are exporting using the CSV format, you can choose a profile in >the dropdown list. >--- > C4/Csv.pm | 13 ------------- > Koha/Exporter/Record.pm | 3 ++- > misc/export_records.pl | 7 ++++++- > tools/export.pl | 10 ++++++++-- > 4 files changed, 16 insertions(+), 17 deletions(-) > >diff --git a/C4/Csv.pm b/C4/Csv.pm >index 7c8f824..cc88c01 100644 >--- a/C4/Csv.pm >+++ b/C4/Csv.pm >@@ -32,7 +32,6 @@ use vars qw(@ISA @EXPORT); > > @EXPORT = qw( > &GetCsvProfile >- &GetCsvProfileId > &GetMarcFieldsForCsv > ); > >@@ -49,18 +48,6 @@ sub GetCsvProfile { > return ($sth->fetchrow_hashref); > } > >-# Returns id of csv profile about a given csv profile name >-sub GetCsvProfileId { >- my ($name) = @_; >- my $dbh = C4::Context->dbh; >- my $query = "SELECT export_format_id FROM export_format WHERE profile=?"; >- >- $sth = $dbh->prepare($query); >- $sth->execute($name); >- >- return ( $sth->fetchrow ); >-} >- > # Returns fields to extract for the given csv profile > sub GetMarcFieldsForCsv { > >diff --git a/Koha/Exporter/Record.pm b/Koha/Exporter/Record.pm >index ee76d8a..b043411 100644 >--- a/Koha/Exporter/Record.pm >+++ b/Koha/Exporter/Record.pm >@@ -7,6 +7,7 @@ use MARC::File::USMARC; > use C4::AuthoritiesMarc; > use C4::Biblio; > use C4::Record; >+use Koha::CsvProfiles; > > sub _get_record_for_export { > my ($params) = @_; >@@ -133,7 +134,7 @@ sub export { > print MARC::File::XML::footer(); > print "\n"; > } elsif ( $format eq 'csv' ) { >- $csv_profile_id ||= C4::Csv::GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); >+ $csv_profile_id ||= Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') })->export_format_id; > print marc2csv( $record_ids, $csv_profile_id, $itemnumbers ); > } > >diff --git a/misc/export_records.pl b/misc/export_records.pl >index 2783542..2d24569 100755 >--- a/misc/export_records.pl >+++ b/misc/export_records.pl >@@ -29,6 +29,7 @@ use C4::Record; > > use Koha::Biblioitems; > use Koha::Database; >+use Koha::CsvProfiles; > use Koha::Exporter::Record; > use Koha::DateUtils qw( dt_from_string output_pref ); > >@@ -195,11 +196,15 @@ if ($deleted_barcodes) { > } > } > else { >+ unless ( $csv_profile_id ) { >+ my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); >+ $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef; >+ } > Koha::Exporter::Record::export( > { record_type => $record_type, > record_ids => \@record_ids, > format => $output_format, >- csv_profile_id => ( $csv_profile_id || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ), >+ csv_profile_id => $csv_profile_id, > export_items => (not $dont_export_items), > clean => $clean || 0, > } >diff --git a/tools/export.pl b/tools/export.pl >index f625370..a59caf1 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -191,6 +191,12 @@ if ( $op eq "export" ) { > -attachment => $filename, > ); > >+ my $csv_profile_id = $query->param('csv_profile_id'); >+ unless ( $csv_profile_id ) { >+ my $default_csv_profile = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); >+ $csv_profile_id = $default_csv_profile ? $default_csv_profile->export_format_id : undef; >+ } >+ > Koha::Exporter::Record::export( > { record_type => $record_type, > record_ids => \@record_ids, >@@ -198,7 +204,7 @@ if ( $op eq "export" ) { > filename => $filename, > itemnumbers => \@itemnumbers, > dont_export_fields => $export_remove_fields, >- csv_profile_id => ( $query->param('csv_profile_id') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ) || undef ), >+ csv_profile_id => $csv_profile_id, > export_items => (not $dont_export_items), > } > ); >@@ -308,7 +314,7 @@ else { > itemtypeloop => \@itemtypesloop, > authority_types => $authority_types, > export_remove_fields => C4::Context->preference("ExportRemoveFields"), >- csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }), >+ csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ], > ); > > output_html_with_http_headers $query, $cookie, $template->output; >-- >2.7.0
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 15451
:
46108
|
46109
|
46110
|
46111
|
46112
|
46113
|
46114
|
46306
|
50178
|
50179
|
50180
|
50181
|
50182
|
50183
|
50184
|
50185
|
50860
|
50861
|
50862
|
50863
|
50864
|
50865
|
50866
|
50867
|
50868
|
50985
|
53623
|
53624
|
53625
|
53626
|
53627
|
53628
|
53629
|
53630
|
53631
|
53641