From 95753f56a4b2e89cd5a73831a649350d6276eb03 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 10 Jun 2010 11:08:02 +0000 Subject: [PATCH] Bug 4839 (System pref for MARC field 008 authorities; additional logic for position 14) [version 3.0.x] Currently, the default for this marc field is hardcoded in the plugin code of marc21_field_008_authorities.pl (two occurrences). I suggest to move this value to a new system preference. If this pref should not exist, the old hardcoded value could still be used. Furthermore, the default for position 14 (heading use: main or added entry) should be dependent on the authority type. For CHRON_TERM, GENRE/FORM and TOPIC_TERM, it should be b (not appropriate) instead of a (appropriate). This patch applies to 3.0.x only. Additional patch submitted for master. --- .../marc21_field_008_authorities.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cataloguing/value_builder/marc21_field_008_authorities.pl b/cataloguing/value_builder/marc21_field_008_authorities.pl index 1aae045808..d05bea0c12 100755 --- a/cataloguing/value_builder/marc21_field_008_authorities.pl +++ b/cataloguing/value_builder/marc21_field_008_authorities.pl @@ -37,6 +37,8 @@ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year +=1900; $mon +=1; my $dateentered = substr($year,2,2).sprintf ("%0.2d", $mon).sprintf ("%0.2d",$mday); +my $defaultval = C4::Context->preference('AuthorityField008Default') || '|| aca||aabn | a|a d'; + sub plugin_parameters { my ($dbh,$record,$tagslib,$i,$tabloop) = @_; return ""; @@ -51,7 +53,12 @@ sub plugin_javascript { function Focus$function_name(subfield_managed) { if (!document.getElementById(\"$field_number\").value) { - document.getElementById(\"$field_number\").value='$dateentered' + '|| aca||aabn | a|a d'; + var authtype=document.forms['f'].elements['authtypecode'].value; + var fieldval='$dateentered$defaultval'; + if(authtype && (authtype == 'TOPIC_TERM' || authtype == 'GENRE/FORM' || authtype == 'CHRON_TERM')) { + fieldval= fieldval.substr(0,14)+'b'+fieldval.substr(15); + } + document.getElementById(\"$field_number\").value=fieldval; } return 1; } @@ -61,8 +68,9 @@ function Blur$function_name(subfield_managed) { } function Clic$function_name(i) { + var authtype=document.forms['f'].elements['authtypecode'].value; defaultvalue=document.getElementById(\"$field_number\").value; - newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=$field_number&result=\"+defaultvalue,\"unimarc field 100\",'width=1000,height=600,toolbar=false,scrollbars=yes'); + newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_008_authorities.pl&index=$field_number&result=\"+defaultvalue+\"&authtypecode=\"+authtype,\"unimarc field 100\",'width=1000,height=600,toolbar=false,scrollbars=yes'); } //]]> @@ -75,7 +83,8 @@ sub plugin { my ($input) = @_; my $index= $input->param('index'); my $result= $input->param('result'); - + my $authtype= $input->param('authtypecode')||''; + substr($defaultval,14-6,1)='b' if $authtype=~ /TOPIC_TERM|GENRE.FORM|CHRON_TERM/; my $dbh = C4::Context->dbh; @@ -87,7 +96,7 @@ sub plugin { flagsrequired => {editcatalogue => 1}, debug => 1, }); - $result = "$dateentered".'|| aca||aabn | a|a d' unless $result; + $result = "$dateentered$defaultval" unless $result; my $f1 = substr($result,0,6); my $f6 = substr($result,6,1); my $f7 = substr($result,7,1); @@ -104,7 +113,7 @@ sub plugin { my $f28 = substr($result,28,1); my $f29 = substr($result,29,1); my $f31 = substr($result,31,1); - my $f32 = substr($result,32,2); + my $f32 = substr($result,32,1); my $f33 = substr($result,33,1); my $f38 = substr($result,38,1); my $f39 = substr($result,39,1); -- 2.39.5