From 63d121e5750c452880c4166a3d3022e8042817fb Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 20 Jul 2020 11:09:01 -0300 Subject: [PATCH] Bug 5087: (QA follow-up) Rename the attribute to fit later API usage This patch renames the introduced attribute for later usage on the API, and changes the logic to use it the other way around. It also adds a KEY for the flag, as it will be used in WHERE statements. Signed-off-by: Tomas Cohen Arazi --- Koha/Schema/Result/ExportFormat.pm | 10 +++++----- ...87_-_add_opac_option_field_to_export_formats.perl | 10 +++++++--- installer/data/mysql/kohastructure.sql | 5 +++-- .../prog/en/modules/tools/csv-profiles.tt | 8 ++++---- opac/opac-basket.pl | 6 +++++- opac/opac-downloadcart.pl | 12 +++++++++++- tools/csv-profiles.pl | 6 +++--- 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Koha/Schema/Result/ExportFormat.pm b/Koha/Schema/Result/ExportFormat.pm index 1816f0d2ea..675c6e2738 100644 --- a/Koha/Schema/Result/ExportFormat.pm +++ b/Koha/Schema/Result/ExportFormat.pm @@ -85,7 +85,7 @@ __PACKAGE__->table("export_format"); is_nullable: 1 size: 255 -=head2 opac_option +=head2 staff_only data_type: 'tinyint' default_value: 0 @@ -129,7 +129,7 @@ __PACKAGE__->add_columns( is_nullable => 1, size => 255, }, - "opac_option", + "staff_only", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, ); @@ -146,8 +146,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("export_format_id"); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-04-20 20:08:25 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:J2VDj9yI8uanFR9EGv2sXw +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-07-20 14:15:46 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:O8kM+dd6GTS2qS39lnDG1g sub koha_object_class { 'Koha::CsvProfile'; @@ -157,7 +157,7 @@ sub koha_objects_class { } __PACKAGE__->add_columns( - '+opac_option' => { is_boolean => 1 }, + '+staff_only' => { 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 index c2b4021552..7eaffd409d 100644 --- 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 @@ -1,8 +1,12 @@ $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|); + unless( column_exists( 'export_format', 'staff_only' ) ) { + $dbh->do(q| + ALTER TABLE export_format + ADD staff_only TINYINT(1) NOT NULL DEFAULT 0 AFTER used_for, + ADD KEY `staff_only_idx` (`staff_only`); + |); } - NewVersion( $DBversion, 5087, "Add export_format.opac_option" ); + NewVersion( $DBversion, 5087, "Add export_format.staff_only" ); } diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c392dc6a47..1c8758a8a7 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -689,8 +689,9 @@ CREATE TABLE `export_format` ( `encoding` varchar(255) NOT NULL DEFAULT 'utf8', `type` varchar(255) DEFAULT 'marc', `used_for` varchar(255) DEFAULT 'export_records', - `opac_option` TINYINT(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`export_format_id`) + `staff_only` TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`export_format_id`), + KEY `staff_only_idx` (`staff_only`) ) 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 55f7f7afc9..1d2dbfd2d0 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 @@ -193,11 +193,11 @@
  • - - [% IF csv_profile.opac_option %] - + + [% IF csv_profile.staff_only %] + [% ELSE %] - + [% END %]
  • diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index 51ece6cd2e..1713de4993 100755 --- a/opac/opac-basket.pl +++ b/opac/opac-basket.pl @@ -166,7 +166,11 @@ my $resultsarray = \@results; # my $itemsarray=\@items; $template->param( - csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records', opac_option => 1 }) ], + csv_profiles => [ + Koha::CsvProfiles->search( + { type => 'marc', used_for => 'export_records', staff_only => 0 } + ) + ], bib_list => $bib_list, BIBLIO_RESULTS => $resultsarray, ); diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl index 671542a517..7720cd461e 100755 --- a/opac/opac-downloadcart.pl +++ b/opac/opac-downloadcart.pl @@ -124,7 +124,17 @@ if ($bib_list && $format) { print $output; } else { - $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records', opac_option => 1 }) ]); + $template->param( + csv_profiles => [ + Koha::CsvProfiles->search( + { + type => 'marc', + used_for => 'export_records', + staff_only => 0 + } + ) + ] + ); $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 b1bbcba6cd..284fdc17ce 100755 --- a/tools/csv-profiles.pl +++ b/tools/csv-profiles.pl @@ -84,7 +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"); + my $staff_only = $input->param("staff_only") ? 1 : 0; if ($export_format_id) { my $csv_profile = Koha::CsvProfiles->find($export_format_id) @@ -98,7 +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); + $csv_profile->staff_only($staff_only); eval { $csv_profile->store; }; if ($@) { @@ -117,7 +117,7 @@ if ( $op eq 'add_form' ) { encoding => $encoding, type => $type, used_for => $used_for, - opac_option => $opac_option + staff_only => $staff_only } ); eval { $csv_profile->store; }; -- 2.27.0