From 3a0ba6198913cb7e9d01d9705477ba1e93dfe306 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Fr=C3=A9d=C3=A9rick=20Capovilla?= Date: Mon, 28 Mar 2011 11:55:28 -0400 Subject: [PATCH] Remove Koha-specific fields from records imported via Z39.50 Removes all items (952) and authids ($9 in headings) in the record. --- C4/Biblio.pm | 26 ++++++++++++++++++++++++++ acqui/neworderempty.pl | 6 ++---- cataloguing/addbiblio.pl | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 66fc51a..1e08714 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -121,6 +121,7 @@ BEGIN { &TransformHtmlToXml &PrepareItemrecordDisplay &GetNoZebraIndexes + &RemoveItemsAndAuthidsFromRecord ); } @@ -2490,6 +2491,31 @@ sub GetNoZebraIndexes { return %indexes; } +=head2 RemoveItemsAndAuthidsFromRecord + + RemoveItemsAndAuthidsFromRecord($record); + + Remove all items (952) from the record. + Also removes all authids (subfield 9 in headings) + +=cut + +sub RemoveItemsAndAuthidsFromRecord { + my $record = shift; + + # Remove all the items (952) from the record + foreach my $item ($record->field('952')) { + $record->delete_field($item); + } + + # Remove all authid links ($9) in the record + foreach my $heading qw(100 110 111 130 440 600 610 611 630 648 650 651 655 700 710 711 730 800 810 811 830) { + foreach my $field ($record->field($heading)) { + $field->delete_subfield(code => '9'); + } + } +} + =head1 INTERNAL FUNCTIONS =head2 _DelBiblioNoZebra($biblionumber,$record,$server); diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 7c726f3..157a89b 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -132,10 +132,8 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){ my ($marcrecord, $encoding) = MARCfindbreeding($params->{'breedingid'}); die("Could not find the selected record in the reservoir, bailing") unless $marcrecord; - # Remove all the items (952) from the imported record - foreach my $item ($marcrecord->field('952')) { - $marcrecord->delete_field($item); - } + # Do a cleanup on the imported record + RemoveItemsAndAuthidsFromRecord($marcrecord); my $duplicatetitle; #look for duplicates diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 2c0c63d..3f2ff57 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -889,6 +889,7 @@ if (($biblionumber) && !($breedingid)){ } if ($breedingid) { ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ; + RemoveItemsAndAuthidsFromRecord($record) if $record; } $is_a_modif = 0; -- 1.5.6.5