Bugzilla – Attachment 99976 Details for
Bug 24589
Add plugin hook addbiblio_check_record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24589: Add plugin hook addbiblio_check_record
0001-Bug-24589-Add-plugin-hook-addbiblio_check_record.patch (text/plain), 3.34 KB, created by
paxed
on 2020-03-03 08:13:31 UTC
(
hide
)
Description:
Bug 24589: Add plugin hook addbiblio_check_record
Filename:
MIME Type:
Creator:
paxed
Created:
2020-03-03 08:13:31 UTC
Size:
3.34 KB
patch
obsolete
>From 25658719905eb70b5e3c7ef052966b549d7ddde1 Mon Sep 17 00:00:00 2001 >From: Pasi Kallinen <pasi.kallinen@koha-suomi.fi> >Date: Wed, 5 Feb 2020 09:32:38 +0200 >Subject: [PATCH] Bug 24589: Add plugin hook addbiblio_check_record > >Adds a new plugin hook, addbiblio_check_record, to addbiblio.pl. >When saving a record, the hook is called with the MARC record as >a parameter. If the hook returns anything, the return values are >shown to the user, and saving the record is prevented. > >This can be used to create plugins that eg. check or modify the record. > >Advanced editor has not been changed. >--- > cataloguing/addbiblio.pl | 30 ++++++++++++++++++++++ > .../prog/en/modules/cataloguing/addbiblio.tt | 10 ++++++++ > 2 files changed, 40 insertions(+) > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index cd53c66e70..ae6da5cd58 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -41,6 +41,8 @@ use Koha::ItemTypes; > use Koha::Libraries; > > use Koha::BiblioFrameworks; >+use Koha::Plugins; >+use Koha::Plugins::Handler; > > use Date::Calc qw(Today); > use MARC::File::USMARC; >@@ -832,6 +834,34 @@ if ( $op eq "addbiblio" ) { > # getting html input > my @params = $input->multi_param(); > $record = TransformHtmlToMarc( $input, 1 ); >+ >+ if ( $record ne '-1' && C4::Context->preference('UseKohaPlugins') && >+ C4::Context->config('enable_plugins') ) { >+ my @formaterrors; >+ my @plugins = Koha::Plugins->new()->GetPlugins({ >+ method => 'addbiblio_check_record' >+ }); >+ foreach my $plugin (@plugins) { >+ push(@formaterrors, @{$plugin->addbiblio_check_record($record)}); >+ } >+ if (scalar(@formaterrors) > 0) { >+ $template->param( >+ marc_format_errors => \@formaterrors, >+ title => $record->title, >+ popup => $mode, >+ frameworkcode => $frameworkcode, >+ itemtype => $frameworkcode, >+ borrowernumber => $loggedinuser, >+ biblionumber => $biblionumber, >+ tab => scalar $input->param('tab') >+ ); >+ $template->{'VARS'}->{'searchid'} = $searchid; >+ build_tabs ($template, $record, $dbh,$encoding,$input); >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+ } >+ } >+ > # check for a duplicate > my ( $duplicatebiblionumber, $duplicatetitle ); > if ( !$is_a_modif ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >index 4fda2747a9..2ab129730b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -687,6 +687,16 @@ > </div> > [% END %] > >+ [% IF marc_format_errors %] >+ <div class="dialog alert"> >+ <ul> >+ [% FOREACH MARC_ERR IN marc_format_errors %] >+ <li>[% MARC_ERR | html %]</li> >+ [% END %] >+ </ul> >+ </div> >+ [% END %] >+ > [% IF ( popup ) %] > <input type="hidden" name="mode" value="popup" /> > [% END %] >-- >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 24589
:
98429
|
98447
| 99976