Lines 643-662
sub AddAuthority {
Link Here
|
643 |
|
643 |
|
644 |
# Save record into auth_header, update 001 |
644 |
# Save record into auth_header, update 001 |
645 |
my $action; |
645 |
my $action; |
|
|
646 |
my $authority; |
646 |
if (!$authid ) { |
647 |
if (!$authid ) { |
647 |
$action = 'create'; |
648 |
$action = 'create'; |
648 |
# Save a blank record, get authid |
649 |
# Save a blank record, get authid |
649 |
$dbh->do( "INSERT INTO auth_header (datecreated,marcxml) values (NOW(),?)", undef, '' ); |
650 |
$authority = Koha::Authority->new({ datecreated => \'NOW()', marcxml => '' })->store(); |
650 |
$authid = $dbh->last_insert_id( undef, undef, 'auth_header', 'authid' ); |
651 |
$authority->discard_changes(); |
|
|
652 |
$authid = $authority->authid; |
651 |
logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
653 |
logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
652 |
} else { |
654 |
} else { |
653 |
$action = 'modify'; |
655 |
$action = 'modify'; |
|
|
656 |
$authority = Koha::Authorities->find($authid); |
654 |
} |
657 |
} |
|
|
658 |
|
655 |
# Insert/update the recordID in MARC record |
659 |
# Insert/update the recordID in MARC record |
656 |
$record->delete_field( $record->field('001') ); |
660 |
$record->delete_field( $record->field('001') ); |
657 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
661 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
658 |
# Update |
662 |
# Update |
659 |
$dbh->do( "UPDATE auth_header SET authtypecode=?, marc=?, marcxml=? WHERE authid=?", undef, $authtypecode, $record->as_usmarc, $record->as_xml_record($format), $authid ) or die $DBI::errstr; |
663 |
$authority->update({ authtypecode => $authtypecode, marc => $record->as_usmarc, marcxml => $record->as_xml_record($format) }); |
660 |
|
664 |
|
661 |
unless ( $skip_record_index ) { |
665 |
unless ( $skip_record_index ) { |
662 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
666 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
663 |
- |
|
|