Bugzilla – Attachment 190000 Details for
Bug 41318
AmazonLocale system preference - add Brazil as an option
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41318: Rename AmazonLocale to AmazonLocaleTld
Bug-41318-Rename-AmazonLocale-to-AmazonLocaleTld.patch (text/plain), 19.24 KB, created by
David Nind
on 2025-11-27 18:37:48 UTC
(
hide
)
Description:
Bug 41318: Rename AmazonLocale to AmazonLocaleTld
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-11-27 18:37:48 UTC
Size:
19.24 KB
patch
obsolete
>From 7820db695823c8bb5087866ce36aa374ca974a92 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 27 Nov 2025 12:38:53 +0100 >Subject: [PATCH] Bug 41318: Rename AmazonLocale to AmazonLocaleTld > >To be more flexible we could allow the top-level domain instead of >having a predefined list. >However this patch still list the different available options (and adds >Brazilian) for easy selection. > >Note that this system preference is not used to retrieve the image but >only to link to from the image. Contrary to what the reporter of the bug >report thought. And actually what I thought as well until I finished to >write the patch and started testing it! >Anyway now the patch is written, there should not be any changes in >behaviour. Most of the time the links are actually broken when not using >.com. So I think we either broke the whole feature at some point, or it >never really worked. On a separate bug we could eventually have a look >at fetching from the locale tld. > >Test plan: >Turn on OPACAmazonCoverImages and AmazonCoverImages >http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=5 >http://localhost:8080/cgi-bin/koha/opac-detail.pl?biblionumber=5 >=> You see the PBP cover >click on it, it opens the lightbox, click "(see the original image)" at >the bottom >=> This is where the syspref AmazonLocale/AmazonLocaleTld acts > >Modify the syspref's value and confirm that the link is modified and >point to the correct domain (leading to 404 or broken pages most of the time, >at least in my tests). > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/External/Amazon.pm | 80 ------------------- > catalogue/detail.pl | 14 ++-- > .../data/mysql/atomicupdate/bug_41318.pl | 34 ++++++++ > .../data/mysql/localization/de-DE/custom.sql | 2 +- > .../data/mysql/localization/fr-CA/custom.sql | 2 +- > installer/data/mysql/mandatory/sysprefs.sql | 2 +- > .../admin/preferences/enhanced_content.pref | 24 +++--- > .../prog/en/modules/catalogue/detail.tt | 2 +- > .../bootstrap/en/includes/cover-images.inc | 3 +- > .../bootstrap/en/modules/opac-detail.tt | 2 +- > opac/opac-detail.pl | 3 - > t/db_dependent/Amazon.t | 51 ------------ > t/db_dependent/check_sysprefs.t | 4 +- > 13 files changed, 62 insertions(+), 161 deletions(-) > delete mode 100644 C4/External/Amazon.pm > create mode 100755 installer/data/mysql/atomicupdate/bug_41318.pl > delete mode 100755 t/db_dependent/Amazon.t > >diff --git a/C4/External/Amazon.pm b/C4/External/Amazon.pm >deleted file mode 100644 >index 297443fdf0..0000000000 >--- a/C4/External/Amazon.pm >+++ /dev/null >@@ -1,80 +0,0 @@ >-package C4::External::Amazon; >- >-# Copyright (C) 2006 LibLime >-# <jmf at liblime dot com> >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <https://www.gnu.org/licenses>. >- >-use strict; >-use warnings; >- >-use vars qw(@ISA @EXPORT); >- >-BEGIN { >- require Exporter; >- @ISA = qw(Exporter); >- @EXPORT = qw( >- get_amazon_tld >- ); >-} >- >-sub get_amazon_tld { >- my %tld = ( >- CA => '.ca', >- DE => '.de', >- FR => '.fr', >- IN => '.in', >- JP => '.jp', >- UK => '.co.uk', >- US => '.com', >- ); >- >- my $locale = C4::Context->preference('AmazonLocale'); >- my $tld = $tld{$locale} || '.com'; # default top level domain is .com >- return $tld; >-} >- >-=head1 NAME >- >-C4::External::Amazon - Functions for retrieving Amazon.com content in Koha >- >-=head2 FUNCTIONS >- >-This module provides facilities for retrieving Amazon.com content in Koha >- >-=over >- >-=item get_amazon_tld() >- >-Get Amazon Top Level Domain depending on Amazon local preference: AmazonLocal. >-For example, if AmazonLocal is 'UK', returns '.co.uk'. >- >-=back >- >-=cut >- >-1; >-__END__ >- >-=head1 NOTES >- >-=cut >- >-=head1 AUTHOR >- >-Joshua Ferraro <jmf@liblime.com> >- >-=cut >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index f8a1fe447e..0dd89317b6 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -34,13 +34,12 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::Biblio qw( GetBiblioData GetFrameworkCode ); > use C4::Items qw( GetAnalyticsCount ); > use C4::Reserves; >-use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); >-use C4::XISBN qw( get_xisbns ); >-use C4::External::Amazon qw( get_amazon_tld ); >-use C4::Search qw( z3950_search_args enabled_staff_search_views new_record_from_zebra ); >-use C4::Tags qw( get_tags ); >-use C4::XSLT qw( XSLTParse4Display ); >-use Koha::DateUtils qw( format_sqldatetime ); >+use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); >+use C4::XISBN qw( get_xisbns ); >+use C4::Search qw( z3950_search_args enabled_staff_search_views new_record_from_zebra ); >+use C4::Tags qw( get_tags ); >+use C4::XSLT qw( XSLTParse4Display ); >+use Koha::DateUtils qw( format_sqldatetime ); > use C4::HTML5Media; > use C4::CourseReserves qw( GetItemCourseReservesInfo ); > use Koha::AuthorisedValues; >@@ -434,7 +433,6 @@ foreach ( keys %{$dat} ) { > > # does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews'); > # method query not found?!?! >-$template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages") ); > $template->param( > biblionumber => $biblionumber, > ( $analyze ? 'analyze' : 'detailview' ) => 1, >diff --git a/installer/data/mysql/atomicupdate/bug_41318.pl b/installer/data/mysql/atomicupdate/bug_41318.pl >new file mode 100755 >index 0000000000..4d29b948f9 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_41318.pl >@@ -0,0 +1,34 @@ >+use Modern::Perl; >+use Koha::Installer::Output qw(say_warning say_success say_info); >+ >+return { >+ bug_number => "41318", >+ description => "Rename system preference AmazonLocale to AmazonLocaleTld", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ my $pref_exists = >+ $dbh->selectrow_array(q{SELECT COUNT(*) FROM systempreferences WHERE variable = "AmazonLocale"}); >+ if ($pref_exists) { >+ $dbh->do( >+ q{ >+ UPDATE systempreferences >+ SET `variable`="AmazonLocaleTld", >+ `explanation`="Use to set the locale top-level domain (tld) of your Amazon web services", >+ `type`="free", >+ `value` = CASE `value` >+ WHEN 'CA' THEN 'ca' >+ WHEN 'UK' THEN 'co.uk' >+ WHEN 'DE' THEN 'de' >+ WHEN 'FR' THEN 'fr' >+ WHEN 'IN' THEN 'in' >+ WHEN 'JP' THEN 'jp' >+ ELSE 'com' >+ END >+ WHERE `variable`="AmazonLocale" >+ } >+ ) && say $out "Renamed system preference 'AmazonLocale' to 'AmazonLocaleTld"; >+ } >+ }, >+}; >diff --git a/installer/data/mysql/localization/de-DE/custom.sql b/installer/data/mysql/localization/de-DE/custom.sql >index c30dad0d1d..99bf368be2 100644 >--- a/installer/data/mysql/localization/de-DE/custom.sql >+++ b/installer/data/mysql/localization/de-DE/custom.sql >@@ -16,7 +16,7 @@ > -- You should have received a copy of the GNU General Public License > -- along with Koha; if not, see <https://www.gnu.org/licenses>. > >-UPDATE systempreferences SET value = 'DE' WHERE variable = 'AmazonLocale'; >+UPDATE systempreferences SET value = 'de' WHERE variable = 'AmazonLocaleTld'; > UPDATE systempreferences SET value = 'Vater|Mutter' WHERE variable = 'borrowerRelationship'; > UPDATE systempreferences SET value = 'Herr|Frau' WHERE variable = 'BorrowersTitles'; > UPDATE systempreferences SET value = 'FR' WHERE variable = 'CurencyFormat'; >diff --git a/installer/data/mysql/localization/fr-CA/custom.sql b/installer/data/mysql/localization/fr-CA/custom.sql >index da727eaf90..941cf9dd75 100644 >--- a/installer/data/mysql/localization/fr-CA/custom.sql >+++ b/installer/data/mysql/localization/fr-CA/custom.sql >@@ -17,7 +17,7 @@ > -- along with Koha; if not, see <https://www.gnu.org/licenses>. > > UPDATE systempreferences SET value = 'fre|eng' WHERE variable = 'AdvancedSearchLanguages'; >-UPDATE systempreferences SET value = 'CA' WHERE variable = 'AmazonLocale'; >+UPDATE systempreferences SET value = 'ca' WHERE variable = 'AmazonLocaleTld'; > UPDATE systempreferences SET value = 'père|mère|grand-parent|tuteur légal|autre' WHERE variable = 'borrowerRelationship'; > UPDATE systempreferences SET value = 'M.|Mme|Mx' WHERE variable = 'BorrowersTitles'; > UPDATE systempreferences SET value = 'FR' WHERE variable = 'CurencyFormat'; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 35a5d15dd8..6c71df0d99 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -60,7 +60,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AlwaysShowHoldingsTableFilters','0','','Option to always show filters when loading the holdings table','YesNo'), > ('AmazonAssocTag','','','See: http://aws.amazon.com','free'), > ('AmazonCoverImages','0','','Display Cover Images in staff interface from Amazon Web Services','YesNo'), >-('AmazonLocale','US','US|CA|DE|FR|IN|JP|UK','Use to set the Locale of your Amazon.com Web Services','Choice'), >+('AmazonLocaleTld','com','','Use to set the locale top-level domain (tld) of your Amazon web services','free'), > ('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'), > ('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for suggestion and checkout history privacy',''), > ('ApplyFrameworkDefaults', 'new', 'new|duplicate|changed|imported', 'Configure when to apply framework default values - when cataloguing a new record, or when editing a record as new (duplicating), or when changing framework, or when importing a record', 'multiple'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >index 1f088136f4..3b4cbceeb2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >@@ -18,17 +18,19 @@ Enhanced content: > - other editions of an item on the OPAC. > Amazon: > - >- - Use Amazon data from its >- - pref: AmazonLocale >- choices: >- US: American >- CA: Canadian >- DE: German >- FR: French >- IN: Indian >- JP: Japanese >- UK: British >- - website. >+ - Use Amazon data using the following top-level domain >+ - pref: AmazonLocaleTld >+ - . >+ - '<br />Options:<ul>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="com">com</a>" for American</li>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="com.br">com.br</a>" for Brazilian</li>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="co.uk">co.uk</a>" for British</li>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="ca">ca</a>" for Canadian</li>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="fr">fr</a>" for French</li>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="de">de</a>" for German</li>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="in">in</a>" for Indian</li>' >+ - '<li>Enter "<a href="#" class="set_syspref" data-syspref="AmazonLocaleTld" data-value="jp">jp</a>" for Japanese</li>' >+ - '</ul>' > - > - Put the associate tag > - pref: AmazonAssocTag >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 061b5d39a1..0786801898 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -262,7 +262,7 @@ > <img > src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.MZZZZZZZ.jpg" > alt="Amazon cover image" >- data-link="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link" >+ data-link="http://www.amazon.[% Koha.Preference('AmazonLocaleTld') | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link" > /> > </a> > <div class="hint">Image from Amazon.com</div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/cover-images.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/cover-images.inc >index 16f7fe2698..ec28532fd9 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/cover-images.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/cover-images.inc >@@ -1,4 +1,5 @@ > [% USE raw %] >+[% USE Koha %] > [% USE ItemTypes %] > <div > class="bookcover" >@@ -33,7 +34,7 @@ > src="https://images-na.ssl-images-amazon.com/images/P/[% SEARCH_RESULT.normalized_isbn | uri %].01.MZZZZZZZ.jpg" > alt="Amazon cover image" > id="amazon-thumbnail-[% SEARCH_RESULT.biblionumber | html %]" >- data-link="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% SEARCH_RESULT.normalized_isbn | html %][% AmazonAssocTag | html %]#reader-link" >+ data-link="http://www.amazon.[% Koha.Preference('AmazonLocaleTld') | uri %]/gp/reader/[% SEARCH_RESULT.normalized_isbn | html %][% AmazonAssocTag | html %]#reader-link" > /> > </a> > <div class="hint">Image from Amazon.com</div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index 0c85fbb735..68643d5536 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -100,7 +100,7 @@ > <img > src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | uri %].01.MZZZZZZZ.jpg" > alt="Amazon cover image" >- data-link="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link" >+ data-link="http://www.amazon.[% Koha.Preference('AmazonLocaleTld') | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link" > /> > </a> > <div class="hint">Image from Amazon.com</div> >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 211dac36ea..292ba3b8e2 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -46,7 +46,6 @@ use C4::Biblio qw( > use C4::Record qw( marc2cites ); > use C4::Tags qw( get_tags ); > use C4::XISBN qw( get_xisbns ); >-use C4::External::Amazon qw( get_amazon_tld ); > use C4::External::BakerTaylor qw( image_url link_url ); > use C4::External::Syndetics qw( > get_syndetics_anotes >@@ -1140,8 +1139,6 @@ if ( C4::Context->preference("OPACShelfBrowser") ) { > } > } > >-$template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages") ); >- > if ( C4::Context->preference("BakerTaylorEnabled") ) { > $template->param( > BakerTaylorEnabled => 1, >diff --git a/t/db_dependent/Amazon.t b/t/db_dependent/Amazon.t >deleted file mode 100755 >index 7af8666621..0000000000 >--- a/t/db_dependent/Amazon.t >+++ /dev/null >@@ -1,51 +0,0 @@ >-#!/usr/bin/perl >-# >-# This Koha test module is a stub! >-# Add more tests here!!! >- >-use strict; >-use warnings; >- >-use Test::NoWarnings; >-use Test::More tests => 9; >-use t::lib::Mocks; >-use C4::Context; >- >-BEGIN { >- use_ok( 'C4::External::Amazon', qw( get_amazon_tld ) ); >-} >- >-my $context = C4::Context->new(); >- >-my $locale = $context->preference('AmazonLocale'); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', 'CA' ); >-$context->clear_syspref_cache(); >-is( get_amazon_tld, '.ca', 'Changes locale to CA and tests get_amazon_tld' ); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', 'DE' ); >-$context->clear_syspref_cache(); >-is( get_amazon_tld, '.de', 'Changes locale to DE and tests get_amazon_tld' ); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', 'FR' ); >-$context->clear_syspref_cache(); >-is( get_amazon_tld, '.fr', 'Changes locale to FR and tests get_amazon_tld' ); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', 'JP' ); >-$context->clear_syspref_cache(); >-is( get_amazon_tld, '.jp', 'Changes locale to JP and tests get_amazon_tld' ); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', 'UK' ); >-$context->clear_syspref_cache(); >-is( get_amazon_tld, '.co.uk', 'Changes locale to UK and tests get_amazon_tld' ); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', 'US' ); >-$context->clear_syspref_cache(); >-is( get_amazon_tld, '.com', 'Changes locale to US and tests get_amazon_tld' ); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', 'NZ' ); >-$context->clear_syspref_cache(); >-is( get_amazon_tld, '.com', 'Changes locale to one not in the array and tests get_amazon_tld' ); >- >-t::lib::Mocks::mock_preference( 'AmazonLocale', $locale ); >-$context->clear_syspref_cache(); >diff --git a/t/db_dependent/check_sysprefs.t b/t/db_dependent/check_sysprefs.t >index a09a5b5286..1d47ac149d 100755 >--- a/t/db_dependent/check_sysprefs.t >+++ b/t/db_dependent/check_sysprefs.t >@@ -86,8 +86,8 @@ subtest 'Compare sysprefs.sql with YAML files' => sub { > # > # Example: > # INSERT INTO `systempreferences` (variable,value,explanation,options,type) >-# VALUES('AmazonLocale','US','Use to set the Locale of your Amazon.com Web Services', >-# 'US|CA|DE|FR|JP|UK','Choice') >+# VALUES('AmazonLocaleTld','com','Use to set the Locale of your Amazon.com Web Services', >+# '','Free') > # > sub get_syspref_from_file { > my $fh = shift; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41318
:
189988
| 190000