Lines 545-551
returns authid of the newly created authority
Link Here
|
545 |
|
545 |
|
546 |
sub AddAuthority { |
546 |
sub AddAuthority { |
547 |
# pass the MARC::Record to this function, and it will create the records in the authority table |
547 |
# pass the MARC::Record to this function, and it will create the records in the authority table |
548 |
my ($record,$authid,$authtypecode) = @_; |
548 |
my ( $record, $authid, $authtypecode, $params ) = @_; |
|
|
549 |
|
550 |
my $skip_record_index = $params->{skip_record_index} || 0; |
551 |
|
549 |
my $dbh=C4::Context->dbh; |
552 |
my $dbh=C4::Context->dbh; |
550 |
my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record |
553 |
my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record |
551 |
|
554 |
|
Lines 654-661
sub AddAuthority {
Link Here
|
654 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
657 |
$record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); |
655 |
# Update |
658 |
# Update |
656 |
$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; |
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; |
657 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
660 |
|
658 |
$indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); |
661 |
unless ( $skip_record_index ) { |
|
|
662 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
663 |
$indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); |
664 |
} |
659 |
|
665 |
|
660 |
_after_authority_action_hooks({ action => $action, authority_id => $authid }); |
666 |
_after_authority_action_hooks({ action => $action, authority_id => $authid }); |
661 |
return ( $authid ); |
667 |
return ( $authid ); |
Lines 697-709
sub DelAuthority {
Link Here
|
697 |
Modifies authority record, optionally updates attached biblios. |
703 |
Modifies authority record, optionally updates attached biblios. |
698 |
The parameter skip_merge is optional and should be used with care. |
704 |
The parameter skip_merge is optional and should be used with care. |
699 |
|
705 |
|
|
|
706 |
skip_record_index will skip the indexation step. |
707 |
|
700 |
=cut |
708 |
=cut |
701 |
|
709 |
|
702 |
sub ModAuthority { |
710 |
sub ModAuthority { |
703 |
my ( $authid, $record, $authtypecode, $params ) = @_; |
711 |
my ( $authid, $record, $authtypecode, $params ) = @_; |
|
|
712 |
|
713 |
my $skip_record_index = $params->{skip_record_index} || 0; |
714 |
|
704 |
my $oldrecord = GetAuthority($authid); |
715 |
my $oldrecord = GetAuthority($authid); |
705 |
#Now rewrite the $record to table with an add |
716 |
#Now rewrite the $record to table with an add |
706 |
$authid = AddAuthority($record, $authid, $authtypecode); |
717 |
$authid = AddAuthority($record, $authid, $authtypecode, { skip_record_index => $skip_record_index }); |
707 |
merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge}; |
718 |
merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge}; |
708 |
logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog"); |
719 |
logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog"); |
709 |
return $authid; |
720 |
return $authid; |