Bugzilla – Attachment 98429 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]
Add plugin hook addbiblio_check_record
0001-Bug-24589-Add-plugin-hook-addbiblio_check_record.patch (text/plain), 3.33 KB, created by
paxed
on 2020-02-05 08:21:32 UTC
(
hide
)
Description:
Add plugin hook addbiblio_check_record
Filename:
MIME Type:
Creator:
paxed
Created:
2020-02-05 08:21:32 UTC
Size:
3.33 KB
patch
obsolete
>From 82d0a551117be224a72dec51e9eb5129dca1a060 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 a548bab8a6..16fe5b1bf5 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; >@@ -827,6 +829,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 8904afaa5a..e96a4a0a8d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -650,6 +650,16 @@ > </div> > [% END %] > >+ [% IF marc_format_errors %] >+ <div class="dialog alert"> >+ <ul> >+ [% FOREACH MARC_ERR IN marc_format_errors %] >+ <li>[% MARC_ERR %]</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