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

(-)a/C4/AuthoritiesMarc.pm (-1 / +21 lines)
Lines 20-25 package C4::AuthoritiesMarc; Link Here
20
20
21
use strict;
21
use strict;
22
use warnings;
22
use warnings;
23
use MARC::Record;
24
use Try::Tiny;
25
23
use C4::Context;
26
use C4::Context;
24
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblio );
27
use C4::Biblio qw( GetFrameworkCode GetMarcBiblio ModBiblio );
25
use C4::Search qw( FindDuplicate new_record_from_zebra );
28
use C4::Search qw( FindDuplicate new_record_from_zebra );
Lines 625-635 sub AddAuthority { Link Here
625
  }
628
  }
626
629
627
    # Save record into auth_header, update 001
630
    # Save record into auth_header, update 001
631
    my $action;
628
    if (!$authid ) {
632
    if (!$authid ) {
633
        $action = 'create';
629
        # Save a blank record, get authid
634
        # Save a blank record, get authid
630
        $dbh->do( "INSERT INTO auth_header (datecreated,marcxml) values (NOW(),?)", undef, '' );
635
        $dbh->do( "INSERT INTO auth_header (datecreated,marcxml) values (NOW(),?)", undef, '' );
631
        $authid = $dbh->last_insert_id( undef, undef, 'auth_header', 'authid' );
636
        $authid = $dbh->last_insert_id( undef, undef, 'auth_header', 'authid' );
632
        logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
637
        logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
638
    } else {
639
        $action = 'modify';
633
    }
640
    }
634
    # Insert/update the recordID in MARC record
641
    # Insert/update the recordID in MARC record
635
    $record->delete_field( $record->field('001') );
642
    $record->delete_field( $record->field('001') );
Lines 639-644 sub AddAuthority { Link Here
639
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
646
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
640
    $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record );
647
    $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record );
641
648
649
    _after_authority_action_hooks({ action => $action, authority_id => $authid });
642
    return ( $authid );
650
    return ( $authid );
643
}
651
}
644
652
Lines 667-672 sub DelAuthority { Link Here
667
    logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
675
    logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
668
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
676
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
669
    $indexer->index_records( $authid, "recordDelete", "authorityserver", undef );
677
    $indexer->index_records( $authid, "recordDelete", "authorityserver", undef );
678
679
    _after_authority_action_hooks({ action => 'delete', authority_id => $authid });
670
}
680
}
671
681
672
=head2 ModAuthority
682
=head2 ModAuthority
Lines 1584-1589 sub compare_fields { Link Here
1584
}
1594
}
1585
1595
1586
1596
1597
=head2 _after_authority_action_hooks
1598
1599
Helper method that takes care of calling all plugin hooks
1600
1601
=cut
1602
1603
sub _after_authority_action_hooks {
1604
    my ( $args ) = @_; # hash keys: action, authority_id
1605
    return Koha::Plugins->call( 'after_authority_action', $args );
1606
}
1607
1587
END { }       # module clean-up code here (global destructor)
1608
END { }       # module clean-up code here (global destructor)
1588
1609
1589
1;
1610
1;
1590
- 

Return to bug 27173