Bug 4839: Adjust default values for MARC21 authority Fixed-Length Data Elements

Currently, the default for this MARC control field is hardcoded in the plugin code of marc21_field_008_authorities.pl (two occurrences).
This patch moves it into a new syspref. If this pref should not exist, the old hardcoded value is used. Authorities preference file is updated too.
A warning is generated if the length of the field is not correct.

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).

Rebased on March 17. Follow-up patch added for installation pref.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2010-11-29 14:29:34 +01:00 committed by Chris Cormack
parent 32b8ff74fd
commit 6de831da03
2 changed files with 35 additions and 5 deletions

View file

@ -27,6 +27,9 @@ use C4::Context;
use C4::Search;
use C4::Output;
use constant FIXLEN_DATA_ELTS => '|| aca||aabn | a|a d';
use constant PREF_008 => 'MARCAuthorityControlField008';
=head1 DESCRIPTION
plugin_parameters : other parameters added when the plugin is called by the dopop function
@ -38,6 +41,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 = Field008();
sub plugin_parameters {
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
return "";
@ -52,7 +57,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;
}
@ -62,8 +72,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,\"tag_editor\",'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,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
}
//]]>
@ -76,7 +87,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;
@ -88,7 +100,7 @@ sub plugin {
flagsrequired => {editcatalogue => '*'},
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);
@ -105,7 +117,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);
@ -158,4 +170,16 @@ if ((!$f1) ||($f1 =~ m/ /)){
output_html_with_http_headers $input, $cookie, $template->output;
}
sub Field008 {
my $pref= C4::Context->preference(PREF_008);
if(!$pref) {
return FIXLEN_DATA_ELTS;
}
elsif(length($pref)<34) {
warn "marc21_field_008_authorities.pl: Syspref ".PREF_008." should be 34 characters long ";
return FIXLEN_DATA_ELTS;
}
return substr($pref,0,34); #ignore remainder
}
1;

View file

@ -14,6 +14,12 @@ Authorities:
yes: "Don't"
no: Do
- automatically update attached biblios when changing an authority record. If this is off, please ask your administrator to enable the merge_authorities.pl cronjob.
-
- Use the following text for the contents of MARC authority control field 008 position 06-39 (fixed length data elements). Do NOT include the date (position 00-05).
- pref: MARCAuthorityControlField008
default: "|| aca||aabn | a|a d"
type: textarea
class: code
-
- pref: UseAuthoritiesForTracings
default: yes