|
Lines 623-639
sub AddAuthority {
Link Here
|
| 623 |
} |
623 |
} |
| 624 |
|
624 |
|
| 625 |
# Save record into auth_header, update 001 |
625 |
# Save record into auth_header, update 001 |
|
|
626 |
my $authority; |
| 626 |
if (!$authid ) { |
627 |
if (!$authid ) { |
| 627 |
# Save a blank record, get authid |
628 |
# Save a blank record, get authid |
| 628 |
$dbh->do( "INSERT INTO auth_header (datecreated,marcxml) values (NOW(),?)", undef, '' ); |
629 |
$authority = Koha::Authority->new({ datecreated => \'NOW()', marcxml => '' })->store(); |
| 629 |
$authid = $dbh->last_insert_id( undef, undef, 'auth_header', 'authid' ); |
630 |
$authority->discard_changes(); |
|
|
631 |
$authid = $authority->authid; |
| 630 |
logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
632 |
logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
|
|
633 |
} else { |
| 634 |
$authority = Koha::Authorities->find($authid); |
| 631 |
} |
635 |
} |
|
|
636 |
|
| 632 |
# Insert/update the recordID in MARC record |
637 |
# Insert/update the recordID in MARC record |
| 633 |
$record->delete_field( $record->field('001') ); |
638 |
$record->delete_field( $record->field('001') ); |
| 634 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
639 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
| 635 |
# Update |
640 |
# Update |
| 636 |
$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; |
641 |
$authority->update({ authtypecode => $authtypecode, marc => $record->as_usmarc, marcxml => $record->as_xml_record($format) }); |
| 637 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
642 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
| 638 |
$indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); |
643 |
$indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); |
| 639 |
|
644 |
|
| 640 |
- |
|
|