#1473: MARCfindbreeding breaks MARC21 records in reservoir
authorPaul POULAIN <paul@koha-fr.org>
Mon, 8 Oct 2007 19:24:31 +0000 (14:24 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Mon, 8 Oct 2007 20:51:35 +0000 (15:51 -0500)
doesn't change anything for UNIMARC (as expected), UNTESTED for MARC21, pls test it

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
cataloguing/addbiblio.pl

index d78d253..cdd526d 100755 (executable)
@@ -57,20 +57,21 @@ sub MARCfindbreeding {
       $dbh->prepare("select file,marc,encoding from marc_breeding where id=?");
     $sth->execute($id);
     my ( $file, $marc, $encoding ) = $sth->fetchrow;
+    # remove the - in isbn, koha store isbn without any -
     if ($marc) {
         my $record = MARC::Record->new_from_usmarc($marc);
-        if ( $record->field('010') ) {
-            foreach my $field ( $record->field('010') ) {
-                foreach my $subfield ( $field->subfield('a') ) {
-                    my $newisbn = $field->subfield('a');
+        my ($isbnfield,$isbnsubfield) = GetMarcFromKohaField('biblioitems.isbn','');
+        if ( $record->field($isbnfield) ) {
+            foreach my $field ( $record->field($isbnfield) ) {
+                foreach my $subfield ( $field->subfield($isbnsubfield) ) {
+                    my $newisbn = $field->subfield($isbnsubfield);
                     $newisbn =~ s/-//g;
-                    $field->update( 'a' => $newisbn );
+                    $field->update( $isbnsubfield => $newisbn );
                 }
-                # record->insert_fields_ordered($record->field('010'));
             }
         }
-
-        if ($record->subfield(100,'a')) {
+        # fix the unimarc 100 coded field (with unicode information)
+        if (C4::Context->preference('marcflavour') eq 'UNIMARC' && $record->subfield(100,'a')) {
             my $f100a=$record->subfield(100,'a');
             my $f100 = $record->field(100);
             my $f100temp = $f100->as_string;
@@ -87,6 +88,7 @@ sub MARCfindbreeding {
             return -1;
         }
         else {
+            # normalize author : probably UNIMARC specific...
             if (    C4::Context->preference("z3950NormalizeAuthor")
                 and C4::Context->preference("z3950AuthorAuthFields") )
             {