Bug 33957: Add normalized_oclc and only fetch when needed

opac-user.tt wants to normalized_oclc number if using syndetics or B&T images

We don't need to fetch it if not, but we need to pass it if so

To test:
1 - Switch all Syndetics prefs to 'Show' or 'Use' except
    SyndeticsClientCode = just enter 'test'
2 - Checkout some items to a patron, ensure the records have:
    - ISBN
    - UPC
    - OCLC number
3 - View opac-user.pl (sign in to opac as the user)
4 - View the network console tab (may need to reload)
5 - Note requests like:
    https://secure.syndetics.com/index.aspx?isbn=1780335792/MC.GIF&client=test&type=xw10&upc=&oclc=
6 - Note that oclc parameter is not filled for record with an oclc number
7 - Apply patch
8 - Reload
9 - Confirm the link now has oclc as expected
10 - Disable syndetics, enable google books or another source
11 - Confirm images display as expected

JD amended patch: tidy

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit a59f757fd7)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 67343cbd45)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2023-06-08 11:15:27 +00:00 committed by Matt Blenkinsop
parent 0efca288a2
commit 738dedd8db

View file

@ -27,6 +27,7 @@ use C4::Koha qw(
getitemtypeimagelocation getitemtypeimagelocation
GetNormalizedISBN GetNormalizedISBN
GetNormalizedUPC GetNormalizedUPC
GetNormalizedOCLCNumber
); );
use C4::Circulation qw( CanBookBeRenewed GetRenewCount GetIssuingCharges ); use C4::Circulation qw( CanBookBeRenewed GetRenewCount GetIssuingCharges );
use C4::External::BakerTaylor qw( image_url link_url ); use C4::External::BakerTaylor qw( image_url link_url );
@ -284,9 +285,15 @@ if ( $pending_checkouts->count ) { # Useless test
my $isbn = GetNormalizedISBN($issue->{'isbn'}); my $isbn = GetNormalizedISBN($issue->{'isbn'});
$issue->{normalized_isbn} = $isbn; $issue->{normalized_isbn} = $isbn;
my $marcrecord = $biblio_object->metadata->record({ embed_items => 1, opac => 1, patron => $patron,});
$issue->{normalized_upc} = GetNormalizedUPC( $marcrecord, C4::Context->preference('marcflavour') );
if ( C4::Context->preference('BakerTaylorEnabled')
|| C4::Context->preference('SyndeticsEnabled')
|| C4::Context->preference('SyndeticsCoverImages') )
{
my $marcrecord = $biblio_object->metadata->record( { embed_items => 1, opac => 1, patron => $patron, } );
$issue->{normalized_upc} = GetNormalizedUPC( $marcrecord, C4::Context->preference('marcflavour') );
$issue->{normalized_oclc} = GetNormalizedOCLCNumber( $marcrecord, C4::Context->preference('marcflavour') );
}
# My Summary HTML # My Summary HTML
if (my $my_summary_html = C4::Context->preference('OPACMySummaryHTML')){ if (my $my_summary_html = C4::Context->preference('OPACMySummaryHTML')){
$issue->{author} ? $my_summary_html =~ s/{AUTHOR}/$issue->{author}/g : $my_summary_html =~ s/{AUTHOR}//g; $issue->{author} ? $my_summary_html =~ s/{AUTHOR}/$issue->{author}/g : $my_summary_html =~ s/{AUTHOR}//g;