Browse Source

Bug 22140: Use of EasyAnalyticalRecords pref in search

Like Bug 20702 defined GetHostItemsInfo does nothing if EasyAnalyticalRecords pref is disabled, there are other places where code must be dependant on this pref.

Test plan :
1) Build an analitical record with 773$0 and $9
2) Enable EasyAnalyticalRecords
3) Don't apply patch
4) Go to OPAC
5) Perform a search that displays the record, check there is the linked item
6) Open record detail page, check there is the linked item
7) Apply patch and redo 5) and 6)
8) Disable EasyAnalyticalRecords
9) redo 5) and 6), you should not see the linked item

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
19.05.x
Fridolin Somers 4 years ago
committed by Nick Clemens
parent
commit
7266d50dd2
  1. 45
      C4/Search.pm
  2. 31
      opac/opac-detail.pl

45
C4/Search.pm

@ -2008,28 +2008,31 @@ sub searchResults {
# Pull out the items fields
my @fields = $marcrecord->field($itemtag);
my $marcflavor = C4::Context->preference("marcflavour");
# adding linked items that belong to host records
my $analyticsfield = '773';
if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
$analyticsfield = '773';
} elsif ($marcflavor eq 'UNIMARC') {
$analyticsfield = '461';
}
foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
my $hostbiblionumber = $hostfield->subfield("0");
my $linkeditemnumber = $hostfield->subfield("9");
if( $hostbiblionumber ) {
my $hostbiblio = GetMarcBiblio({
biblionumber => $hostbiblionumber,
embed_items => 1 });
my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
if( $hostbiblio ) {
my @hostitems = $hostbiblio->field($itemfield);
foreach my $hostitem (@hostitems){
if ($hostitem->subfield("9") eq $linkeditemnumber){
my $linkeditem =$hostitem;
# append linked items if they exist
push @fields, $linkeditem if $linkeditem;
if ( C4::Context->preference('EasyAnalyticalRecords') ) {
my $analyticsfield = '773';
if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
$analyticsfield = '773';
} elsif ($marcflavor eq 'UNIMARC') {
$analyticsfield = '461';
}
foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
my $hostbiblionumber = $hostfield->subfield("0");
my $linkeditemnumber = $hostfield->subfield("9");
if( $hostbiblionumber ) {
my $hostbiblio = GetMarcBiblio({
biblionumber => $hostbiblionumber,
embed_items => 1 });
my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
if( $hostbiblio ) {
my @hostitems = $hostbiblio->field($itemfield);
foreach my $hostitem (@hostitems){
if ($hostitem->subfield("9") eq $linkeditemnumber){
my $linkeditem =$hostitem;
# append linked items if they exist
push @fields, $linkeditem if $linkeditem;
}
}
}
}

31
opac/opac-detail.pl

@ -481,21 +481,22 @@ $template->param(
OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
);
# adding items linked via host biblios
my $analyticfield = '773';
if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
$analyticfield = '773';
} elsif ($marcflavour eq 'UNIMARC') {
$analyticfield = '461';
}
foreach my $hostfield ( $record->field($analyticfield)) {
my $hostbiblionumber = $hostfield->subfield("0");
my $linkeditemnumber = $hostfield->subfield("9");
my @hostitemInfos = GetItemsInfo($hostbiblionumber);
foreach my $hostitemInfo (@hostitemInfos){
if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
push(@all_items, $hostitemInfo);
if ( C4::Context->preference('EasyAnalyticalRecords') ) {
# adding items linked via host biblios
my $analyticfield = '773';
if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
$analyticfield = '773';
} elsif ($marcflavour eq 'UNIMARC') {
$analyticfield = '461';
}
foreach my $hostfield ( $record->field($analyticfield)) {
my $hostbiblionumber = $hostfield->subfield("0");
my $linkeditemnumber = $hostfield->subfield("9");
my @hostitemInfos = GetItemsInfo($hostbiblionumber);
foreach my $hostitemInfo (@hostitemInfos){
if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
push(@all_items, $hostitemInfo);
}
}
}
}

Loading…
Cancel
Save