From fe294eda23f9f921e1af69b268931aaff7b011bf Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 13 Mar 2020 17:16:28 +0000 Subject: [PATCH] Bug 24854: Remove IDreamBooks integration The IDreamBooks service has not seen updates in a long time, so we should remove the service from Koha as it's no longer operational. To test: - Apply patch and run the database update - Verify that the IDreamBooks related system preferences are gone - Verify that opac detail pages and result lists still work as expected - Run t/db_dependent/UsageStats.t Signed-off-by: Lucas Gass --- C4/UsageStats.pm | 3 -- .../atomicupdate/bug_24854-remove_idreambooks.perl | 6 +++ installer/data/mysql/sysprefs.sql | 3 -- .../admin/preferences/enhanced_content.pref | 19 ------- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 61 ---------------------- .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 44 ---------------- opac/opac-detail.pl | 3 -- opac/opac-search.pl | 3 -- t/db_dependent/UsageStats.t | 3 -- 9 files changed, 6 insertions(+), 139 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_24854-remove_idreambooks.perl diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index 7b3b8ea668..5cb1361314 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -207,9 +207,6 @@ sub BuildReport { BakerTaylorEnabled GoogleJackets HTML5MediaEnabled - IDreamBooksReadometer - IDreamBooksResults - IDreamBooksReviews LibraryThingForLibrariesEnabled LocalCoverImages OPACLocalCoverImages diff --git a/installer/data/mysql/atomicupdate/bug_24854-remove_idreambooks.perl b/installer/data/mysql/atomicupdate/bug_24854-remove_idreambooks.perl new file mode 100644 index 0000000000..0f5576a9ef --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24854-remove_idreambooks.perl @@ -0,0 +1,6 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "DELETE FROM systempreferences WHERE variable in ('IDreamBooksReadometer','IDreamBooksResults','IDreamBooksReviews')" ); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24854 - Remove IDeamBooks* system preferences)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index fc6cb8830b..8976290307 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -228,9 +228,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'), ('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'), ('HTML5MediaYouTube',0,'Embed|Don\'t embed','YouTube links as videos','YesNo'), -('IDreamBooksReadometer','0','','Display Readometer from IDreamBooks.com','YesNo'), -('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'), -('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'), ('IdRef','0','','Disable/enable the IdRef webservice from the OPAC detail page.','YesNo'), ('IllLog', 0, '', 'If ON, log information about ILL requests', 'YesNo'), ('ILLModule','0','If ON, enables the interlibrary loans module.','','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 2d4c1dfb10..033c048777 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 @@ -184,25 +184,6 @@ Enhanced Content: choices: yes: in tabs. no: in line with the bibliographic information. - IDreamLibraries: - - - - pref: IDreamBooksReviews - choices: - yes: Add - no: "Don't add" - - a tab on the OPAC details with book reviews from critics aggregated by IDreamBooks.com. - - - - pref: IDreamBooksReadometer - choices: - yes: Add - no: "Don't add" - - a "Readometer" that summarizes the reviews gathered by IDreamBooks.com to the OPAC details page. - - - - pref: IDreamBooksResults - choices: - yes: Add - no: "Don't add" - - the rating from IDreamBooks.com to OPAC search results. Syndetics: - - pref: SyndeticsEnabled 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 40421dfe5f..197672c124 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -549,9 +549,6 @@ [% IF ( defaulttab == 'media' ) %]
  • [% ELSE %]
  • [% END %]Play media
  • [% END %] - [% IF ( IDreamBooksReviews ) %] - - [% END %] [% IF ( serialcollection ) %] @@ -973,12 +970,6 @@ [% END # / IF OPACLocalCoverImages && localimages.size %] - [% IF ( IDreamBooksReviews ) %] - - [% END %] [% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %] @@ -1682,59 +1673,7 @@ [% END # / IF ( OpacStarRatings != 'disable' )%] -[% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %] - var isbn = $(".isbn:last").text().split(" ")[1]; - if (isbn) { - isbn = isbn.replace(/\W*$/, ''); - isbn = isbn.replace(/-/, ''); - - if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) { - // Use Microsoft XDR for IE version 8 or above - var xdr = new XDomainRequest(); - xdr.open("get", "https://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e"); - xdr.onload = function() { - json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... }; - eval(json); // json is now a regular JSON object - parseIDBJSON(json); // parse using same function as for jQuery's success event - } - xdr.send(); - } else { - $.getJSON("https://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){ - parseIDBJSON(json); - }); - } - } -[% END # / IDreamBooksReviews || IDreamBooksReadometer%] - }); - [% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %] - function parseIDBJSON( json ) { - if(json.total_results > 0 && json.book.rating > 0){ - var isbn = $(".isbn:last").text().split(" ")[1]; - isbn = isbn.replace(/\W+/g, ''); - - [% IF ( IDreamBooksReadometer ) %] - $(".title").append(''+json.book.title+_('); - [% END %] - - [% IF ( IDreamBooksReviews ) %] - //build new tab for critic reviews - $("#tab_idb_critic_reviews a").text($("#tab_idb_critic_reviews a").text().replace('XXX', json.book.review_count)); - - //append happy-sad cloud review - - $("#catalogue_detail_biblio").append(""+json.book.title+_(" by ")+json.book.author+""+json.book.rating+"% "+_("rating based on reviews at iDreamBooks.com")+""); - - //insert data into Book reviews tab - $.each(json.book.critic_reviews, function(){ - $("#idb_review_snippets").append("
    "+this.source+"
    \"..."+this.snippet+"...\"
    "+_("Review date: ")+this.review_date+"
    "+_("Review result: ")+this.pos_or_neg+" "+_("iDreamBooks.com rating")+"
    "); - }); - $("#seemoreidb").attr('href', json.book.detail_link); - $("#tab_idb_critic_reviews").show(); - [% END %] - } - } - [% END # / IF IDreamBooksReviews || IDreamBooksReadometer %] $(document).ready(function() { if( OPACPopupAuthorsSearch == "1" ){ 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 a9bf80502e..86baa9f802 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -330,17 +330,6 @@ [% END %] [% END %] - - [% IF ( IDreamBooksResults && SEARCH_RESULT.normalized_isbn ) %] - - [% END %] [% IF ( COinSinOPACResults && SEARCH_RESULT.coins ) %] @@ -722,39 +711,6 @@ $(document).ready(function(){ e.preventDefault(); }); - [% IF ( IDreamBooksResults ) %] - $('.idbresult').each(function() { - var isbn = $(this).children('a').text().replace(/\s*/,''); - var element = this; - - if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) { - // Use Microsoft XDR for IE version 8 or above - var xdr = new XDomainRequest(); - xdr.open("get", "https://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e"); - xdr.onload = function() { - json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... }; - eval(json); // json is now a regular JSON object - if(json.total_results > 0 && json.book.rating > 0){ - $(element).children('a').html(""+json.book.title+_(" by ")+json.book.author+""+json.book.rating+"%"); - $(element).show(); - } else { - $(element).remove(); - } - } - xdr.send(); - } else { - $.getJSON("https://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){ - if(json.total_results > 0 && json.book.rating > 0){ - $(element).children('a').html(""+json.book.title+_(" by ")+json.book.author+""+json.book.rating+"%"); - $(element).show(); - } else { - $(element).remove(); - } - }); - } - }); - [% END %] - var param1 = ""; [% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) || loggedinusername ) %] param1 += ""+_("Select titles to: ")+""; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index e58cf8b65d..f1100878bd 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1195,9 +1195,6 @@ if (C4::Context->preference('OPACLocalCoverImages') == 1) { $template->{VARS}->{localimages} = \@images; } -$template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews'); -$template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer'); -$template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults'); $template->{VARS}->{OPACPopupAuthorsSearch} = C4::Context->preference('OPACPopupAuthorsSearch'); if (C4::Context->preference('OpacHighlightedWords')) { diff --git a/opac/opac-search.pl b/opac/opac-search.pl index a3a766ac7d..01887f283a 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -1023,9 +1023,6 @@ if (C4::Context->preference('GoogleIndicTransliteration')) { $template->{VARS}->{DidYouMean} = ( defined C4::Context->preference('OPACdidyoumean') && C4::Context->preference('OPACdidyoumean') =~ m/enable/ ); -$template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksReviews'); -$template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer'); -$template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults'); if ($offset == 0) { $template->param(firstPage => 1); diff --git a/t/db_dependent/UsageStats.t b/t/db_dependent/UsageStats.t index 6b8db7e641..9241b27b58 100644 --- a/t/db_dependent/UsageStats.t +++ b/t/db_dependent/UsageStats.t @@ -468,9 +468,6 @@ sub mocking_systempreferences_to_a_set_value { BakerTaylorEnabled GoogleJackets HTML5MediaEnabled - IDreamBooksReadometer - IDreamBooksResults - IDreamBooksReviews LibraryThingForLibrariesEnabled LocalCoverImages OPACLocalCoverImages -- 2.11.0