Bug 9149: Add missing GetAuthorizedHeading

On 3.8.x, it was possible for multiple automatically generated
authorities to be linked to a single heading. This patch deletes
previous links from headings prior to linking them to
automatically-generated headings. This patch also corrects a
potential problem wherein multiple authorities might be generated if
a record is edited repeatedly in quick succession. The latter problem
exists on Master and 3.6.x as well, and the code that corrects the
multiple linkages is equally applicable if seemingly unnecessary.

This patch adds a missing routine to C4::AuthoritiesMarc that should
have been in the 3.8.x version of the patch for bug 8823.

To test:
1) Turn on BiblioAddsAuthorities and AutoCreateAuthorities.
2) Create a new record or edit an existing one, and add an
   authority-controlled heading (for example, MARC21 1xx or 6xx or
   UNIMARC 6xx or 7xx) which does not currently exist in your authority
   file.
3) If you don't get a software error, it worked.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
For 2) you can also download a record over Z39.50.
Passes all tests.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
This commit is contained in:
Jared Camins-Esakov 2012-11-29 15:11:00 -05:00 committed by Chris Cormack
parent d3c5e317f1
commit 91116d70d0
1 changed files with 63 additions and 0 deletions

View File

@ -1144,6 +1144,69 @@ sub BuildSummary {
return \%summary;
}
=head2 GetAuthorizedHeading
$heading = &GetAuthorizedHeading({ record => $record, authid => $authid })
Takes a MARC::Record object describing an authority record or an authid, and
returns a string representation of the first authorized heading. This routine
should be considered a temporary shim to ease the future migration of authority
data from C4::AuthoritiesMarc to the object-oriented Koha::*::Authority.
=cut
sub GetAuthorizedHeading {
my $args = shift;
my $record;
unless ($record = $args->{record}) {
return unless $args->{authid};
$record = GetAuthority($args->{authid});
}
if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
# construct UNIMARC summary, that is quite different from MARC21 one
# accepted form
foreach my $field ($record->field('2..')) {
return $field->as_string('abcdefghijlmnopqrstuvwxyz');
}
} else {
foreach my $field ($record->field('1..')) {
my $tag = $field->tag();
next if "152" eq $tag;
# FIXME - 152 is not a good tag to use
# in MARC21 -- purely local tags really ought to be
# 9XX
if ($tag eq '100') {
return $field->as_string('abcdefghjklmnopqrstvxyz68');
} elsif ($tag eq '110') {
return $field->as_string('abcdefghklmnoprstvxyz68');
} elsif ($tag eq '111') {
return $field->as_string('acdefghklnpqstvxyz68');
} elsif ($tag eq '130') {
return $field->as_string('adfghklmnoprstvxyz68');
} elsif ($tag eq '148') {
return $field->as_string('abvxyz68');
} elsif ($tag eq '150') {
return $field->as_string('abvxyz68');
} elsif ($tag eq '151') {
return $field->as_string('avxyz68');
} elsif ($tag eq '155') {
return $field->as_string('abvxyz68');
} elsif ($tag eq '180') {
return $field->as_string('vxyz68');
} elsif ($tag eq '181') {
return $field->as_string('vxyz68');
} elsif ($tag eq '182') {
return $field->as_string('vxyz68');
} elsif ($tag eq '185') {
return $field->as_string('vxyz68');
} else {
return $field->as_string();
}
}
}
return;
}
=head2 BuildUnimarcHierarchies
$text= &BuildUnimarcHierarchies( $authid, $force)