From 77f0b6a505386acfaed7a3cee44599ee85ccc187 Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Sat, 29 Sep 2018 11:52:08 +0300 Subject: [PATCH] Bug 21453: blinddetail-biblio-search.pl/.tt use hardcoded subfield values for MARC21 When using the authority finder plugin from within the Authorities module, you can pick an entry from the 'Special relationship:' dropdown menu in order to set the relationship between authorities. On a UNIMARC setup, clicking on 'Choose' will not populate subfields $3 (Authority Record Number) and $5 (Tracing Control), which are required for authority linking and hierarchies to work properly. In MARC21 installs, however, all authority data is correctly copied over. This is due to hardcoded subfield values which are MARC21-specific in blinddetail-biblio-search{.pl,.tt}. This patch fixes that by checking the value of 'marcflavour' syspref, and then setting the correct subfields to copy the authority data to. Test plan: 0) [PREREQUISITES in order for the authority finder plugin to come up] a) You must have at least one authority type besides the 'Default'. b) View the MARC structure of the 'Default' auth type, then click on 'Actions->Subfields' for tag 500; click on 'Edit subfields'. Select the subfield 'a' tab, then pick an auth type from the 'Thesaurus:' dropdown menu; click 'Save changes' at the top. 1) In the Staff client, go to Authorities, then click 'New Authority' and pick the 'Default' authority type (or edit an existing auth). 2) When the authority editor comes up, go to tag 500 and expand it. 3) Click on the ellipsis (...) next to subfield $a. 4) When the authority finder comes up, search for an authority, pick a relator code from the 'Special relationship:' dropdown, and then click on the 'Choose' button for one of the authorities you found. 5) MARC21/NORMARC setup: all subfields are populated correctly. UNIMARC setup: notice how subfields $3 and $5 are not populated. 6) Apply the patch. 7) Repeat steps 3) and 4) above. MARC21/NORMARC: all subfields are populated correctly, as before. UNIMARC: both the relator code and the authority id are copied over along with any other subfields that may exist. 8) To ensure that authority linking in the Cataloging module works as before, launch the biblio editor, find a MARC tag that allows you to search for an authority, and link it. MARC21/NORMARC: all authority data is copied over (auth id in $9). UNIMARC: all authority data is copied over (auth id in $9). --- authorities/blinddetail-biblio-search.pl | 22 ++++++++++++++++++---- .../authorities/blinddetail-biblio-search.tt | 15 +++++++++++++-- .../modules/authorities/searchresultlist-auth.tt | 11 ++++++----- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/authorities/blinddetail-biblio-search.pl b/authorities/blinddetail-biblio-search.pl index f8ae22b242..4fcc3e54ed 100755 --- a/authorities/blinddetail-biblio-search.pl +++ b/authorities/blinddetail-biblio-search.pl @@ -57,8 +57,11 @@ my $dbh = C4::Context->dbh; my $authid = $query->param('authid'); my $index = $query->param('index'); my $tagid = $query->param('tagid'); +my $source = $query->param('source'); my $relationship = $query->param('relationship'); +my $marcflavour = C4::Context->preference("marcflavour"); + # open template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -89,7 +92,8 @@ if ($authid) { # Get all values for each distinct subfield and add to subfield loop my %done_subfields; for ( $field->subfields ) { - next if $_->[0] eq '9'; # $9 will be set with authid value + next if $_->[0] eq '3'; # $3 will be set with authid value (in UNIMARC authorities) + next if $_->[0] eq '9'; # $9 will be set with authid value (in MARC21/NORMARC authorities and also MARC21/NORMARC/UNIMARC biblios) my $letter = $_->[0]; $letter ||= '@'; next if defined $done_subfields{$letter}; @@ -98,7 +102,17 @@ if ($authid) { $done_subfields{$letter} = 1; } - push( @subfield_loop, { marc_subfield => 'w', marc_values => $relationship } ) if ( $relationship ); + # If a relationship code has been selected, add it to the appropriate + # subfield of @subfield_loop, depending on the MARC flavour being used. + if ( $relationship ) { + my $relationship_subfield; + if ( $marcflavour eq 'UNIMARC' ) { + $relationship_subfield = '5'; + } elsif ( $marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC' ) { + $relationship_subfield = 'w'; + } + push( @subfield_loop, { marc_subfield => $relationship_subfield, marc_values => $relationship } ) ; + } my $controlled_ind = $auth->controlled_indicators({ record => $record, biblio_tag => $tag_number }); $indicator1 = $controlled_ind->{ind1}; @@ -112,9 +126,9 @@ if ($authid) { $template->param( "clear" => 1 ); } - - $template->param( + source => $source, + marcflavour => $marcflavour, authid => $authid ? $authid : "", index => $index, tagid => $tagid, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt index 2b022d6ace..c1ab361cba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt @@ -35,7 +35,9 @@ [%- FOREACH marc_value IN SUBFIELD_LOO.marc_values -%] [%- marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html -%] [%- END -%] - [%- END -%]‡9[% authid | html %]"; + [%- END -%][% IF ( marcflavour == 'UNIMARC' ) %]‡3[% authid %]"; + [% ELSIF ( marcflavour == 'MARC21' ) || ( marcflavour == 'NORMARC' ) %]‡9[% authid %]"; + [% END %] [% END %] RancorReplaceField( new_line, "[% indicator1 | html %]", "[% indicator2 | html %]" ); [% ELSE %] @@ -135,7 +137,16 @@ [% IF ( clear ) %] if (subfield){subfield.value="" ;} [% ELSE %] - if(code.value=='9'){ + [% IF ( marcflavour == 'UNIMARC' ) %] + [% IF ( source == 'auth' ) %] + var authid_subfield = "3"; + [% ELSIF ( source == 'biblio' ) %] + var authid_subfield = "9"; + [% END %] + [% ELSIF ( marcflavour == 'MARC21' ) || ( marcflavour == 'NORMARC' ) %] + var authid_subfield = "9"; + [% END %] + if(code.value==authid_subfield){ subfield.value = "[% authid |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]"; break; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt index 0ba25accff..d6abf7f1c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt @@ -99,14 +99,15 @@ } function doauth(authid, index, repet){ - [% IF source == 'auth' %] + var source = "[% source %]"; + if ( source == 'auth' ) { var e = document.getElementById("relationship"); var relationship = e.options[e.selectedIndex].value; - jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet + '&relationship=' + relationship); - [% ELSE %] - jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet); - [% END %] + jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet + '&source=' + source + '&relationship=' + relationship); + } else { + jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet + '&source=' + source); + } } [% END %] -- 2.11.0