@@ -, +, @@
prefs)
---
C4/External/OverDrive.pm | 18 -------
.../bootstrap/en/includes/opac-bottom.inc | 5 +-
.../bootstrap/en/modules/opac-overdrive-search.tt | 2 +-
.../opac-tmpl/bootstrap/en/modules/opac-results.tt | 7 ++-
opac/opac-search.pl | 6 +--
opac/svc/overdrive_proxy | 2 +-
t/External/OverDrive.t | 55 ----------------------
7 files changed, 13 insertions(+), 82 deletions(-)
delete mode 100755 t/External/OverDrive.t
--- a/C4/External/OverDrive.pm
+++ a/C4/External/OverDrive.pm
@@ -32,7 +32,6 @@ BEGIN {
require Exporter;
our @ISA = qw( Exporter ) ;
our @EXPORT = qw(
- IsOverDriveEnabled
GetOverDriveToken
);
}
@@ -63,23 +62,6 @@ This module provides content search for OverDrive,
=over
-=item IsOverDriveEnabled
-
-Returns 1 if all of the necessary system preferences for OverDrive are set.
-
-=back
-
-=cut
-
-sub IsOverDriveEnabled {
- return (
- C4::Context->preference( 'OverDriveClientKey' ) &&
- C4::Context->preference( 'OverDriveClientSecret' )
- );
-}
-
-=over
-
=item GetOverDriveToken
Fetches an OAuth2 auth token for the OverDrive API, reusing an existing token in
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
@@ -1,4 +1,5 @@
[% USE raw %]
+[% USE Koha %]
[%- USE KohaPlugins -%]
[% USE Asset %]
[% UNLESS ( is_popup ) %]
@@ -274,8 +275,10 @@ $.widget.bridge('uitooltip', $.ui.tooltip);
[% END %]
-[% IF (RecordedBooksEnabled) %]
+[% IF Koha.Preference('RecordedBooksClientSecret') && Koha.Preference('RecordedBooksLibraryID') %]
+
[% END %]
[% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %]
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt
@@ -93,7 +93,7 @@ function fetch_availability( prod, $tr ) {
function search( offset ) {
$( '#overdrive-status' ).html( _("Searching OverDrive...") + ' ' );
- KOHA.OverDrive.Search( "[% OverDriveLibraryID | html %]", querystring, results_per_page, offset, function( data ) {
+ KOHA.OverDrive.Search( "[% Koha.Preference('OverDriveLibraryID') | html %]", querystring, results_per_page, offset, function( data ) {
if ( data.error ) {
$( '#overdrive-status' ).html( '' + _("Error searching OverDrive collection.") + '' );
return;
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
@@ -6,6 +6,11 @@
[% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %]
[% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %]
+[% IF firstPage %]
+ [% SET OverDriveEnabled = Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') %]
+ [% SET RecordedBooksEnabled = Koha.Preference('RecordedBooksLibraryID') && Koha.Preference('RecordedBooksClientSecret') %]
+[% END %]
+
[% INCLUDE 'doc-head-open.inc' %]
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog ›
[% IF ( searchdesc ) %]
@@ -923,7 +928,7 @@ $(document).ready(function(){
var $overdrive_results = $( '' + MSG_SEARCHING.format('OverDrive') + '
' );
$( '#numresults' ) .append( ' ' )
.append( $overdrive_results );
- KOHA.OverDrive.Search( "[% OverDriveLibraryID | html %]", querystring, 1, 0, function( data ) {
+ KOHA.OverDrive.Search( "[% Koha.Preference('OverDriveLibraryID') | html %]", querystring, 1, 0, function( data ) {
if ( data.error ) {
$overdrive_results.html( MSG_ERROR_SEARCHING_COLLECTION.format('OverDrive') );
return;
--- a/opac/opac-search.pl
+++ a/opac/opac-search.pl
@@ -1010,11 +1010,7 @@ $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBook
$template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults');
if ($offset == 0) {
- if (IsOverDriveEnabled()) {
- $template->param(OverDriveEnabled => 1);
- $template->param(OverDriveLibraryID => C4::Context->preference('OverDriveLibraryID'));
- }
- $template->param(RecordedBooksEnabled => C4::Context->preference( 'RecordedBooksClientSecret' ) && C4::Context->preference( 'RecordedBooksLibraryID' ));
+ $template->param(firstPage => 1);
}
$template->param( borrowernumber => $borrowernumber);
--- a/opac/svc/overdrive_proxy
+++ a/opac/svc/overdrive_proxy
@@ -47,7 +47,7 @@ my $query = new CGI;
my $token;
-if ( !IsOverDriveEnabled() || !( $token = GetOverDriveToken() ) ) {
+if ( !(C4::Context->preference('OverDriveClientKey') && C4::Context->preference('OverDriveClientSecret')) || !( $token = GetOverDriveToken() ) ) {
print $query->header(
-status => '400 Bad Request',
);
--- a/t/External/OverDrive.t
+++ a/t/External/OverDrive.t
@@ -1,55 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright 2015 BibLibre
-#
-# 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 C4::Context;
-use t::lib::Mocks qw(mock_preference);
-use Test::More tests => 6;
-
-BEGIN {
- use_ok('C4::External::OverDrive');
-}
-
-can_ok(
- 'C4::External::OverDrive', qw(
- _request
- IsOverDriveEnabled
- GetOverDriveToken )
-);
-
-# ---------- Testing IsOverDriveEnabled ---------
-
-t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 );
-t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 );
-
-is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
-
-t::lib::Mocks::mock_preference( "OverDriveClientKey", 0 );
-t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 );
-
-is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
-
-t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 );
-t::lib::Mocks::mock_preference( "OverDriveClientSecret", 0 );
-
-is( IsOverDriveEnabled(), 0, 'IsOverDriveEnabled fail' );
-
-t::lib::Mocks::mock_preference( "OverDriveClientKey", 1 );
-t::lib::Mocks::mock_preference( "OverDriveClientSecret", 1 );
-
-is( IsOverDriveEnabled(), 1, 'IsOverDriveEnabled success' );
--