Lines 1-4
Link Here
|
1 |
package C4::AuthoritiesMarc; |
1 |
package C4::AuthoritiesMarc; |
|
|
2 |
|
2 |
# Copyright 2000-2002 Katipo Communications |
3 |
# Copyright 2000-2002 Katipo Communications |
3 |
# |
4 |
# |
4 |
# This file is part of Koha. |
5 |
# This file is part of Koha. |
Lines 683-699
sub AddAuthority {
Link Here
|
683 |
|
684 |
|
684 |
=head2 DelAuthority |
685 |
=head2 DelAuthority |
685 |
|
686 |
|
686 |
DelAuthority({ authid => $authid }); |
687 |
DelAuthority({ authid => $authid, [ skip_merge => 1 ] }); |
687 |
|
688 |
|
688 |
Deletes $authid and calls merge to cleanup in linked biblio records |
689 |
Deletes $authid and calls merge to cleanup linked biblio records. |
|
|
690 |
Parameter skip_merge is used in authorities/merge.pl. You should normally not |
691 |
use it. |
689 |
|
692 |
|
690 |
=cut |
693 |
=cut |
691 |
|
694 |
|
692 |
sub DelAuthority { |
695 |
sub DelAuthority { |
693 |
my ( $params ) = @_; |
696 |
my ( $params ) = @_; |
694 |
my $authid = $params->{authid} || return; |
697 |
my $authid = $params->{authid} || return; |
695 |
my $dbh=C4::Context->dbh; |
698 |
my $skip_merge = $params->{skip_merge}; |
696 |
merge({ mergefrom => $authid, MARCfrom => GetAuthority($authid) }); |
699 |
my $dbh = C4::Context->dbh; |
|
|
700 |
merge({ mergefrom => $authid }) if !$skip_merge; |
697 |
$dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid ); |
701 |
$dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid ); |
698 |
logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
702 |
logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
699 |
ModZebra( $authid, "recordDelete", "authorityserver", undef); |
703 |
ModZebra( $authid, "recordDelete", "authorityserver", undef); |
Lines 1370-1388
sub AddAuthorityTrees{
Link Here
|
1370 |
=head2 merge |
1374 |
=head2 merge |
1371 |
|
1375 |
|
1372 |
$count = merge({ |
1376 |
$count = merge({ |
1373 |
mergefrom => mergefrom, |
1377 |
mergefrom => $mergefrom, |
1374 |
MARCfrom => $MARCfrom, |
1378 |
[ MARCfrom => $MARCfrom, ] |
1375 |
[ mergeto => $mergeto, ] |
1379 |
[ mergeto => $mergeto, ] |
1376 |
[ MARCto => $MARCto, ] |
1380 |
[ MARCto => $MARCto, ] |
1377 |
[ biblionumbers => [ $a, $b, $c ], ] |
1381 |
[ biblionumbers => [ $a, $b, $c ], ] |
1378 |
[ override_limit => 1, ] |
1382 |
[ override_limit => 1, ] |
1379 |
}); |
1383 |
}); |
1380 |
|
1384 |
|
1381 |
Merge biblios linked to authority $mergefrom. |
1385 |
Merge biblios linked to authority $mergefrom (mandatory parameter). |
1382 |
If $mergeto equals mergefrom, the linked biblio field is updated. |
1386 |
If $mergeto equals mergefrom, the linked biblio field is updated. |
1383 |
If $mergeto is different, the biblio field will be linked to $mergeto. |
1387 |
If $mergeto is different, the biblio field will be linked to $mergeto. |
1384 |
If $mergeto is missing, the biblio field is deleted. |
1388 |
If $mergeto is missing, the biblio field is deleted. |
1385 |
|
1389 |
|
|
|
1390 |
MARCfrom is used to determine if a cleared subfield in the authority record |
1391 |
should be removed from a biblio. MARCto is used to populate the biblio |
1392 |
record with the updated values; if you do not pass it, the biblio field |
1393 |
will be deleted (same as missing mergeto). |
1394 |
|
1386 |
Normally all biblio records linked to $mergefrom, will be considered. But |
1395 |
Normally all biblio records linked to $mergefrom, will be considered. But |
1387 |
you can pass specific numbers via the biblionumbers parameter. |
1396 |
you can pass specific numbers via the biblionumbers parameter. |
1388 |
|
1397 |
|
Lines 1435-1450
sub merge {
Link Here
|
1435 |
my @record_to; |
1444 |
my @record_to; |
1436 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to); |
1445 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to); |
1437 |
my @record_from; |
1446 |
my @record_from; |
1438 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields() if $auth_tag_to_report_from && $MARCfrom && $MARCfrom->field($auth_tag_to_report_from); |
1447 |
if( !$authfrom && $MARCfrom && $MARCfrom->field('1..','2..') ) { |
|
|
1448 |
# postponed merge, authfrom was deleted and MARCfrom only contains the old reporting tag (and possibly a 100 for UNIMARC) |
1449 |
# 2XX is for UNIMARC; we use -1 in order to skip 100 in UNIMARC; this will not impact MARC21, since there is only one tag |
1450 |
@record_from = ( $MARCfrom->field('1..','2..') )[-1]->subfields; |
1451 |
} elsif( $auth_tag_to_report_from && $MARCfrom && $MARCfrom->field($auth_tag_to_report_from) ) { |
1452 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields; |
1453 |
} |
1439 |
|
1454 |
|
1440 |
# Get All candidate Tags for the change |
1455 |
# Get all candidate tags for the change |
1441 |
# (This will reduce the search scope in marc records). |
1456 |
# (This will reduce the search scope in marc records). |
1442 |
# For a deleted authority record, we scan all auth controlled fields |
1457 |
# For a deleted authority record, we scan all auth controlled fields |
1443 |
my $dbh = C4::Context->dbh; |
1458 |
my $dbh = C4::Context->dbh; |
1444 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
1459 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
1445 |
my $tags_using_authtype = $authtypefrom ? $dbh->selectcol_arrayref( $sql, undef, ( $authtypefrom->authtypecode )) : $dbh->selectcol_arrayref( "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode IS NOT NULL AND authtypecode<>''" ); |
1460 |
my $tags_using_authtype = $authtypefrom ? $dbh->selectcol_arrayref( $sql, undef, ( $authtypefrom->authtypecode )) : $dbh->selectcol_arrayref( "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode IS NOT NULL AND authtypecode<>''" ); |
1446 |
my $tags_new; |
1461 |
my $tags_new; |
1447 |
if( $authtypefrom && $authtypeto && $authtypeto->authtypecode ne $authtypefrom->authtypecode ) { |
1462 |
if( $authtypeto && ( !$authtypefrom || $authtypeto->authtypecode ne $authtypefrom->authtypecode )) { |
1448 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
1463 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
1449 |
} |
1464 |
} |
1450 |
|
1465 |
|
Lines 1470-1478
sub merge {
Link Here
|
1470 |
my $tag = $field->tag(); |
1485 |
my $tag = $field->tag(); |
1471 |
next if !defined($auth_number) || $auth_number ne $mergefrom; |
1486 |
next if !defined($auth_number) || $auth_number ne $mergefrom; |
1472 |
$countfrom++; |
1487 |
$countfrom++; |
1473 |
if ( !$mergeto || ( $overwrite && $countfrom > 1 ) ) { |
1488 |
if ( !$mergeto || !@record_to || |
1474 |
# if mergeto is missing, this indicates a delete |
1489 |
( $overwrite && $countfrom > 1 ) ) { |
1475 |
# Or: remove this duplicate in strict mode |
1490 |
# !mergeto or !record_to indicates a delete |
|
|
1491 |
# Other condition: remove this duplicate in strict mode |
1476 |
$marcrecord->delete_field($field); |
1492 |
$marcrecord->delete_field($field); |
1477 |
$update = 1; |
1493 |
$update = 1; |
1478 |
next; |
1494 |
next; |