@@ -, +, @@ adding/updating bibliographic records --- cataloguing/addbiblio.pl | 14 +++++++++++++- ...8138-edit-biblio-marc-modification-template-syspref.sql | 1 + .../prog/en/modules/admin/preferences/cataloguing.pref | 5 +++++ svc/bib | 13 +++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.sql --- a/cataloguing/addbiblio.pl +++ a/cataloguing/addbiblio.pl @@ -34,6 +34,7 @@ use C4::Koha; use C4::ClassSource; use C4::ImportBatch; use C4::Charset; +use C4::MarcModificationTemplates; use Koha::BiblioFrameworks; use Koha::DateUtils; @@ -45,6 +46,7 @@ use Date::Calc qw(Today); use MARC::File::USMARC; use MARC::File::XML; use URI::Escape; +use List::MoreUtils qw(firstval); if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { MARC::File::XML->default_record_format('UNIMARC'); @@ -835,7 +837,17 @@ if ( $op eq "addbiblio" ) { my $oldbibitemnum; if (C4::Context->preference("BiblioAddsAuthorities")){ BiblioAutoLink( $record, $frameworkcode ); - } + } + my $marc_modification_template_name = C4::Context->preference("EditBiblioMarcModificationTemplate"); + if ($marc_modification_template_name) { + my $template = firstval { $_->{'name'} eq $marc_modification_template_name } GetModificationTemplates(); + if ($template) { + ModifyRecordWithTemplate($template->{'template_id'}, $record); + } + else { + warn "No MARC modification template exists with name \"$marc_modification_template_name\""; + } + } if ( $is_a_modif ) { ModBiblio( $record, $biblionumber, $frameworkcode ); } --- a/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.sql +++ a/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.sql @@ -0,0 +1, @@ +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES ('EditBiblioMarcModificationTemplate', '', '', 'MARC modification template applied when saving bibliographic record in staff client or HTTP API', 'Free'); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -125,6 +125,11 @@ Cataloging: - 'MARC21: "952$a 952$b 952$c"' - Note that the FA framework is excluded from the permission. - If the pref is empty, no fields are restricted. + - + - Apply the MARC modification template with name + - pref: EditBiblioMarcModificationTemplate + class: short + - on records saved using the staff client simple MARC editor, advanced editor or HTTP API. Display: - - 'Separate multiple displayed authors, series or subjects with ' --- a/svc/bib +++ a/svc/bib @@ -26,7 +26,9 @@ use CGI qw ( -utf8 ); use C4::Auth qw/check_api_auth/; use C4::Biblio; use C4::Items; +use C4::MarcModificationTemplates; use XML::Simple; +use List::MoreUtils qw(firstval); my $query = new CGI; binmode STDOUT, ':encoding(UTF-8)'; @@ -112,6 +114,17 @@ sub update_bib { } } + my $marc_modification_template_name = C4::Context->preference("EditBiblioMarcModificationTemplate"); + if ($marc_modification_template_name) { + my $template = firstval { $_->{'name'} eq $marc_modification_template_name } GetModificationTemplates(); + if ($template) { + ModifyRecordWithTemplate($template->{'template_id'}, $record); + } + else { + warn "No MARC modification template exists with name \"$marc_modification_template_name\""; + } + } + ModBiblio( $record, $biblionumber, '' ); my $new_record = GetMarcBiblio( $biblionumber, $query->url_param('items') ); --