From 1a14a0539affc98b0a0a9a50abc25b9279dac376 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 Dec 2021 15:35:25 +0100 Subject: [PATCH] Bug 29695: Remove GetColumnDefs C4::Templates::GetColumnDefs can easily be replaced using the new Koha::Database::Columns module. Test plan: Go to the import patron tool and confirm that you see the same list of patron's attribute on the import patron form. Signed-off-by: Owen Leonard Signed-off-by: Tomas Cohen Arazi Signed-off-by: Fridolin Somers --- C4/Templates.pm | 47 ------------------- .../prog/en/modules/tools/import_borrowers.tt | 29 ++++++------ .../prog/js/pages/preferences.js | 2 +- t/db_dependent/Templates.t | 35 ++++++-------- tools/import_borrowers.pl | 6 +-- 5 files changed, 31 insertions(+), 88 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index 2aef2b27c4..1d0156837b 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -355,51 +355,4 @@ sub getlanguagecookie { return $cookie; } -=head2 GetColumnDefs - - my $columns = GetColumnDefs( $cgi ) - -It is passed a CGI object and returns a hash of hashes containing -the column names and descriptions for each table defined in the -columns.def file corresponding to the CGI object. - -=cut - -sub GetColumnDefs { - - my $query = shift; - - my $columns = {}; - - my $htdocs = C4::Context->config('intrahtdocs'); - my $columns_file = 'columns.def'; - - # Get theme and language to build the path to columns.def - my ($theme, $lang, $availablethemes) = - themelanguage($htdocs, 'about.tt', 'intranet', $query); - # Build columns.def path - my $path = "$htdocs/$theme/$lang/$columns_file"; - my $fh; - if ( ! open ( $fh, q{<:encoding(utf-8)}, $path ) ) { - carp "Error opening $path. Check your templates."; - return; - } - # Loop through the columns.def file - while ( my $input = <$fh> ){ - chomp $input; - if ( $input =~ m|(.*)| ) { - my ( $table, $column ) = split( '\.', $1); - my $description = $2; - # Initialize the table array if needed. - @{$columns->{ $table }} = () if ! defined $columns->{ $table }; - # Push field and description - push @{$columns->{ $table }}, - { field => $column, description => $description }; - } - } - close $fh; - - return $columns; -} - 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt index b55773fa8a..0aa898d484 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt @@ -246,36 +246,35 @@