Bugzilla – Attachment 180268 Details for
Bug 21453
blinddetail-biblio-search.pl/.tt use hardcoded subfield values for MARC21
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21453: copy data to the correct subfields when linking authorities with authorities
Bug-21453-copy-data-to-the-correct-subfields-when-.patch (text/plain), 8.89 KB, created by
Andreas Roussos
on 2025-04-02 09:09:52 UTC
(
hide
)
Description:
Bug 21453: copy data to the correct subfields when linking authorities with authorities
Filename:
MIME Type:
Creator:
Andreas Roussos
Created:
2025-04-02 09:09:52 UTC
Size:
8.89 KB
patch
obsolete
>From 628ac369bc9f0d931fab376af9d250c80ad09865 Mon Sep 17 00:00:00 2001 >From: Andreas Roussos <a.roussos@dataly.gr> >Date: Wed, 2 Apr 2025 09:01:56 +0000 >Subject: [PATCH] Bug 21453: copy data to the correct subfields when linking > authorities with authorities > >When using the authority finder plugin from within Koha's >Authorities module, you can pick an entry from the 'Special >relationship:' dropdown menu in order to set the relationship >between authorities. > >The problem is that in UNIMARC setups, when you click on >'Choose' to select an authority, it does not populate >subfields $3 (Authority Record Number) and $5 (Tracing >Control), which are required for authority linking and >authority hierarchies to work properly. > >In MARC21, 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 the >'marcflavour' syspref, and then setting the correct >subfields to copy the authority data to. > >Test plan (involves testing in both a MARC21 and a UNIMARC instance): > >0) [PREREQUISITES in order for the authority finder plugin to come up > when testing in a UNIMARC instance] > 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) In MARC21: all subfields are populated correctly. > In UNIMARC: notice how subfields $3 and $5 are *not* populated. > >6) Apply the patch. > >7) Repeat steps 3) and 4) above. > In MARC21: all subfields are populated correctly, as before. > In 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 bibliographic record editor, find a MARC > tag that allows you to search for an authority, and link it. > In MARC21: all authority data is copied over (authid in $9). > In UNIMARC: all authority data is copied over (authid in $9). >--- > authorities/blinddetail-biblio-search.pl | 22 ++++++++++++++++--- > .../authorities/blinddetail-biblio-search.tt | 18 +++++++++++++-- > .../authorities/searchresultlist-auth.tt | 11 +++++----- > 3 files changed, 41 insertions(+), 10 deletions(-) > >diff --git a/authorities/blinddetail-biblio-search.pl b/authorities/blinddetail-biblio-search.pl >index e4c3eb4ceb..b231976283 100755 >--- a/authorities/blinddetail-biblio-search.pl >+++ b/authorities/blinddetail-biblio-search.pl >@@ -55,6 +55,8 @@ my $authid = $query->param('authid'); > my $index = $query->param('index'); > my $tagid = $query->param('tagid'); > my $relationship = $query->param('relationship'); >+my $source = $query->param('source'); >+my $marcflavour = C4::Context->preference("marcflavour"); > > # open template > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -85,7 +87,10 @@ 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 >+ if ( $marcflavour eq 'UNIMARC' ) { >+ next if $_->[0] eq '3'; # $3 will be set with authid value (in UNIMARC authority records) >+ } >+ next if $_->[0] eq '9'; # $9 will be set with authid value > my $letter = $_->[0]; > $letter ||= '@'; > next if defined $done_subfields{$letter}; >@@ -94,7 +99,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' ) { >+ $relationship_subfield = 'w'; >+ } >+ push @subfield_loop, { marc_subfield => $relationship_subfield, marc_values => $relationship }; >+ } > > # Copy the ISNI number over (should one exist) to subfield $o when linking > # authorities with authorities in UNIMARC instances. This only applies to >@@ -142,7 +157,8 @@ $template->param( > indicator2 => $indicator2, > SUBFIELD_LOOP => \@subfield_loop, > tag_number => $tag_number, >- rancor => $index =~ /rancor$/, >+ rancor => ( $index =~ /rancor$/ ) ? 1 : 0, >+ source => $source, > ); > > output_html_with_http_headers $query, $cookie, $template->output; >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 3812099def..2d5ad70bbe 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 >@@ -1,6 +1,8 @@ > [% USE To %] >+[% USE Koha %] > [% PROCESS 'i18n.inc' %] > [% SET footerjs = 1 %] >+[% SET marcflavour = Koha.Preference('marcflavour') %] > [% INCLUDE 'doc-head-open.inc' %] > <title > >[% FILTER collapse %] >@@ -38,7 +40,10 @@ > [%- FOREACH marc_value IN SUBFIELD_LOO.marc_values -%] > [%- To.json( marc_value ) | html -%] > [%- END -%] >- [%- END -%]â¡9[% authid | html %]"; >+ [%- END -%] >+ [% IF ( marcflavour == 'UNIMARC' ) %]â¡3[% authid | html %]"; >+ [% ELSIF ( marcflavour == 'MARC21' ) %]â¡9[% authid | html %]"; >+ [% END %] > [% END %] > RancorReplaceField( new_line, "[% indicator1 | html %]", "[% indicator2 | html %]" ); > [% ELSE %] >@@ -167,7 +172,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' ) %] >+ var authid_subfield = "9"; >+ [% END %] >+ if(code.value==authid_subfield){ > subfield.value = "[% To.json(authid) | $raw %]"; > subfield.className = subfield.className.replace("no_matching_authority_field", "matching_authority_field"); > 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 dd0f402d93..ae078771f9 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 >@@ -154,14 +154,15 @@ > } > > function doauth(authid, index, repet){ >- [% IF source == 'auth' %] >+ var source = "[% source %]"; >+ if ( source == 'auth' ) { > var elem = document.getElementById("special_relationship"); > var relationship = elem.options[elem.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); >+ } > } > </script> > [% END %] >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21453
:
79609
|
80140
| 180268