Bugzilla – Attachment 61443 Details for
Bug 18138
Use MARC modification template when adding/updating bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18138: Use MARC modification template when adding/updating bibliographic records
Bug-18138-Use-MARC-modification-template-when-addi.patch (text/plain), 5.42 KB, created by
David Gustafsson
on 2017-03-22 13:11:53 UTC
(
hide
)
Description:
Bug 18138: Use MARC modification template when adding/updating bibliographic records
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2017-03-22 13:11:53 UTC
Size:
5.42 KB
patch
obsolete
>From 965d5a921673f3e3e41d169b198e58286890822b Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Mon, 20 Mar 2017 15:09:13 +0100 >Subject: [PATCH] Bug 18138: Use MARC modification template when > adding/updating bibliographic records > >Add a preference that enables a specific marc modification template to be applied on bibliographic records saved using simple or advanced MARC editor or the HTTP API. > >To test: >1) Create a MARC modification template containg one or more actions. >2) Under "Global system preferences" and "Cataloging" set the "EditBiblioMarcModificationTemplate" preference to the name of the previously created template. >3) Edit (or create) a bibliographic record using either the simple or advanced MARC editor. >4) Save the record. >5) Verify that the action(s) have been applied. > >Sponsored-by: Gothenburg University Library >--- > 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 > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 54950a57de..43952513e7 100755 >--- a/cataloguing/addbiblio.pl >+++ b/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 ); > } >diff --git a/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.sql b/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.sql >new file mode 100644 >index 0000000000..0756e581b8 >--- /dev/null >+++ b/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'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index 1aeadf9860..64c20589af 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/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 ' >diff --git a/svc/bib b/svc/bib >index 789951b5ea..361a652627 100755 >--- a/svc/bib >+++ b/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') ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18138
:
61442
|
61443
|
61734
|
82783
|
86617
|
110266
|
110269
|
110270
|
110272
|
118439
|
118440
|
118441
|
118442
|
118443
|
118444
|
118824
|
120709
|
123125
|
123127
|
123128
|
123129
|
123130
|
123131
|
123132
|
123133
|
123137
|
124466
|
124467
|
124468
|
124469
|
124470
|
124471
|
124472
|
124473
|
124474
|
124475
|
124476
|
124477
|
124478
|
124484
|
124485
|
124486
|
124492
|
124493
|
124991
|
125157
|
148004
|
148005
|
148006
|
148007
|
148008
|
148009
|
157183
|
157184
|
157185
|
157186
|
157187
|
157188
|
157189
|
157190
|
157485
|
157486
|
157487
|
157488
|
157489
|
157490
|
157491
|
158414
|
158415
|
158416
|
158417
|
158418
|
158419
|
158420
|
158421
|
162612
|
162613