[Patches] [PATCH] Remove Koha-specific fields from records imported via Z39.50

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Sat Dec 24 04:35:03 NZDT 2011


From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick=20Capovilla?= <frederick.capovilla at libeo.com>
Date: Fri, 23 Dec 2011 10:38:50 -0500
Subject: [PATCH] Remove Koha-specific fields from records imported via Z39.50

Removes all items (952) and authids ($9 in headings) in the record.
Patch modified for Koha version 3.6
---
 C4/Biblio.pm             |   29 +++++++++++++++++++++++++++++
 acqui/neworderempty.pl   |    6 ++----
 cataloguing/addbiblio.pl |    1 +
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 4a9735f..8424663 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -133,6 +133,7 @@ BEGIN {
       &TransformHtmlToXml
       &PrepareItemrecordDisplay
       &GetNoZebraIndexes
+      &RemoveItemsAndAuthidsFromRecord
     );
 }
 
@@ -2831,6 +2832,34 @@ 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');
+            unless($field->subfields()) {
+                $record->delete_field($field);
+            }
+        }
+    }
+}
+
 =head2 EmbedItemsInMarcBiblio
 
     EmbedItemsInMarcBiblio($marc, $biblionumber);
diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index 6361125..7504c3e 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 1a82989..8ee43c3 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -909,6 +909,7 @@ if (($biblionumber) && !($breedingid)){
 }
 if ($breedingid) {
     ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
+    RemoveItemsAndAuthidsFromRecord($record) if $record;
 }
 #populate hostfield if hostbiblionumber is available
 if ($hostbiblionumber){
-- 
1.7.2.5




More information about the Patches mailing list