From 93ba3b85608ec468c2c11f38b5aca9ade40c5fbc Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Wed, 5 Dec 2012 15:34:24 +0000 Subject: [PATCH] Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre' Changed Charset.pm to use defaultlanguage instead of 'fre'. Signed-off-by: Rolando Isodoro Signed-off-by: Katrin Fischer 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 --- C4/Charset.pm | 11 +++++++---- installer/data/mysql/updatedatabase.pl | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/C4/Charset.pm b/C4/Charset.pm index c294b36133..f8ddd63627 100644 --- a/C4/Charset.pm +++ b/C4/Charset.pm @@ -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"; } diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 15896a1691..43851ac067 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1,4 +1,3 @@ - #!/usr/bin/perl # Database Updater -- 2.39.5