From 16a395c3b7163a8028f199176b7bfe92f53042fe Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Thu, 29 Nov 2012 11:02:16 +0000 Subject: [PATCH 1/4] Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre' Added a new system preference to set the UNIMARC field 100 default language. The default value for that system preference is 'fre'. Changed Biblio.pm to use the system preference: - if the language is bad filled in the preferences it uses 'fre' as default value - only replaces the language when the field 100 is empty - if the language is filled with the plugin only replaces the positions 25-28 to 'y50' Signed-off-by: Rolando Isodoro Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- C4/Biblio.pm | 5 ++++- cataloguing/value_builder/unimarc_field_100.pl | 5 ++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 1b882864ed..2c7170c3c3 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3624,6 +3624,8 @@ sub ModBiblioMarc { # deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode if ( $encoding eq "UNIMARC" ) { + my $defaultlanguage = C4::Context->preference("UNIMARCField100Language"); + $defaultlanguage = "fre" if (!$defaultlanguage || length($defaultlanguage) != 3); my $string = $record->subfield( 100, "a" ); if ( ($string) && ( length( $record->subfield( 100, "a" ) ) == 36 ) ) { my $f100 = $record->field(100); @@ -3632,8 +3634,9 @@ sub ModBiblioMarc { $string = POSIX::strftime( "%Y%m%d", localtime ); $string =~ s/\-//g; $string = sprintf( "%-*s", 35, $string ); + substr ( $string, 22, 3, $defaultlanguage); } - substr( $string, 22, 6, "frey50" ); + substr( $string, 25, 3, "y50" ); unless ( $record->subfield( 100, "a" ) ) { $record->insert_fields_ordered( MARC::Field->new( 100, "", "", "a" => $string ) ); } diff --git a/cataloguing/value_builder/unimarc_field_100.pl b/cataloguing/value_builder/unimarc_field_100.pl index 0d01554458..0ecf8443be 100755 --- a/cataloguing/value_builder/unimarc_field_100.pl +++ b/cataloguing/value_builder/unimarc_field_100.pl @@ -82,6 +82,9 @@ sub plugin { my $dbh = C4::Context->dbh; + my $defaultlanguage = C4::Context->preference("UNIMARCField100Language"); + $defaultlanguage = "fre" if (!$defaultlanguage || length($defaultlanguage) != 3); + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "cataloguing/value_builder/unimarc_field_100.tmpl", @@ -92,7 +95,7 @@ sub plugin { debug => 1, } ); - $result = ' d u y0frey50 ba' unless $result; + $result = " d u y0".$defaultlanguage."y50 ba" unless $result; my $f1 = substr( $result, 0, 8 ); if ( $f1 eq ' ' ) { my @today = Date::Calc::Today(); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index fed22b64b3..387f977d6e 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -414,3 +414,4 @@ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number OPAC searches', 'YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IntranetNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number staff client searches', 'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 447b3fef4a..15896a1691 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1,3 +1,4 @@ + #!/usr/bin/perl # Database Updater @@ -6414,6 +6415,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.11.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short')"); + print "Upgrade to $DBversion done (Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre')\n"; + SetVersion($DBversion); +} =head1 FUNCTIONS From a7eb8832827a4632b750eed30c1ba920ec89bf5c Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Tue, 4 Dec 2012 16:18:57 +0000 Subject: [PATCH 2/4] Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre' Forget to add the system preference to the template. Signed-off-by: Rolando Isodoro Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/admin/preferences/cataloguing.pref | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index c3a3847997..96f3603366 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -104,7 +104,11 @@ Cataloging: - - Define a list of subfields to use when prefilling items (separated by space) - pref: SubfieldsToUseWhenPrefill - + - + - Use the languague (ISO 690-2) + - pref: UNIMARCField100Language + class: short + - as default language in the UNIMARC field 100 when creating a new record or in the field plugin. Display: - - 'Separate multiple displayed authors, series or subjects with ' From 93ba3b85608ec468c2c11f38b5aca9ade40c5fbc Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Wed, 5 Dec 2012 15:34:24 +0000 Subject: [PATCH 3/4] 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 From 91d91583bd19fe2fb19057d2630cbfac7bc9739f Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Wed, 20 Feb 2013 09:07:31 -0500 Subject: [PATCH 4/4] Bug 8347: Increment version number Database update for bug 8347 has been given version 3.11.00.020 --- installer/data/mysql/updatedatabase.pl | 2 +- kohaversion.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 43851ac067..d4059cbfa7 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6414,7 +6414,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } -$DBversion = "3.11.00.XXX"; +$DBversion = "3.11.00.020"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short')"); print "Upgrade to $DBversion done (Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre')\n"; diff --git a/kohaversion.pl b/kohaversion.pl index ee3788d336..34495bd6dd 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts : use strict; sub kohaversion { - our $VERSION = '3.11.00.019'; + our $VERSION = '3.11.00.020'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install