From 33fdf290bbf58ce26756b2218bfccce10049870c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 16 May 2023 10:18:13 +0200 Subject: [PATCH] Bug 33697: Remove RecordedBooks (rbdigital) integration RecordedBooks search API integration is now obsolete following rbdigital's incorporation into OverDrive. Associated code should be removed. https://company.overdrive.com/2020/06/23/overdrive-to-acquire-rbdigital-from-rbmedia/ Test plan: use git grep extensively and confirm that this patch removes all occurrences of this feature. Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 8b9355088ad6e5238921ef554af44ffeb7677364) Signed-off-by: Tomas Cohen Arazi --- Koha/ExternalContent/RecordedBooks.pm | 119 ------- .../data/mysql/atomicupdate/bug_33697.pl | 16 + installer/data/mysql/mandatory/sysprefs.sql | 3 - .../admin/preferences/enhanced_content.pref | 12 - .../opac-tmpl/bootstrap/css/src/opac.scss | 1 - .../bootstrap/en/includes/opac-bottom.inc | 6 - .../en/includes/recordedbooks-checkout.inc | 15 - .../en/modules/opac-recordedbooks-search.tt | 178 ---------- .../bootstrap/en/modules/opac-results.tt | 19 - .../bootstrap/en/modules/opac-user.tt | 26 -- .../opac-tmpl/bootstrap/js/recordedbooks.js | 334 ------------------ opac/opac-recordedbooks-search.pl | 43 --- opac/opac-user.pl | 1 - opac/svc/recordedbooks | 148 -------- .../Koha_ExternalContent_RecordedBooks.t | 55 --- 15 files changed, 16 insertions(+), 960 deletions(-) delete mode 100644 Koha/ExternalContent/RecordedBooks.pm create mode 100755 installer/data/mysql/atomicupdate/bug_33697.pl delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/recordedbooks-checkout.inc delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recordedbooks-search.tt delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js delete mode 100755 opac/opac-recordedbooks-search.pl delete mode 100755 opac/svc/recordedbooks delete mode 100755 t/db_dependent/Koha_ExternalContent_RecordedBooks.t diff --git a/Koha/ExternalContent/RecordedBooks.pm b/Koha/ExternalContent/RecordedBooks.pm deleted file mode 100644 index 10e5b6bd65..0000000000 --- a/Koha/ExternalContent/RecordedBooks.pm +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright 2016 Catalyst -# -# 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 . - -package Koha::ExternalContent::RecordedBooks; - -use Modern::Perl; -use Carp qw( croak ); - -use base qw(Koha::ExternalContent); -use WebService::ILS::RecordedBooks::PartnerPatron; -use WebService::ILS::RecordedBooks::Partner; -use C4::Context; - -__PACKAGE__->mk_accessors(qw(domain is_identified)); - -=head1 NAME - -Koha::ExternalContent::RecordedBooks - -=head1 SYNOPSIS - - use Koha::ExternalContent::RecordedBooks; - my $rb_client = Koha::ExternalContent::RecordedBooks->new(); - my $rb_auth_url = $od_client->auth_url(); - -=head1 DESCRIPTION - -A (very) thin wrapper around C - -Takes "RecordedBooks*" Koha preferences - -=cut - -=head2 Class Methods - -=cut - -=head3 new - -my $rb_client = Koha::ExternalContent::RecordedBooks->new(); - -Create the object for interacting with RecordedBooks - -=cut - -sub new { - my $class = shift; - my $params = shift || {}; - - my $self = $class->SUPER::new($params); - unless ($params->{client}) { - my $client_secret = C4::Context->preference('RecordedBooksClientSecret') - or croak("RecordedBooksClientSecret pref not set"); - my $library_id = C4::Context->preference('RecordedBooksLibraryID') - or croak("RecordedBooksLibraryID pref not set"); - my $domain = C4::Context->preference('RecordedBooksDomain'); - my $patron = $params->{koha_session_id} ? $self->koha_patron : undef; - my $email; - if ($patron) { - $email = $patron->email - or $self->logger->warn("User with no email, cannot identify with RecordedBooks"); - } - my $client; - if ($email) { - local $@; - $client = eval { WebService::ILS::RecordedBooks::PartnerPatron->new( - client_secret => $client_secret, - library_id => $library_id, - domain => $domain, - user_id => $email, - ) }; - $self->logger->warn("Invalid RecordedBooks user $email ($@)") if $@; - $self->is_identified($client); - } - $client ||= WebService::ILS::RecordedBooks::Partner->new( - client_secret => $client_secret, - library_id => $library_id, - domain => $domain, - ); - $self->client( $client ); - } - return $self; -} - -=head1 METHODS - -L methods used without mods: - -=over 4 - -=item C - -=back - -=cut - -use vars qw{$AUTOLOAD}; -sub AUTOLOAD { - my $self = shift; - (my $method = $AUTOLOAD) =~ s/.*:://; - return $self->client->$method(@_); -} -sub DESTROY { } - -1; diff --git a/installer/data/mysql/atomicupdate/bug_33697.pl b/installer/data/mysql/atomicupdate/bug_33697.pl new file mode 100755 index 0000000000..ce43e50e40 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_33697.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "33697", + description => "Remove RecordedBooks (rbdigital) integration", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + for my $pref_name ( qw( RecordedBooksClientSecret RecordedBooksDomain RecordedBooksLibraryID ) ) { + $dbh->do(q{ + DELETE FROM systempreferences + WHERE variable=? + }, undef, $pref_name) == 1 && say $out "Removed system preference '$pref_name'"; + } + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index a9e8a97e49..db1dcabd01 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -303,9 +303,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'), ('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'), ('IntranetCatalogSearchPulldown','0', NULL, 'Show a search field pulldown for \"Search the catalog\" boxes','YesNo'), -('RecordedBooksClientSecret','','30','Client key for RecordedBooks integration','Free'), -('RecordedBooksDomain','','','RecordedBooks domain','Free'), -('RecordedBooksLibraryID','','','Library ID for RecordedBooks integration','Integer'), ('OnSiteCheckouts','0','','Enable/Disable the on-site checkouts feature','YesNo'), ('OnSiteCheckoutsForce','0','','Enable/Disable the on-site for all cases (Even if a user is debarred, etc.)','YesNo'), ('OnSiteCheckoutAutoCheck','0','','Enable/Do not enable onsite checkout by default if last checkout was an onsite checkout','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 b10983cb22..61c62e69c7 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 @@ -377,18 +377,6 @@ Enhanced content: - for user access to OverDrive.
- If you enable access you must have a SIP connection registered with - OverDrive for patron authentication against Koha - RecordedBooks: - - - - Include RecordedBooks availability information with the client secret - - pref: RecordedBooksClientSecret - - . - - - - Show items from the RecordedBooks catalog of library ID - - pref: RecordedBooksLibraryID - - . - - - - RecordedBooks domain - - pref: RecordedBooksDomain Coce cover images cache: - - pref: OpacCoce diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index 9023024c0b..7a8091493a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -2276,7 +2276,6 @@ nav { } #overdrive-results, -#recordedbooks-results, #openlibrary-results { font-weight: bold; padding-left: 1em; 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 aba60fc502..b0497410c2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -272,12 +272,6 @@ [% END %] -[% IF Koha.Preference('RecordedBooksClientSecret') && Koha.Preference('RecordedBooksLibraryID') %] - -[% END %] - [% Asset.js("lib/js-cookie/js.cookie-3.0.1.min.js") | $raw %] -[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 77816dd377..06057cd28b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -9,7 +9,6 @@ [% IF firstPage %] [% SET OverDriveEnabled = Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') %] - [% SET RecordedBooksEnabled = Koha.Preference('RecordedBooksLibraryID') && Koha.Preference('RecordedBooksClientSecret') %] [% END %] [% INCLUDE 'doc-head-open.inc' %] @@ -582,7 +581,6 @@ [% END %] [% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") | $raw %][% END %] - [% IF ( RecordedBooksEnabled ) %][% Asset.js("js/recordedbooks.js") | $raw %][% END %] [% Asset.js("js/authtoresults.js") | $raw %] [% Asset.js("lib/hc-sticky.js") | $raw %] [% IF ( OpacHighlightedWords ) %] @@ -836,23 +834,6 @@ } } ); [% END # /IF OverDriveEnabled %] - [% IF ( RecordedBooksEnabled ) %] - var $recordedbooks_results = $( '
' + MSG_SEARCHING.format('RecordedBooks') + '
' ); - $( '#numresults' ) .after( $recordedbooks_results ); - KOHA.RecordedBooks.search( querystring, [% OPACnumSearchResults || "null" | html %], null, function( data ) { - if ( data.error ) { - $recordedbooks_results.html( MSG_ERROR_SEARCHING_COLLECTION.format('RecordedBooks') + ': ' + data.error); - return; - } - - // data.total can be either 42 or "60+" - if ( typeof(data.total) === 'string' && data.total.charAt(0) > 0 || typeof(data.total) === 'number' && data.total > 0 ) { - $recordedbooks_results.html( '' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.total, 'RecordedBooks') + '' ); - } else { - $recordedbooks_results.remove(); - } - } ); - [% END # /IF RecordedBooksEnabled %] [% IF ( OpenLibrarySearch ) %] var $openlibrary_results = $( '
' + MSG_SEARCHING.format('OpenLibrary' ) + '
' ); $( '#numresults' ) .after( $openlibrary_results ); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 94a6d657e1..b13dfebf09 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -312,18 +312,11 @@ OverDrive account [% END %] - [% IF ( RecordedBooksCirculation ) %] - - [% END %]
-
-
[% IF ( issues_count ) %]
@@ -1070,9 +1063,6 @@ [% INCLUDE 'overdrive-login.inc' %] [% END %] [% END %] -[% IF ( RecordedBooksCirculation ) %] -[% INCLUDE 'recordedbooks-checkout.inc' %] -[% END %] [% INCLUDE 'opac-bottom.inc' %] [% BLOCK jsinclude %] @@ -1437,20 +1427,4 @@ }); [% END %] - [% IF RecordedBooksCirculation %] - [% Asset.js("js/recordedbooks.js") | $raw %] - - [% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js b/koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js deleted file mode 100644 index 773a970dc5..0000000000 --- a/koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js +++ /dev/null @@ -1,334 +0,0 @@ -if ( typeof KOHA == "undefined" || !KOHA ) { - var KOHA = {}; -} - -KOHA.RecordedBooks = new function() { - var svc_url = '/cgi-bin/koha/svc/recordedbooks'; - - var error_div = $('
'); - function display_error ( error ) { - error_div.text(error); - } - - var details = null; - - function is_identified() { - return details ? details.is_identified : false; - } - - var checkout_popup = null; - $( document ).ready(function() { - checkout_popup = $("#recordedbooks-checkout"); - }); - - function display_account (container, data) { - if (!data.is_identified) { - return; - } - - if (data.checkouts) { - var checkouts_div = $('
').html('

' + MSG_CHECKOUTS + '

'); - var items = data.checkouts.items; - var checkouts_list; - if (items.length == 0) { - checkouts_list = MSG_NO_CHECKOUTS; - } else { - checkouts_list = $('