From b7af5691b530253dc6ba599c4660b4fe14b14246 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Fri, 11 May 2012 11:59:42 +0200 Subject: [PATCH] Bug 8071: link between bib and authorities with the authid I have in a database authorities (marcxml.auth_header) $90 in the tag 2XX So when I want link a bib record with a auth record, koha create the link with the $90 in the tag 2XX and not with the authid from auth_header. Result in the thesaurus all the link are bad In fact, merge should not report $9 in record_to And when choosing an authority, it should not report the $9 from "heading" And when displaying on detail.pl, if $9 contains that erroneous data, it should not be displayed --- C4/AuthoritiesMarc.pm | 2 +- C4/Biblio.pm | 18 +++++++++++++----- authorities/blinddetail-biblio-search.pl | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 8660488..51c9807 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1353,7 +1353,7 @@ sub merge { if ($auth_number==$mergefrom) { my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); my $exclude='9'; - foreach my $subfield (@record_to) { + foreach my $subfield (grep {$_->[0] ne 9} @record_to) { $field_to->add_subfields($subfield->[0] =>$subfield->[1]); $exclude.= $subfield->[0]; } diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 56cd94e..e343239 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1675,10 +1675,13 @@ sub GetMarcSubjects { if ( $counter != 0 ) { $operator = ' and '; } - if ( $code eq 9 ) { + if ( $code eq 9 and $linkvalue ne " 0 ") { $found9 = 1; @link_loop = ( { 'limit' => 'an', link => "$linkvalue" } ); } + if ( $code eq 9 and $linkvalue eq " 0 ") { + next; + } if ( not $found9 ) { push @link_loop, { 'limit' => $subject_limit, link => $linkvalue, operator => $operator }; } @@ -1734,7 +1737,7 @@ sub GetMarcAuthors { my $count_auth = 0; # if there is an authority link, build the link with Koha-Auth-Number: subfield9 - my $subfield9 = $field->subfield('9'); + my $found9 ; for my $authors_subfield (@subfields) { # don't load unimarc subfields 3, 5 @@ -1749,9 +1752,14 @@ sub GetMarcAuthors { } # if we have an authority link, use that as the link, otherwise use standard searching - if ($subfield9) { - @link_loop = ( { 'limit' => 'an', link => "$subfield9" } ); - } else { + if ( $subfieldcode eq 9 and $linkvalue ne " 0 ") { + $found9 = 1; + @link_loop = ( { 'limit' => 'an', link => "$linkvalue" } ); + } + if ( not $found9 ) { + push @link_loop, { 'limit' => 'au', link => $linkvalue, operator => $operator }; + } + unless ($found9){ # reset $linkvalue if UNIMARC author responsibility if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] eq "4" ) ) { diff --git a/authorities/blinddetail-biblio-search.pl b/authorities/blinddetail-biblio-search.pl index 7de7db3..469676a 100755 --- a/authorities/blinddetail-biblio-search.pl +++ b/authorities/blinddetail-biblio-search.pl @@ -84,6 +84,7 @@ if ($authid) { # Get all values for each distinct subfield my %subfields; for ( $field->subfields ) { + next if $_->[0] == "9"; my $letter = $_->[0]; next if defined $subfields{$letter}; my @values = $field->subfield($letter); -- 1.7.2.5