}
use Carp;
+use Try::Tiny;
use Encode qw( decode is_utf8 );
use List::MoreUtils qw( uniq );
use Koha::Biblio::Metadatas;
use Koha::Holds;
use Koha::ItemTypes;
+use Koha::Plugins;
use Koha::SearchEngine;
use Koha::Libraries;
use Koha::Util::MARC;
C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
}
+ _after_biblio_action_hooks({ action => 'create', biblio_id => $biblionumber });
+
logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
return ( $biblionumber, $biblioitemnumber );
}
_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
+ _after_biblio_action_hooks({ action => 'modify', biblio_id => $biblionumber });
+
# update OAI-PMH sets
if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
# from being generated by _koha_delete_biblioitems
$error = _koha_delete_biblio( $dbh, $biblionumber );
+ _after_biblio_action_hooks({ action => 'delete', biblio_id => $biblionumber });
+
logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
return;
$m_rs->store;
ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
+
return $biblionumber;
}
1;
+=head2 _after_biblio_action_hooks
+
+Helper method that takes care of calling all plugin hooks
+
+=cut
+
+sub _after_biblio_action_hooks {
+ my ( $args ) = @_;
+
+ my $biblio_id = $args->{biblio_id};
+ my $action = $args->{action};
+
+ if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
+
+ my @plugins = Koha::Plugins->new->GetPlugins({
+ method => 'after_biblio_action',
+ });
+
+ if (@plugins) {
+
+ my $biblio = Koha::Biblios->find( $biblio_id );
+
+ foreach my $plugin ( @plugins ) {
+ try {
+ $plugin->after_biblio_action({ action => $action, biblio => $biblio, biblio_id => $biblio_id });
+ }
+ catch {
+ warn "$_";
+ };
+ }
+ }
+ }
+}
+
__END__
=head1 AUTHOR
}
use Carp;
+use Try::Tiny;
use C4::Context;
use C4::Koha;
use C4::Biblio;
logaction( "CATALOGUING", "ADD", $itemnumber, "item" )
if C4::Context->preference("CataloguingLog");
+ _after_item_action_hooks({ action => 'create', item_id => $itemnumber });
+
return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber );
}
# item status is possible
ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
+ _after_item_action_hooks({ action => 'modify', item_id => $itemnumber });
+
logaction( "CATALOGUING", "MODIFY", $itemnumber, "item " . Dumper($item) )
if $log_action && C4::Context->preference("CataloguingLog");
}
ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
+ _after_item_action_hooks({ action => 'delete', item_id => $itemnumber });
+
#search item field code
logaction("CATALOGUING", "DELETE", $itemnumber, "item") if C4::Context->preference("CataloguingLog");
return $deleted;
return $report;
}
+=head2 _after_item_action_hooks
+
+Helper method that takes care of calling all plugin hooks
+
+=cut
+
+sub _after_item_action_hooks {
+ my ( $args ) = @_;
+
+ my $item_id = $args->{item_id};
+ my $action = $args->{action};
+
+ if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
+
+ my @plugins = Koha::Plugins->new->GetPlugins({
+ method => 'after_item_action',
+ });
+
+ if (@plugins) {
+
+ my $item = Koha::Items->find( $item_id );
+
+ foreach my $plugin ( @plugins ) {
+ try {
+ $plugin->after_item_action({ action => $action, item => $item, item_id => $item_id });
+ }
+ catch {
+ warn "$_";
+ };
+ }
+ }
+ }
+}
1;