From 49193c6b926338e4f9d80f3b93ade97ef3b61aad Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 1 Feb 2023 15:03:03 +0100 Subject: [PATCH] Bug 22972: Add another source of authority data to copy in biblio record This patch allows to copy an authority subfield into a biblio record subfield ($1) when cataloging a biblio record and using the authority finder. This can be used to copy standard authority identifiers to the biblio record The subfield is configurable for each authority type. If multiple fields or subfields exist in the authority, they are all copied to the biblio record in separate $1 subfields Test plan (authority types and fields are for MARC21, but this work in UNIMARC too): 1. Edit PERSO_NAME autority type and set "Authority subfield to copy in $1" to: 024$1 2. Check that you have (or create) a PERSO_NAME authority of this type with several 024$1 3. Check that in the biblio framework 700$1 is defined and visible 4. In biblio field 700, choose the above authority. Check that the 024$1 content is present in 700$1 Sponsored-by: Orpheus Instituut Sponsored-by: Rijksmuseum Amsterdam Sponsored-by: Saxion Hogeschool Sponsored-by: Breda University of Applied Sciences Sponsored-by: FotoMuseum Antwerpen Sponsored-by: ModeMuseum Antwerpen Sponsored-by: DIVA Museum for Diamonds, Jewellery and Silver Sponsored-by: Koninklijk Conservatorium Brussel --- admin/authtypes.pl | 3 +++ authorities/blinddetail-biblio-search.pl | 13 +++++++++++++ installer/data/mysql/atomicupdate/bug-22972.pl | 17 +++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + .../prog/en/modules/admin/authtypes.tt | 8 +++++++- 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug-22972.pl diff --git a/admin/authtypes.pl b/admin/authtypes.pl index 3fea873e0d..8e23eafd6a 100755 --- a/admin/authtypes.pl +++ b/admin/authtypes.pl @@ -51,6 +51,7 @@ if ( $op eq 'add_form' ) { my $authtypecode = $input->param('authtypecode'); my $authtypetext = $input->param('authtypetext'); my $auth_tag_to_report = $input->param('auth_tag_to_report'); + my $subfield_to_report_in_1 = $input->param('subfield_to_report_in_1'); my $summary = $input->param('summary'); my $is_a_modif = $input->param('is_a_modif'); @@ -58,6 +59,7 @@ if ( $op eq 'add_form' ) { my $authority_type = Koha::Authority::Types->find($authtypecode); $authority_type->authtypetext($authtypetext); $authority_type->auth_tag_to_report($auth_tag_to_report); + $authority_type->subfield_to_report_in_1($subfield_to_report_in_1); $authority_type->summary($summary); eval { $authority_type->store; }; if ($@) { @@ -70,6 +72,7 @@ if ( $op eq 'add_form' ) { { authtypecode => $authtypecode, authtypetext => $authtypetext, auth_tag_to_report => $auth_tag_to_report, + subfield_to_report_in_1 => $subfield_to_report_in_1, summary => $summary, } ); diff --git a/authorities/blinddetail-biblio-search.pl b/authorities/blinddetail-biblio-search.pl index 1dae908f35..f4536db5e7 100755 --- a/authorities/blinddetail-biblio-search.pl +++ b/authorities/blinddetail-biblio-search.pl @@ -94,6 +94,19 @@ if ($authid) { $done_subfields{$letter} = 1; } + if (my $subfield_to_report_in_1 = $auth_type->subfield_to_report_in_1) { + my ($tag, $code) = split /\$/, $subfield_to_report_in_1; + my @marc_values; + foreach my $field ($record->field($tag)) { + foreach my $subfield ($field->subfield($code)) { + push @marc_values, $subfield; + } + } + if (@marc_values) { + push @subfield_loop, { marc_subfield => '1', marc_values => \@marc_values }; + } + } + push( @subfield_loop, { marc_subfield => 'w', marc_values => $relationship } ) if ( $relationship ); my $controlled_ind = $auth->controlled_indicators({ record => $record, biblio_tag => $tag_number }); diff --git a/installer/data/mysql/atomicupdate/bug-22972.pl b/installer/data/mysql/atomicupdate/bug-22972.pl new file mode 100644 index 0000000000..58cad07b54 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-22972.pl @@ -0,0 +1,17 @@ +use Modern::Perl; + +return { + bug_number => "22972", + description => "Add auth_types.subfield_to_report_in_1", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + unless (column_exists('auth_types', 'subfield_to_report_in_1')) { + $dbh->do(q{ + ALTER TABLE auth_types + ADD COLUMN subfield_to_report_in_1 varchar(5) NOT NULL DEFAULT '' + COMMENT 'Authority subfield to report in biblio $1' + }); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index add4518807..5a36f19f7b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -975,6 +975,7 @@ CREATE TABLE `auth_types` ( `authtypecode` varchar(10) NOT NULL DEFAULT '', `authtypetext` varchar(255) NOT NULL DEFAULT '', `auth_tag_to_report` varchar(3) NOT NULL DEFAULT '', + `subfield_to_report_in_1` varchar(5) NOT NULL DEFAULT '' COMMENT 'Authority subfield to report in biblio $1', `summary` longtext NOT NULL, PRIMARY KEY (`authtypecode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt index e0128143e9..dbd4bf45f9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt @@ -123,14 +123,20 @@
  • -
    Note: for 'Authority field to copy', enter the authority field that should be copied from the authority record to the bibliographic record. E.g., in MARC21, field 100 in the authority record should be copied to field 100 in the bibliographic record
    +
    Note: for 'Authority field to copy', enter the authority field that should be copied from the authority record to the bibliographic record. E.g., in MARC21, field 100 in the authority record should be copied to field 100 in the bibliographic record
    + [% IF authority_type.authtypecode.defined %] [% END %]
  • +
  • + + +
    Enter the authority subfield that should be copied from the authority record to the bibliographic record in $1. E.g., in MARC21, field 024$1 in the authority record should be copied to field 700$1 in the bibliographic record
    +
  • -- 2.30.2