diff --git a/installer/data/mysql/atomicupdate/bug_37221.pl b/installer/data/mysql/atomicupdate/bug_37221.pl new file mode 100755 index 0000000000..37bd4a49bd --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37221.pl @@ -0,0 +1,31 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "37221", + description => "Add new system preference OPACOverDrive", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my $count_sql = + q{SELECT count( value ) AS count FROM systempreferences WHERE variable IN ('OverDriveLibraryID', 'OverDriveClientKey', 'OverDriveClientSecret') AND value IS NOT NULL AND value != ''}; + my ($count) = $dbh->selectrow_array($count_sql); + my $enabled = + $count == 3 ? 1 : 0; # If all 3 preferences are enabled OverDrive content has been previously enabled + + my $sth = $dbh->prepare( + q{ + INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) + VALUES ('OPACOverDrive', ?, 'Enable OverDrive integration in the OPAC', '', 'YesNo') + } + ); + $sth->execute($enabled); + + if ($enabled) { + say_success( $out, "Added and enabled new system preference 'OPACOverDrive'" ); + } else { + say_success( $out, "Added new system preference 'OPACOverDrive'" ); + } + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 34ada9d837..7f5aad3553 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -526,6 +526,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACnumSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'), ('OPACnumSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in OPAC search results','YesNo'), ('OPACOpenURLItemTypes', '', NULL, 'Show the OpenURL link only for these item types', 'Free'), +('OPACOverDrive','0',NULL,'Enable OverDrive integration in the OPAC','YesNo'), ('OpacPasswordChange','1',NULL,'If ON, enables patron-initiated password change in OPAC (disable it when using LDAP auth)','YesNo'), ('OPACPatronDetails','1','','If OFF the patron details tab in the OPAC is disabled.','YesNo'), ('OPACpatronimages','0',NULL,'Enable patron images in the OPAC','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 e463f1657c..d9cde00fbe 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 @@ -339,6 +339,12 @@ Enhanced content: 0: "Don't embed" - YouTube links as videos. OverDrive: + - + - pref: OPACOverDrive + choices: + 1: Enable + 0: "Don't enable" + - "OverDrive integration in the OPAC" - - Include OverDrive availability information with the client key - pref: OverDriveClientKey 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 46bc94ff14..a7f87af6d3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -29,6 +29,7 @@ [% SET OPACCustomCoverImages = ( Koha.Preference('OPACCustomCoverImages') && Koha.Preference('CustomCoverImagesURL') ) %] [% SET OverDriveEnabled = Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') %] [% END %] +[% SET OverDriveEnabled = ( Koha.Preference( "OPACOverDrive" ) && Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') ) %] [% INCLUDE 'doc-head-open.inc' %] @@ -674,7 +675,7 @@ highlightOff(); }); [% END # /IF OpacHighlightedWords %] - [% IF ( OverDriveEnabled ) %] + [% IF ( OverDriveEnabled && firstPage ) %] var $overdrive_results = $( '<div id="overdrive-results">' + _("Searching %s...").format('OverDrive') + ' <img class="throbber" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" /></div>' ); $( '#numresults' ) .after( $overdrive_results ); //Clean querystring, first we remove CCL entities, then decode HTML entities, then swap double quotes for single quotes 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 b6780c18f5..fbbd40d3fd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -10,9 +10,10 @@ [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacMySummaryNote = AdditionalContents.get( location => "OpacMySummaryNote", lang => lang, library => branchcode ) %] - [% SET borrower_club_enrollments = logged_in_user.get_club_enrollments %] [% SET borrower_enrollable_clubs = logged_in_user.get_enrollable_clubs(1) %] <!-- 1 => OPAC --> +[% SET OverDriveEnabled = ( Koha.Preference( "OPACOverDrive" ) && Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') ) %] +[% SET OverDriveCirculation = ( OverDriveEnabled && Koha.Preference( "OverDriveCirculation" ) ) %] [% INCLUDE 'doc-head-open.inc' %] <title>Your library home › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog @@ -1469,27 +1470,27 @@ [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] [% Asset.js("js/ratings.js") | $raw %] [% END %] - [% IF Koha.Preference('OverDriveCirculation') %] - [% Asset.js("js/overdrive.js") | $raw %] - + $("#opac-user-overdrive_panel").each( function() { + KOHA.OverDriveCirculation.display_account_details(this); + } ); + }); + [% END %] [% END %] diff --git a/opac/opac-overdrive-search.pl b/opac/opac-overdrive-search.pl index 923df46e98..a56d1530ea 100755 --- a/opac/opac-overdrive-search.pl +++ b/opac/opac-overdrive-search.pl @@ -27,6 +27,12 @@ use C4::Output qw( output_html_with_http_headers ); my $cgi = CGI->new; +# if OPACOverDrive is disabled, leave immediately +if ( !C4::Context->preference('OPACOverDrive') ) { + print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); + exit; +} + # Getting the template and auth my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 34e9334e54..3f1ca4ad59 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -364,7 +364,6 @@ if (C4::Context->preference("OPACAmazonCoverImages") or } $template->param( - OverDriveCirculation => C4::Context->preference('OverDriveCirculation') || 0, overdrive_error => scalar $query->param('overdrive_error') || undef, overdrive_tab => scalar $query->param('overdrive_tab') || 0, );