Bug 24854: Remove IDreamBooks integration
authorKatrin Fischer <katrin.fischer.83@web.de>
Fri, 13 Mar 2020 17:16:28 +0000 (17:16 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 24 Mar 2020 08:07:23 +0000 (08:07 +0000)
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 <lucas@bywatersolutions.com>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/UsageStats.pm
installer/data/mysql/atomicupdate/bug_24854-remove_idreambooks.perl [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
opac/opac-detail.pl
opac/opac-search.pl
t/db_dependent/UsageStats.t

index 7b3b8ea..5cb1361 100644 (file)
@@ -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 (file)
index 0000000..de6acb8
--- /dev/null
@@ -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 IDreamBooks* system preferences)\n";
+}
index 612dcc2..ba95509 100644 (file)
@@ -229,9 +229,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'),
index 2d4c1df..033c048 100644 (file)
@@ -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 <a href='https://idreambooks.com/'>IDreamBooks.com</a>.
-        -
-            - pref: IDreamBooksReadometer
-              choices:
-                  yes: Add
-                  no: "Don't add"
-            - a "Readometer" that summarizes the reviews gathered by <a href='https://idreambooks.com/'>IDreamBooks.com</a> to the OPAC details page.
-        -
-            - pref: IDreamBooksResults
-              choices:
-                  yes: Add
-                  no: "Don't add"
-            - the rating from <a href='https://idreambooks.com/'>IDreamBooks.com</a> to OPAC search results.
     Syndetics:
         -
             - pref: SyndeticsEnabled
index 40421df..197672c 100644 (file)
                             [% IF ( defaulttab == 'media' ) %]<li id="tab_html5media" class="ui-tabs-active">[% ELSE %]<li id="tab_html5media">[% END %]<a href="#html5media">Play media</a></li>
                         [% END %]
 
-                        [% IF ( IDreamBooksReviews ) %]
-                            <li id='tab_idb_critic_reviews' style="display:none;"><a href='#idb_critic_reviews'>Book reviews by critics ( XXX )</a></li>
-                        [% END %]
                     </ul>
 
                     [% IF ( serialcollection ) %]
                             </div><!-- / #images -->
                         [% END # / IF OPACLocalCoverImages && localimages.size %]
 
-                        [% IF ( IDreamBooksReviews ) %]
-                            <div id="idb_critic_reviews">
-                                <div id="idb_review_snippets"></div>
-                                <span><a id="seemoreidb">More book reviews at iDreamBooks.com</a></span>
-                            </div>
-                        [% END %]
                 </div> <!-- / #bibliodescriptions -->
 
                 [% IF ( NovelistSelectProfile && NovelistSelectView == 'below' && ( normalized_isbn || normalized_upc ) ) %]
 
 [% 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('<a href="'+json.book.detail_link+'" id="idreambooksreadometer"><img src="https://idreambooks.com/remotereadometer/'+isbn+'.jpg" alt="'+json.book.title+_(" by ")+json.book.author+'" title="'+_("Rating based on reviews of ")+json.book.title+'"></a>');
-                [% 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("<span class='idreambookssummary results_summary'><a href='"+json.book.detail_link+"'><img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+_(" by ")+json.book.author+"' title='"+_("Rating based on reviews of ")+json.book.title+"'>"+json.book.rating+"%</a> <a href='http://www.idreambooks.com/'>"+_("rating based on reviews at iDreamBooks.com")+"</a></span>");
-
-                    //insert data into Book reviews tab
-                    $.each(json.book.critic_reviews, function(){
-                            $("#idb_review_snippets").append("<div class='review'><div><a href='"+this.review_link+"'>"+this.source+"</a></div><div>\"..."+this.snippet+"...\"</div><div>"+_("Review date: ")+this.review_date+"</div><div><a class='reviewlink' href='"+json.book.detail_link+"'>"+_("Review result: ")+this.pos_or_neg+" <img src='"+this.smiley_or_sad_small+"' alt='"+_("iDreamBooks.com rating")+"' title='"+this.pos_or_neg+"' /></a></div></div>");
-                            });
-                    $("#seemoreidb").attr('href', json.book.detail_link);
-                    $("#tab_idb_critic_reviews").show();
-                [% END %]
-            }
-        }
-    [% END # / IF IDreamBooksReviews || IDreamBooksReadometer %]
 
         $(document).ready(function() {
             if( OPACPopupAuthorsSearch == "1" ){
index a9bf805..86baa9f 100644 (file)
                                                         [% END %]
                                                     [% END %]
 
-
-                                                    [% IF ( IDreamBooksResults && SEARCH_RESULT.normalized_isbn ) %]
-                                                        <div class="idbresult" style="display: none;">
-                                                            [% IF ( IDreamBooksReviews ) %]
-                                                                <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]#idb_critic_reviews">
-                                                            [% ELSE %]
-                                                                <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]">
-                                                            [% END %]
-                                                            [% SEARCH_RESULT.normalized_isbn | html %]</a>
-                                                        </div>
-                                                    [% END %]
                                                 </div>
                                                 [% IF ( COinSinOPACResults && SEARCH_RESULT.coins ) %]
                                                     <!-- COinS / Openurl -->
@@ -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("<img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+_(" by ")+json.book.author+"' title='"+_("Rating based on reviews of ")+json.book.title+"'>"+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("<img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+_(" by ")+json.book.author+"' title='"+_("Rating based on reviews of ")+json.book.title+"'>"+json.book.rating+"%");
-                        $(element).show();
-                    } else {
-                        $(element).remove();
-                    }
-                });
-            }
-        });
-    [% END %]
-
     var param1 = "";
     [% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) || loggedinusername ) %]
     param1 += "<span id=\"selections\">"+_("Select titles to: ")+"</span>";
index e58cf8b..f110087 100755 (executable)
@@ -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')) {
index a3a766a..01887f2 100755 (executable)
@@ -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);
index 6b8db7e..9241b27 100644 (file)
@@ -468,9 +468,6 @@ sub mocking_systempreferences_to_a_set_value {
         BakerTaylorEnabled
         GoogleJackets
         HTML5MediaEnabled
-        IDreamBooksReadometer
-        IDreamBooksResults
-        IDreamBooksReviews
         LibraryThingForLibrariesEnabled
         LocalCoverImages
         OPACLocalCoverImages