Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre'
authorVitor FERNANDES <vfernandes@keep.pt>
Wed, 5 Dec 2012 15:34:24 +0000 (15:34 +0000)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 20 Feb 2013 14:06:57 +0000 (09:06 -0500)
Changed Charset.pm to use defaultlanguage instead of 'fre'.

Signed-off-by: Rolando Isodoro <rolando.isidoro@gmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.

1) Check system preference was added correctly:
   UNIMARCField100Language
2) Change code in preference to be not 'fre'.
3) Catalog a bibliographic record.
  - check plugin shows new value
  - check empty field is filled with new value from the plugin
  - check you can still edit it to be something else

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/Charset.pm
installer/data/mysql/updatedatabase.pl

index c294b36..f8ddd63 100644 (file)
@@ -324,8 +324,10 @@ sub SetMarcUnicodeFlag {
         substr($leader, 9, 1) = 'a';
         $marc_record->leader($leader); 
     } elsif ($marc_flavour =~/UNIMARC/) {
+       my $defaultlanguage = C4::Context->preference("UNIMARCField100Language");
+        $defaultlanguage = "fre" if (!$defaultlanguage || length($defaultlanguage) != 3);
         my $string; 
-               my ($subflength,$encodingposition)=($marc_flavour=~/AUTH/?(21,9):(36,22));
+               my ($subflength,$encodingposition)=($marc_flavour=~/AUTH/?(21,12):(36,25));
                $string=$marc_record->subfield( 100, "a" );
         if (defined $string && length($string)==$subflength) { 
                        $string = substr $string, 0,$subflength if (length($string)>$subflength);
@@ -333,9 +335,10 @@ sub SetMarcUnicodeFlag {
         else { 
             $string = POSIX::strftime( "%Y%m%d", localtime ); 
             $string =~ s/\-//g; 
-            $string = sprintf( "%-*s", $subflength, $string ); 
+            $string = sprintf( "%-*s", $subflength, $string );
+           substr ( $string, ($encodingposition - 3), 3, $defaultlanguage);
         } 
-        substr( $string, $encodingposition, 8, "frey50  " ); 
+        substr( $string, $encodingposition, 3, "y50" );
         if ( $marc_record->subfield( 100, "a" ) ) { 
                        $marc_record->field('100')->update(a=>$string);
                }
@@ -343,7 +346,7 @@ sub SetMarcUnicodeFlag {
             $marc_record->insert_grouped_field( 
                 MARC::Field->new( 100, '', '', "a" => $string ) ); 
         }
-               $debug && warn "encodage: ", substr( $marc_record->subfield(100, 'a'), $encodingposition, 8 );
+               $debug && warn "encodage: ", substr( $marc_record->subfield(100, 'a'), $encodingposition, 3 );
     } else {
         warn "Unrecognized marcflavour: $marc_flavour";
     }