@@ -, +, @@ adding/updating bibliographic records --- cataloguing/addbiblio.pl | 12 ++ ...lio-marc-modification-template-syspref.sql | 1 + installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/cataloguing.pref | 5 + svc/bib | 13 ++ ...BiblioMarcModificationTemplatePreference.t | 154 ++++++++++++++++++ 6 files changed, 186 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.sql create mode 100644 t/db_dependent/www/EditBiblioMarcModificationTemplatePreference.t --- a/cataloguing/addbiblio.pl +++ a/cataloguing/addbiblio.pl @@ -44,6 +44,7 @@ use MARC::Record; use C4::ClassSource qw( GetClassSources ); use C4::ImportBatch qw( GetImportRecordMarc ); use C4::Charset qw( SetMarcUnicodeFlag ); +use C4::MarcModificationTemplates; use Koha::BiblioFrameworks; use Koha::DateUtils qw( dt_from_string ); @@ -58,6 +59,7 @@ use Koha::UI::Form::Builder::Biblio; use MARC::File::USMARC; use MARC::File::XML; use URI::Escape qw( uri_escape_utf8 ); +use List::MoreUtils qw(firstval); if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { MARC::File::XML->default_record_format('UNIMARC'); @@ -659,6 +661,16 @@ if ( $op eq "addbiblio" ) { # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate) if ( !$duplicatebiblionumber or $confirm_not_duplicate ) { my $oldbibitemnum; + my $marc_modification_template_name = C4::Context->preference("SaveBiblioMarcModificationTemplate"); + 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 ) { my $member = Koha::Patrons->find($loggedinuser); ModBiblio( --- 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 ('SaveBiblioMarcModificationTemplate', '', NULL, 'MARC modification template applied when saving bibliographic record in staff client or HTTP API', 'Free'); --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/installer/data/mysql/mandatory/sysprefs.sql @@ -645,6 +645,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RoutingListNote','To change this note edit RoutingListNote system preference.','70|10','Define a note to be shown on all routing lists','Textarea'), ('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'), ('SavedSearchFilters', '0', NULL, 'Allow staff with permission to create/edit custom search filters', 'YesNo'), +('SaveBiblioMarcModificationTemplate', '', NULL, 'MARC modification template applied when saving bibliographic record in staff client or HTTP API', 'Free'), ('SCOAllowCheckin','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'), ('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea'), ('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded