From 712143d26b680b66898995f931248a41470beccb Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 20 Dec 2018 22:52:59 +0000 Subject: [PATCH] Bug 5087: Ability to define whether CSV profile shows in OPAC To test: 1) Update database 2) Update schema 3) In staff side, go to Tools -> CSV profiles 4) Make a CSV profile with profile type = MARC and usage = Export records 5) Leave 'Show option in OPAC' unchecked and save 6) Go to OPAC and add an item to your cart 7) Click Cart, click Download, confirm that your newly created CSV profile does not show as an option 8) Go back and edit CSV profile on staff side 9) Check the 'Show option in OPAC' checkbox and save 10) Go back to download cart in OPAC 11) Confirm the CSV profile now shows in the dropdown Sponsored-by: Catalyst IT Signed-off-by: Maryse Simard Signed-off-by: Owen Leonard Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart (cherry picked from commit ae3644a5947ea410fc3e8ac8b64307df7d1cbb18) Signed-off-by: Lucas Gass --- Koha/Schema/Result/ExportFormat.pm | 16 ++++++++++++++-- ..._add_opac_option_field_to_export_formats.perl | 8 ++++++++ installer/data/mysql/kohastructure.sql | 3 ++- .../prog/en/modules/tools/csv-profiles.tt | 9 +++++++++ opac/opac-downloadcart.pl | 2 +- tools/csv-profiles.pl | 3 +++ 6 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_5087_-_add_opac_option_field_to_export_formats.perl diff --git a/Koha/Schema/Result/ExportFormat.pm b/Koha/Schema/Result/ExportFormat.pm index 28516cd61a..1816f0d2ea 100644 --- a/Koha/Schema/Result/ExportFormat.pm +++ b/Koha/Schema/Result/ExportFormat.pm @@ -85,6 +85,12 @@ __PACKAGE__->table("export_format"); is_nullable: 1 size: 255 +=head2 opac_option + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + =cut __PACKAGE__->add_columns( @@ -123,6 +129,8 @@ __PACKAGE__->add_columns( is_nullable => 1, size => 255, }, + "opac_option", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, ); =head1 PRIMARY KEY @@ -138,8 +146,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("export_format_id"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YSQshI3mJfO0LsOlwvdIdg +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-20 20:08:25 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:J2VDj9yI8uanFR9EGv2sXw sub koha_object_class { 'Koha::CsvProfile'; @@ -148,4 +156,8 @@ sub koha_objects_class { 'Koha::CsvProfiles'; } +__PACKAGE__->add_columns( + '+opac_option' => { is_boolean => 1 }, +); + 1; diff --git a/installer/data/mysql/atomicupdate/bug_5087_-_add_opac_option_field_to_export_formats.perl b/installer/data/mysql/atomicupdate/bug_5087_-_add_opac_option_field_to_export_formats.perl new file mode 100644 index 0000000000..c2b4021552 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_5087_-_add_opac_option_field_to_export_formats.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( column_exists( 'export_format', 'opac_option' ) ) { + $dbh->do(q|ALTER TABLE export_format ADD opac_option TINYINT(1) NOT NULL DEFAULT 0 AFTER used_for|); + } + + NewVersion( $DBversion, 5087, "Add export_format.opac_option" ); +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 239b66cb2b..429a7e097e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -689,7 +689,8 @@ CREATE TABLE `export_format` ( `encoding` varchar(255) NOT NULL DEFAULT 'utf8', `type` varchar(255) DEFAULT 'marc', `used_for` varchar(255) DEFAULT 'export_records', - PRIMARY KEY (`export_format_id`) + `opac_option` TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`export_format_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Used for CSV export'; -- diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt index 675d8ccea2..55f7f7afc9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt @@ -192,6 +192,15 @@ +
  • + + [% IF csv_profile.opac_option %] + + [% ELSE %] + + [% END %] +
  • +
  • diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl index 35214ea0e9..671542a517 100755 --- a/opac/opac-downloadcart.pl +++ b/opac/opac-downloadcart.pl @@ -124,7 +124,7 @@ if ($bib_list && $format) { print $output; } else { - $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ]); + $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records', opac_option => 1 }) ]); $template->param(bib_list => $bib_list); output_html_with_http_headers $query, $cookie, $template->output; } diff --git a/tools/csv-profiles.pl b/tools/csv-profiles.pl index dd09677676..b1bbcba6cd 100755 --- a/tools/csv-profiles.pl +++ b/tools/csv-profiles.pl @@ -84,6 +84,7 @@ if ( $op eq 'add_form' ) { my $field_separator = $input->param("field_separator"); my $subfield_separator = $input->param("subfield_separator"); my $encoding = $input->param("encoding"); + my $opac_option = $input->param("opac_option"); if ($export_format_id) { my $csv_profile = Koha::CsvProfiles->find($export_format_id) @@ -97,6 +98,7 @@ if ( $op eq 'add_form' ) { $csv_profile->encoding($encoding); $csv_profile->type($type); $csv_profile->used_for($used_for); + $csv_profile->opac_option($opac_option); eval { $csv_profile->store; }; if ($@) { @@ -115,6 +117,7 @@ if ( $op eq 'add_form' ) { encoding => $encoding, type => $type, used_for => $used_for, + opac_option => $opac_option } ); eval { $csv_profile->store; }; -- 2.39.5