From c5ea73c6f7455c4802b90d526aa8d9c9b5a77473 Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Thu, 29 Nov 2012 11:02:16 +0000 Subject: [PATCH] [PASSED QA] 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: Katrin Fischer --- C4/Biblio.pm | 5 ++++- cataloguing/value_builder/unimarc_field_100.pl | 5 ++++- installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 1b88286..2c7170c 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 0d01554..0ecf844 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 9032bfa..6f066bb 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -389,6 +389,7 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdid INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z','Alphabet than can be expanded into browse links, e.g. on Home > Patrons',NULL,'free'); +<<<<<<< HEAD INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RefundLostItemFeeOnReturn', '1', 'If enabled, the lost item fee charged to a borrower will be refunded when the lost item is returned.', NULL, 'YesNo'); INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('PatronSelfRegistration', '0', NULL, 'If enabled, patrons will be able to register themselves via the OPAC.', 'YesNo'), @@ -411,3 +412,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo'); 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,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 ed922b8..31695ef 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1,3 +1,4 @@ + #!/usr/bin/perl # Database Updater @@ -6399,6 +6400,12 @@ if ( CheckVersion($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 -- 1.7.9.5