From 9ee9e7d2a30df6b4b5d852f676c20e4bc7a1a620 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 18 Dec 2025 08:49:32 -0500 Subject: [PATCH] Bug 41479: Remove Baker & Taylor integration This patch removes Baker & Taylor integration following the shutdown of the company. To test, apply the patch, run the database update, and restart all. - In the staff interface go to Administration -> System preferences and search for 'Baker.' There should be no results. - If necessary enable at least one cover image service, e.g. AmazonCoverImages, OpacCoce, GoogleJackets, etc. - Log in to the OPAC and confirm that cover images display correctly on these pages: - Search results - Bibliographic detail page - Shelf browser - Your summary -> Checked out - Checkout history - Recent comments - Lists Sponsored-by: Athens County Public Libraries --- C4/External/BakerTaylor.pm | 169 ------------------ C4/UsageStats.pm | 1 - .../data/mysql/atomicupdate/bug_41479.pl | 15 ++ installer/data/mysql/mandatory/sysprefs.sql | 4 - .../admin/preferences/enhanced_content.pref | 20 --- .../bootstrap/en/includes/cover-images.inc | 16 -- .../bootstrap/en/includes/opac-bottom.inc | 9 - .../bootstrap/en/includes/shelfbrowser.inc | 10 +- .../bootstrap/en/modules/opac-detail.tt | 25 --- .../bootstrap/en/modules/opac-opensearch.tt | 12 -- .../en/modules/opac-readingrecord.tt | 13 +- .../bootstrap/en/modules/opac-results.tt | 3 +- .../bootstrap/en/modules/opac-shelves.tt | 3 +- .../en/modules/opac-showreviews-rss.tt | 3 - .../bootstrap/en/modules/opac-showreviews.tt | 8 - .../bootstrap/en/modules/opac-user.tt | 20 --- .../opac-tmpl/bootstrap/js/cover_images.js | 4 - opac/opac-detail.pl | 32 +--- opac/opac-readingrecord.pl | 9 - opac/opac-search.pl | 10 -- opac/opac-shelves.pl | 16 +- opac/opac-user.pl | 18 +- t/External/BakerTaylor.t | 36 ---- 23 files changed, 31 insertions(+), 425 deletions(-) delete mode 100644 C4/External/BakerTaylor.pm create mode 100755 installer/data/mysql/atomicupdate/bug_41479.pl delete mode 100755 t/External/BakerTaylor.t diff --git a/C4/External/BakerTaylor.pm b/C4/External/BakerTaylor.pm deleted file mode 100644 index 3da7f84d1bb..00000000000 --- a/C4/External/BakerTaylor.pm +++ /dev/null @@ -1,169 +0,0 @@ -package C4::External::BakerTaylor; - -# Copyright (C) 2008 LibLime -# -# -# 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 . - -use Modern::Perl; -use base 'Exporter'; - -BEGIN { - our @EXPORT_OK = qw(availability content_cafe_url image_url link_url http_jacket_link); -} - -use XML::Simple; -use LWP::Simple qw( get ); - -use C4::Context; - -use vars qw(%EXPORT_TAGS $VERSION); - -BEGIN { - $VERSION = 3.07.00.049; -} - -# These variables are plack safe: they are initialized each time -my ( $user, $pass, $agent, $image_url, $link_url ); - -sub _initialize { - $user = ( @_ ? shift : C4::Context->preference('BakerTaylorUsername') ) || ''; # LL17984 - $pass = ( @_ ? shift : C4::Context->preference('BakerTaylorPassword') ) || ''; # CC82349 - $link_url = ( @_ ? shift : C4::Context->preference('BakerTaylorBookstoreURL') ); - $image_url = - "https://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=$user&Password=$pass&Options=Y&Return=T&Type=S&Value="; - $agent = "Koha/$VERSION [en] (Linux)"; - - #"Mozilla/4.76 [en] (Win98; U)", # if for some reason you want to go stealth, you might prefer this -} - -sub image_url { - _initialize(); - ( $user and $pass ) or return; - my $isbn = ( @_ ? shift : '' ); - $isbn =~ s/(p|-)//g; # sanitize - return $image_url . $isbn; -} - -sub link_url { - _initialize(); - my $isbn = ( @_ ? shift : '' ); - $isbn =~ s/(p|-)//g; # sanitize - $link_url or return; - return $link_url . $isbn; -} - -sub content_cafe_url { - _initialize(); - ( $user and $pass ) or return; - my $isbn = ( @_ ? shift : '' ); - $isbn =~ s/(p|-)//g; # sanitize - return - "https://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=$user&Password=$pass&Options=Y&ItemKey=$isbn"; -} - -sub http_jacket_link { - _initialize(); - my $isbn = shift or return; - $isbn =~ s/(p|-)//g; # sanitize - my $image = availability($isbn); - my $alt = "Buy this book"; - $image and $image = qq($alt); - my $link = &link_url($isbn); - unless ($link) { return $image || ''; } - return sprintf qq(%s), $link, ( $image || $alt ); -} - -sub availability { - _initialize(); - my $isbn = shift or return; - ( $user and $pass ) or return; - $isbn =~ s/(p|-)//g; # sanitize - my $url = - "https://contentcafe2.btol.com/ContentCafe/InventoryAvailability.asmx/CheckInventory?UserID=$user&Password=$pass&Value=$isbn"; - my $content = get($url); - warn "could not retrieve $url" unless $content; - my $xmlsimple = XML::Simple->new(); - my $result = $xmlsimple->XMLin($content); - - if ( $result->{Error} ) { - warn "Error returned to " . __PACKAGE__ . " : " . $result->{Error}; - } - my $avail = $result->{Availability}; - return ( $avail and $avail !~ /^false$/i ) ? &image_url($isbn) : 0; -} - -1; - -__END__ - -=head1 NAME - -C4::External::BakerTaylor - -=head1 DESCRIPTION - -Functions for retrieving content from Baker and Taylor, inventory availability and "Content Cafe". - -The settings for this module are controlled by System Preferences: - -These can be overridden for testing purposes using the initialize function. - -=head1 FUNCTIONS - -=head2 image_url - -Missing POD for image_url. - -=head2 link_url - -Missing POD for link_url. - -=head2 content_cafe_url - -Missing POD for content_cafe_url. - -=head2 http_jacket_link - -Missing POD for http_jacket_link. - -=head2 availability($isbn); - -$isbn is a isbn string - -=head1 NOTES - -A request with failed authentication might see this back from Baker + Taylor: - - - - string - false - Invalid UserID - - -Such response will trigger a warning for each request (potentially many). Point being, do not leave this module configured with incorrect username and password in production. - -=head1 SEE ALSO - -LWP::UserAgent - -=head1 AUTHOR - -Joe Atzberger -atz AT liblime DOT com - -=cut diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index cb755a45242..75e037cf82d 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -236,7 +236,6 @@ sub _shared_preferences { AmazonCoverImages OPACAmazonCoverImages Babeltheque - BakerTaylorEnabled GoogleJackets HTML5MediaEnabled LibraryThingForLibrariesEnabled diff --git a/installer/data/mysql/atomicupdate/bug_41479.pl b/installer/data/mysql/atomicupdate/bug_41479.pl new file mode 100755 index 00000000000..e64cefca1c2 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_41479.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => "41479", + description => + "Remove system preferences BakerTaylorBookstoreURL, BakerTaylorEnabled, BakerTaylorPassword, BakerTaylorUsername", + up => sub { + my ($args) = @_; + my $dbh = $args->{dbh}; + + $dbh->do( + q{ DELETE FROM systempreferences WHERE variable IN ('BakerTaylorBookstoreURL', 'BakerTaylorEnabled', 'BakerTaylorPassword', 'BakerTaylorUsername')} + ); + }, + } diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 2476391b835..2fedd629720 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -114,10 +114,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('Babeltheque','0',NULL,'Turn ON Babeltheque content - See babeltheque.com to subscribe to this service','YesNo'), ('Babeltheque_url_js','',NULL,'Url for Babeltheque javascript (e.g. http://www.babeltheque.com/bw_XX.js)','Free'), ('Babeltheque_url_update','',NULL,'Url for Babeltheque update (E.G. http://www.babeltheque.com/.../file.csv.bz2)','Free'), -('BakerTaylorBookstoreURL','',NULL,'URL template for "My Libary Bookstore" links, to which the "key" value is appended, and "https://" is prepended. It should include your hostname and "Parent Number". Make this variable empty to turn MLB links off. Example: ocls.mylibrarybookstore.com/MLB/actions/searchHandler.do?nextPage=bookDetails&parentNum=10923&key=',''), -('BakerTaylorEnabled','0',NULL,'Enable or disable all Baker & Taylor features.','YesNo'), -('BakerTaylorPassword','',NULL,'Baker & Taylor Password for Content Cafe (external content)','Free'), -('BakerTaylorUsername','',NULL,'Baker & Taylor Username for Content Cafe (external content)','Free'), ('BarcodeSeparators','\\s\\r\\n',NULL,'Splitting characters for barcodes','Free'), ('BasketConfirmations','1','always ask for confirmation.|do not ask for confirmation.','When closing or reopening a basket,','Choice'), ('BatchCheckouts','0',NULL,'Enable or disable batch checkouts','YesNo'), 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 903f02de418..4bc9596dbd3 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 @@ -64,26 +64,6 @@ Enhanced content: - pref: Babeltheque_url_update class: url - (e.g. http://www.babeltheque.com/.../file.csv.bz2). - Baker and Taylor: - - - - pref: BakerTaylorEnabled - choices: - 1: Add - 0: "Don't add" - - Baker and Taylor links and cover images to the OPAC and staff interface. This requires that you have entered in a username and password (which can be seen in image links). - - - - 'Baker and Taylor "My Library Bookstore" links should be accessed at https://' - - pref: BakerTaylorBookstoreURL - class: url - - isbn (this should be filled in with something like ocls.mylibrarybookstore.com/MLB/actions/searchHandler.do?nextPage=bookDetails&parentNum=10923&key=). Leave it blank to disable these links. - - - - Access Baker and Taylor using username - - pref: BakerTaylorUsername - class: password - - and password - - pref: BakerTaylorPassword - class: password - - . Novelist Select: - - pref: NovelistSelectEnabled 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 16f7fe26984..6ff39db6f1d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/cover-images.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/cover-images.inc @@ -81,22 +81,6 @@ [% END %] - [% bt_id = ( SEARCH_RESULT.normalized_upc || SEARCH_RESULT.normalized_isbn ) %] - [% IF ( BakerTaylorEnabled && bt_id ) %] -
- [% IF BakerTaylorBookstoreURL %] - - See Baker & Taylor - - [% ELSE %] - - See Baker & Taylor - - [% END %] -
Image from Baker & Taylor
-
- [% END %] - [% IF OPACCustomCoverImages %] [% SET custom_cover_image_url = SEARCH_RESULT.biblio_object.custom_cover_image_url %] [% IF custom_cover_image_url %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index 825846e29af..75060152d90 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -159,15 +159,6 @@ [% Asset.js("js/localcovers.js") | $raw %] [% END %] -[% IF ( BakerTaylorEnabled ) %] - [% Asset.js("js/bakertaylorimages.js") | $raw %] - -[% END %] - [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]