From dbc31966abb1389f9a27eeea791d61227332f02c Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Sun, 26 May 2024 23:52:53 +0000 Subject: [PATCH] Bug 36616: Prevent reference headings from being linked to biblio records When the new LinkEstablishedHeadings system preference is enabled, this enhancement will disable the Choose button next to reference authority records in the cataloguing authority plugin search results. Users will still be able to choose established headings, where the 008/09 is set to 'a' or 'f' (established) or '|' (not coded). This works for both Zebra and Elasticsearch. To test: 1) Apply patches and install database updates and restart services 2) Go to Koha Administration -> system preferences. Search for LinkEstablishedHeadings. This should be disabled by default (set to 'All headings'). Change to 'Only established headings' and Save. 3) Create a PERSO_NAME authority record. Set the 008/09 to 'b'. 4) Go to Cataloguing and click New record 5) Go to tab 1 and tag 100. Click the plugin editor for 100$a Personal name. 6) Search for your new PERSON_NAME authority record. Confirm it shows in the results but the Choose button is disabled and cannot be clicked. 7) Edit the authority record and set the 008/09 to 'a'. 8) Repeat steps 4-6. This time the Choose button should be possible to click and insert into the biblio record. 9) If you did the above test plan with Zebra as the search enginge (as set by SearchEngine system preference), test again with Elasticsearch. The steps and outcomes should be the same - you may need to manually rebuild the indexes between changing the 008/09. 10) Confirm tests pass - t/db_dependent/AuthoritiesMarc.t Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind --- C4/AuthoritiesMarc.pm | 7 +++++++ .../prog/en/modules/authorities/searchresultlist-auth.tt | 4 ++++ t/db_dependent/AuthoritiesMarc.t | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index b595230c5d..2c6ea20148 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1177,6 +1177,13 @@ sub BuildSummary { my $direction = $linkage =~ m#/r$# ? 'rtl' : 'ltr'; push @otherscript, { term => $field->as_string($subfields_to_report), category => $category, type => $type, direction => $direction, linkage => $linkage }; } + + # determine if established heading + my $f008 = $record->field('008'); + my $pos09 = $f008 ? substr( $f008->data, 9, 1 ) : ""; + if ( $pos09 eq 'a' or $pos09 eq 'f' or $pos09 eq '|' ) { + $summary{established} = 1; + } } $summary{mainentry} = $authorized[0]->{heading}; $summary{mainmainentry} = $authorized[0]->{hemain}; 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 3becbd9760..43e41828f5 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,7 +99,11 @@ [% loop.count | html %] [% END %] [% ELSE %] + [% IF Koha.Preference('LinkEstablishedHeadings') AND !resul.summary.established %] + Choose + [% ELSE %] Choose + [% END %] [% END %] Edit authority diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t index 3823dd9d5c..1744c34b05 100755 --- a/t/db_dependent/AuthoritiesMarc.t +++ b/t/db_dependent/AuthoritiesMarc.t @@ -40,6 +40,7 @@ $module->mock('GetAuthority', sub { } elsif ($authid eq '2') { $record->add_fields( [ '001', '2' ], + [ '008', '|| aca||aabn | a|a d' ], [ '151', ' ', ' ', a => 'New York (State)' ], [ '551', ' ', ' ', a => 'United States', w => 'g', 9 => '1' ] ); @@ -154,7 +155,8 @@ my $expected_marc21_summary = { 'seefrom' => [], 'label' => 'Geographic Name', 'type' => 'Geographic Name', - 'equalterm' => [] + 'equalterm' => [], + 'established' => '1', }; is_deeply( -- 2.39.2