Bug 37221: Add preference to turn off OPAC Overdrive features
This patch adds the preference "OPACOverDrive" to control whether
OverDrive features are shown in the OPAC. This allows a library to
disable OverDrive features without having to remove one or more of their
OverDrive credentials.
The patch also adds a check for the OPACOverDrive preference in the
OverDrive search results page. If OverDrive is disabled, navigating to
that page should give a 404.
To test you will need OverDrive credentials to test with.
- Apply the patch and run updatedatabase.
- If you already had data in the OverDriveLibraryID,
OverDriveClientKey, and OverDriveClientSecret system preferences,
the OPACOverDrive preference will be enabled when added. If not it
will be disabled by default.
- Rebuild the staff interface CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_interface)
- Go to Administration -> System preferences -> Enhanced content ->
OverDrive.
- If necessary, enter valid credentials in the OverDriveLibraryID,
OverDriveClientKey, and OverDriveClientSecret system preferences.
- Set OPACOverDrive to "Don't enable."
- In the OPAC perform a catalog search. Normally, if your credentials
were correct OverDrive search results would automatically appear at
the top of Koha's search results. Now there should be none.
- Enable the OPACOverDrive preference and repeat your search. Now
OverDrive results should appear.
- Confirm that the OverDrive search results page works correctly.
- Test that OverDrive circulation features are working by logging in to
the OPAC as a user who has active OverDrive checkouts.
- Enable the OPACOverDrive and OverDriveCirculation system preferences.
- On the user's summary page there should be a tab for "OverDrive
account."
- The tab should not appear if either OPACOverDrive or
OverDriveCirculation is disabled.
Sponsored-by: Athens County Public Libraries
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
8e73930408
commit
dac0095f1d
|
|
@ -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'" );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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' %]
|
||||
<title>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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</title>
|
||||
|
|
@ -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 %]
|
||||
<script>
|
||||
[%- IF Koha.Preference('OverDrivePasswordRequired') -%]
|
||||
var OD_password_required = 1;
|
||||
[%- ELSE -%]
|
||||
var OD_password_required = 0;
|
||||
[%- END -%]
|
||||
$(document).ready(function() {
|
||||
[% IF ( overdrive_error ) %]
|
||||
KOHA.OverDriveCirculation.display_error("#opac-user-overdrive_panel", "[% overdrive_error.dquote | html %]");
|
||||
[% END %]
|
||||
[% IF OverDriveCirculation %]
|
||||
[% Asset.js("js/overdrive.js") | $raw %]
|
||||
<script>
|
||||
[%- IF Koha.Preference('OverDrivePasswordRequired') -%]
|
||||
var OD_password_required = 1;
|
||||
[%- ELSE -%]
|
||||
var OD_password_required = 0;
|
||||
[%- END -%]
|
||||
$(document).ready(function() {
|
||||
[% IF ( overdrive_error ) %]
|
||||
KOHA.OverDriveCirculation.display_error("#opac-user-overdrive_panel", "[% overdrive_error.dquote | html %]");
|
||||
[% END %]
|
||||
|
||||
[% IF ( overdrive_tab ) %]
|
||||
$("#opac-user-views a[href='#opac-user-overdrive_panel']").tab("show");
|
||||
[% END %]
|
||||
[% IF ( overdrive_tab ) %]
|
||||
$("#opac-user-views a[href='#opac-user-overdrive_panel']").tab("show");
|
||||
[% END %]
|
||||
|
||||
$("#opac-user-overdrive_panel").each( function() {
|
||||
KOHA.OverDriveCirculation.display_account_details(this);
|
||||
} );
|
||||
});
|
||||
</script>
|
||||
$("#opac-user-overdrive_panel").each( function() {
|
||||
KOHA.OverDriveCirculation.display_account_details(this);
|
||||
} );
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue