View | Details | Raw Unified | Return to bug 22709
Collapse All | Expand All

(-)a/C4/Biblio.pm (+43 lines)
Lines 79-84 BEGIN { Link Here
79
}
79
}
80
80
81
use Carp;
81
use Carp;
82
use Try::Tiny;
82
83
83
use Encode qw( decode is_utf8 );
84
use Encode qw( decode is_utf8 );
84
use List::MoreUtils qw( uniq );
85
use List::MoreUtils qw( uniq );
Lines 103-108 use Koha::Acquisition::Currencies; Link Here
103
use Koha::Biblio::Metadatas;
104
use Koha::Biblio::Metadatas;
104
use Koha::Holds;
105
use Koha::Holds;
105
use Koha::ItemTypes;
106
use Koha::ItemTypes;
107
use Koha::Plugins;
106
use Koha::SearchEngine;
108
use Koha::SearchEngine;
107
use Koha::Libraries;
109
use Koha::Libraries;
108
use Koha::Util::MARC;
110
use Koha::Util::MARC;
Lines 233-238 sub AddBiblio { Link Here
233
        C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
235
        C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
234
    }
236
    }
235
237
238
    _after_biblio_action_hooks({ action => 'create', biblio_id => $biblionumber });
239
236
    logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
240
    logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
237
    return ( $biblionumber, $biblioitemnumber );
241
    return ( $biblionumber, $biblioitemnumber );
238
}
242
}
Lines 318-323 sub ModBiblio { Link Here
318
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
322
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
319
    _koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
323
    _koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
320
324
325
    _after_biblio_action_hooks({ action => 'modify', biblio_id => $biblionumber });
326
321
    # update OAI-PMH sets
327
    # update OAI-PMH sets
322
    if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
328
    if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
323
        C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
329
        C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
Lines 418-423 sub DelBiblio { Link Here
418
    # from being generated by _koha_delete_biblioitems
424
    # from being generated by _koha_delete_biblioitems
419
    $error = _koha_delete_biblio( $dbh, $biblionumber );
425
    $error = _koha_delete_biblio( $dbh, $biblionumber );
420
426
427
    _after_biblio_action_hooks({ action => 'delete', biblio_id => $biblionumber });
428
421
    logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
429
    logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
422
430
423
    return;
431
    return;
Lines 3184-3189 sub ModBiblioMarc { Link Here
3184
    $m_rs->store;
3192
    $m_rs->store;
3185
3193
3186
    ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
3194
    ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
3195
3187
    return $biblionumber;
3196
    return $biblionumber;
3188
}
3197
}
3189
3198
Lines 3440-3445 sub RemoveAllNsb { Link Here
3440
1;
3449
1;
3441
3450
3442
3451
3452
=head2 _after_biblio_action_hooks
3453
3454
Helper method that takes care of calling all plugin hooks
3455
3456
=cut
3457
3458
sub _after_biblio_action_hooks {
3459
    my ( $args ) = @_;
3460
3461
    my $biblio_id = $args->{biblio_id};
3462
    my $action    = $args->{action};
3463
3464
    if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
3465
3466
        my @plugins = Koha::Plugins->new->GetPlugins({
3467
            method => 'after_biblio_action',
3468
        });
3469
3470
        if (@plugins) {
3471
3472
            my $biblio = Koha::Biblios->find( $biblio_id );
3473
3474
            foreach my $plugin ( @plugins ) {
3475
                try {
3476
                    $plugin->after_biblio_action({ action => $action, biblio => $biblio, biblio_id => $biblio_id });
3477
                }
3478
                catch {
3479
                    warn "$_";
3480
                };
3481
            }
3482
        }
3483
    }
3484
}
3485
3443
__END__
3486
__END__
3444
3487
3445
=head1 AUTHOR
3488
=head1 AUTHOR
(-)a/C4/Items.pm (-1 / +40 lines)
Lines 55-60 BEGIN { Link Here
55
}
55
}
56
56
57
use Carp;
57
use Carp;
58
use Try::Tiny;
58
use C4::Context;
59
use C4::Context;
59
use C4::Koha;
60
use C4::Koha;
60
use C4::Biblio;
61
use C4::Biblio;
Lines 224-229 sub AddItem { Link Here
224
    logaction( "CATALOGUING", "ADD", $itemnumber, "item" )
225
    logaction( "CATALOGUING", "ADD", $itemnumber, "item" )
225
      if C4::Context->preference("CataloguingLog");
226
      if C4::Context->preference("CataloguingLog");
226
227
228
    _after_item_action_hooks({ action => 'create', item_id => $itemnumber });
229
227
    return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber );
230
    return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber );
228
}
231
}
229
232
Lines 529-534 sub ModItem { Link Here
529
    # item status is possible
532
    # item status is possible
530
    ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
533
    ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
531
534
535
    _after_item_action_hooks({ action => 'modify', item_id => $itemnumber });
536
532
    logaction( "CATALOGUING", "MODIFY", $itemnumber, "item " . Dumper($item) )
537
    logaction( "CATALOGUING", "MODIFY", $itemnumber, "item " . Dumper($item) )
533
      if $log_action && C4::Context->preference("CataloguingLog");
538
      if $log_action && C4::Context->preference("CataloguingLog");
534
}
539
}
Lines 613-618 sub DelItem { Link Here
613
618
614
    ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
619
    ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
615
620
621
    _after_item_action_hooks({ action => 'delete', item_id => $itemnumber });
622
616
    #search item field code
623
    #search item field code
617
    logaction("CATALOGUING", "DELETE", $itemnumber, "item") if C4::Context->preference("CataloguingLog");
624
    logaction("CATALOGUING", "DELETE", $itemnumber, "item") if C4::Context->preference("CataloguingLog");
618
    return $deleted;
625
    return $deleted;
Lines 2638-2642 sub ToggleNewStatus { Link Here
2638
    return $report;
2645
    return $report;
2639
}
2646
}
2640
2647
2648
=head2 _after_item_action_hooks
2649
2650
Helper method that takes care of calling all plugin hooks
2651
2652
=cut
2653
2654
sub _after_item_action_hooks {
2655
    my ( $args ) = @_;
2656
2657
    my $item_id = $args->{item_id};
2658
    my $action  = $args->{action};
2659
2660
    if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
2661
2662
        my @plugins = Koha::Plugins->new->GetPlugins({
2663
            method => 'after_item_action',
2664
        });
2665
2666
        if (@plugins) {
2667
2668
            my $item = Koha::Items->find( $item_id );
2669
2670
            foreach my $plugin ( @plugins ) {
2671
                try {
2672
                    $plugin->after_item_action({ action => $action, item => $item, item_id => $item_id });
2673
                }
2674
                catch {
2675
                    warn "$_";
2676
                };
2677
            }
2678
        }
2679
    }
2680
}
2641
2681
2642
1;
2682
1;
2643
- 

Return to bug 22709