From: Brian Harrington Date: Tue, 21 Apr 2009 16:13:22 +0000 (-0400) Subject: Patch to improve auto-generated MARC21 authorities X-Git-Tag: v3.00.04~547 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=5d21e60ad418496a1cb947fba11807a9c7bbcc20;p=koha.git Patch to improve auto-generated MARC21 authorities This patch makes sure that MARC21 authorities have a minimal Leader, 008, and 040. If an authority record is created through BiblioAddsAuthority it generates a 670 based on information in the bib record. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 7c2e531fda..21c98b2330 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -519,16 +519,11 @@ sub AddAuthority { # pass the MARC::Record to this function, and it will create the records in the authority table my ($record,$authid,$authtypecode) = @_; my $dbh=C4::Context->dbh; - my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record + my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record # if authid empty => true add, find a new authid number - my $format; - if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC') { - $format= 'UNIMARCAUTH'; - } - else { - $format= 'MARC21'; - } + my $format= 'UNIMARCAUTH' if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC'); + $format= 'MARC21' if (uc(C4::Context->preference('marcflavour')) ne 'UNIMARC'); if ($format eq "MARC21") { if (!$record->leader) { diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index b49b1876dc..63a1113c46 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -792,6 +792,15 @@ AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|); $marcrecordauth->insert_fields_ordered(MARC::Field->new('670','','','a'=>$cite)); } + if (C4::Context->preference('marcflavour') eq 'MARC21') { + $marcrecordauth->insert_fields_ordered(MARC::Field->new('667','','','a'=>"Machine generated authority record.")); + my $cite = $record->author() . ", " . $record->title_proper() . ", " . $record->publication_date() . " "; + $cite =~ s/^[\s\,]*//; + $cite =~ s/[\s\,]*$//; + $cite = "Work cat.: (" . C4::Context->preference('MARCOrgCode') . ")". $record->subfield('999','c') . ": " . $cite; + $marcrecordauth->insert_fields_ordered(MARC::Field->new('670','','','a'=>$cite)); + } + # warn "AUTH RECORD ADDED : ".$marcrecordauth->as_formatted; my $authid=AddAuthority($marcrecordauth,'',$data->{authtypecode});