|
Lines 533-539
returns authid of the newly created authority
Link Here
|
| 533 |
|
533 |
|
| 534 |
sub AddAuthority { |
534 |
sub AddAuthority { |
| 535 |
# pass the MARC::Record to this function, and it will create the records in the authority table |
535 |
# pass the MARC::Record to this function, and it will create the records in the authority table |
| 536 |
my ($record,$authid,$authtypecode) = @_; |
536 |
my ( $record, $authid, $authtypecode, $params ) = @_; |
|
|
537 |
|
| 538 |
my $skip_record_index = $params->{skip_record_index} || 0; |
| 539 |
|
| 537 |
my $dbh=C4::Context->dbh; |
540 |
my $dbh=C4::Context->dbh; |
| 538 |
my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record |
541 |
my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record |
| 539 |
|
542 |
|
|
Lines 642-649
sub AddAuthority {
Link Here
|
| 642 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
645 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
| 643 |
# Update |
646 |
# Update |
| 644 |
$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; |
647 |
$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; |
| 645 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
648 |
|
| 646 |
$indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); |
649 |
unless ( $skip_record_index ) { |
|
|
650 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
| 651 |
$indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); |
| 652 |
} |
| 647 |
|
653 |
|
| 648 |
_after_authority_action_hooks({ action => $action, authority_id => $authid }); |
654 |
_after_authority_action_hooks({ action => $action, authority_id => $authid }); |
| 649 |
return ( $authid ); |
655 |
return ( $authid ); |
|
Lines 685-697
sub DelAuthority {
Link Here
|
| 685 |
Modifies authority record, optionally updates attached biblios. |
691 |
Modifies authority record, optionally updates attached biblios. |
| 686 |
The parameter skip_merge is optional and should be used with care. |
692 |
The parameter skip_merge is optional and should be used with care. |
| 687 |
|
693 |
|
|
|
694 |
skip_record_index will skip the indexation step. |
| 695 |
|
| 688 |
=cut |
696 |
=cut |
| 689 |
|
697 |
|
| 690 |
sub ModAuthority { |
698 |
sub ModAuthority { |
| 691 |
my ( $authid, $record, $authtypecode, $params ) = @_; |
699 |
my ( $authid, $record, $authtypecode, $params ) = @_; |
|
|
700 |
|
| 701 |
my $skip_record_index = $params->{skip_record_index} || 0; |
| 702 |
|
| 692 |
my $oldrecord = GetAuthority($authid); |
703 |
my $oldrecord = GetAuthority($authid); |
| 693 |
#Now rewrite the $record to table with an add |
704 |
#Now rewrite the $record to table with an add |
| 694 |
$authid = AddAuthority($record, $authid, $authtypecode); |
705 |
$authid = AddAuthority($record, $authid, $authtypecode, { skip_record_index => $skip_record_index }); |
| 695 |
merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge}; |
706 |
merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge}; |
| 696 |
logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog"); |
707 |
logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog"); |
| 697 |
return $authid; |
708 |
return $authid; |