If you add or alter an authority record and edit one of the MARC fields in UNIMARC 5XX 'See Also Reference Tracing Block' [1], you can click on the ellipsis (...) next to a subfield [2] to launch the authority finder plugin. This plugin allows you to search for an authority and then pick an entry from the 'Special relationship:' dropdown menu in order to set the relationship between the two authorities. The results list of the authority finder contains 'Choose' buttons which _should_ insert all data from the chosen authority into the appropriate subfields of the MARC tag you are editing [3]. However, in UNIMARC setups this does not work: clicking on 'Choose' only populates subfield $a ('Entry Element') with data, but not subfields $3 and $5 ('Authority Record Number' and 'Tracing Control', respectively), which are just as important for correct authority linking. I've tracked this down to these lines of code which are MARC21-specific and use hardcoded subfield values in blinddetail-biblio-search.pl: 91 for ( $field->subfields ) { 92 next if $_->[0] eq '9'; # $9 will be set with authid value 101 push( @subfield_loop, { marc_subfield => 'w', marc_values => $relationship } ) if ( $relationship ); There is also this code in the template blinddetail-biblio-search.tt: 38 [%- END -%]‡9[% authid | html %]"; 138 if(code.value=='9'){ 139 subfield.value = "[% authid |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"; These code fragments don't work 100% because in UNIMARC authorities the authid value is stored in subfield $3 and the relationship code in $5. I propose to modify the Perl script above (which is currently MARC flavour agnostic), have it check the 'marcflavour' system preference, and use that to decide which subfield to push the authority relator code to. A similar approach in the template file will set the authid subfield value depending on whether you are a MARC21 or UNIMARC user. [1] Known as the 'Related Access Point Block' in recent IFLA updates. [2] For the ellipsis to appear next to a subfield, you must view the MARC structure of the relevant authority type and then edit the subfields of the tag you're interested in. Finally, you must select an authority type from the 'Thesaurus:' dropdown menu. [3] Under the hood each 'Choose' button is a call to the JS function doauth(), which in turn calls blinddetail-biblio-search.pl with the parameters required (authid, relationship, etc.).
Created attachment 79609 [details] [review] Bug 21453: blinddetail-biblio-search.pl/.tt use hardcoded subfield values for MARC21 When using the authority finder plugin, you can pick an entry from the 'Special relationship:' dropdown menu in order to set the relationship between authorities. If you're on a UNIMARC setup and click one of the 'Choose' buttons for the search results, only subfield $a (i.e. 'Entry Element') will be copied over to the authority tag you are editing. In MARC21 installs, however, all the authority data plus the authority id are correctly copied over. This is due to hardcoded subfield values in blinddetail-biblio-search{.pl,.tt} which are MARC21-specific. This patch fixes that by checking the 'marcflavour' system preference and selecting the correct subfields to copy the authority data to. Test plan (steps 0-4 are common to both UNIMARC and MARC21 setups): 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'. c) 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. 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: all subfields are populated correctly. UNIMARC: notice how subfields $3 and $5 are not populated. 6) Apply the patch (you may have to restart Plack, too). 7) Repeat steps 3) and 4) above. MARC21: all subfields are populated correctly, same as before. UNIMARC: both the relator code and the authority id are copied over along with any other subfields that may exist.
A colleague has found a case where the patch does not work as intended and may break some setups: when the authority finder is used from within the bibliographic editor (e.g. to link an authority to UNIMARC tag 700), it will populate field $3 ('Authority Record Number') with the auth id but not field $9 ('Koha Internal Code') as it did prior to the patch. I'll try to revise my patch and provide a more thorough test plan.
I've amended my patch and reworded some parts of the commit message that were ambiguous. The patch now takes NORMARC into account as well, which is similar to MARC21 from what I gather by reading the following: https://wiki.koha-community.org/wiki/Add_support_for_NORMARC#Code_changes http://lists.koha-community.org/pipermail/koha-devel/2010-July/034257.html https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11611#c9
Created attachment 80140 [details] [review] 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).
With regards to steps 3 & 4 above: the 'Choose' buttons in results pages other than 1 will not work because the 'source' parameter is missing from the URL pointed to by the pagination hyperlinks. I've added the 'source' parameter to the pagination URLs in a separate bug report (Bug 21880) that fixes a different issue. Therefore, I am marking #21880 as a dependency, hoping that it will be easier to follow the test plan this way.
Comment on attachment 80140 [details] [review] Bug 21453: blinddetail-biblio-search.pl/.tt use hardcoded subfield values for MARC21 Review of attachment 80140 [details] [review]: ----------------------------------------------------------------- ::: authorities/blinddetail-biblio-search.pl @@ +92,4 @@ > # Get all values for each distinct subfield and add to subfield loop > my %done_subfields; > for ( $field->subfields ) { > + next if $_->[0] eq '3'; # $3 will be set with authid value (in UNIMARC authorities) UNIMARC isn't checked. Bad expression? @@ +129,3 @@ > $template->param( > + source => $source, > + marcflavour => $marcflavour, There is no need to pass a systempreference. ::: koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt @@ +35,5 @@ > [%- FOREACH marc_value IN SUBFIELD_LOO.marc_values -%] > [%- marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html -%] > [%- END -%] > + [%- END -%][% IF ( marcflavour == 'UNIMARC' ) %]‡3[% authid %]"; > + [% ELSIF ( marcflavour == 'MARC21' ) || ( marcflavour == 'NORMARC' ) %]‡9[% authid %]"; The filter is removed. QA Fail. @@ +137,4 @@ > [% IF ( clear ) %] > if (subfield){subfield.value="" ;} > [% ELSE %] > + [% IF ( marcflavour == 'UNIMARC' ) %] Perhaps something like [% marcflavour = Koha.Preference('marcflavour') %] near the top? To avoid passing this as a parameter?