From 8151a1fc9126b93b7dc3d47b3bdeebda1439e425 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Fri, 1 Aug 2025 16:06:30 +0200 Subject: [PATCH] Bug 40578: C4/Heading/UNIMARC.pm does deal with authorities TEST PLAN ON AN UNIMARC INSTANCE: 1 - Run tests, they don't work 2 - Run test plan of BZ30047 3 - Run tests, they now work --- C4/Heading/UNIMARC.pm | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/C4/Heading/UNIMARC.pm b/C4/Heading/UNIMARC.pm index 1021f06aa..c5ed5c573 100644 --- a/C4/Heading/UNIMARC.pm +++ b/C4/Heading/UNIMARC.pm @@ -55,6 +55,7 @@ my %subdivisions = ( ); my $bib_heading_fields; +my $auth_heading_fields; =head1 METHODS @@ -84,6 +85,23 @@ sub new { } } + unless ( defined $auth_heading_fields ) { + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( + "SELECT tagfield, authtypecode + FROM auth_tag_structure + WHERE authtypecode <> ''" + ); + $sth->execute(); + $auth_heading_fields = {}; + while ( my ( $tag, $auth_type ) = $sth->fetchrow ) { + $auth_heading_fields->{$tag} = { + auth_type => $auth_type, + subfields => 'abcdefghjklmnopqrstvxyz', + }; + } + } + return bless {}, $class; } @@ -92,8 +110,12 @@ sub new { =cut sub valid_heading_tag { - my ( $self, $tag ) = @_; - return $bib_heading_fields->{$tag}; + my ( $self, $tag, $frameworkcode, $auth ) = @_; + unless ($auth) { + return $bib_heading_fields->{$tag}; + } else { + return $auth_heading_fields->{$tag}; + } } =head2 valid_heading_subfield @@ -116,10 +138,12 @@ sub valid_heading_subfield { =cut sub parse_heading { - my ( $self, $field ) = @_; + my ( $self, $field, $auth ) = @_; + + my $tag = $field->tag; + my $heading_fields = $auth ? {%$auth_heading_fields} : {%$bib_heading_fields}; + my $field_info = $heading_fields->{$tag}; - my $tag = $field->tag; - my $field_info = $bib_heading_fields->{$tag}; my $auth_type = $field_info->{'auth_type'}; my $search_heading = _get_search_heading( $field, $field_info->{'subfields'} ); my $display_heading = _get_display_heading( $field, $field_info->{'subfields'} ); -- 2.30.2