Bugzilla – Attachment 169594 Details for
Bug 37221
No way to turn off OverDrive integrations without removing all system preference values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37221: Add preference to turn off OPAC Overdrive features
Bug-37221-Add-preference-to-turn-off-OPAC-Overdriv.patch (text/plain), 11.88 KB, created by
ByWater Sandboxes
on 2024-07-25 16:21:31 UTC
(
hide
)
Description:
Bug 37221: Add preference to turn off OPAC Overdrive features
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2024-07-25 16:21:31 UTC
Size:
11.88 KB
patch
obsolete
>From f84a968a3c2efbefad5be4fee121db5d77b44969 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 10 Jul 2024 16:19:45 +0000 >Subject: [PATCH] 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: Barbara Johnson <barbara.johnson@bedfordtx.gov> >--- > .../data/mysql/atomicupdate/bug_37221.pl | 31 +++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../admin/preferences/enhanced_content.pref | 6 +++ > .../bootstrap/en/modules/opac-results.tt | 7 +-- > .../bootstrap/en/modules/opac-user.tt | 43 ++++++++++--------- > opac/opac-overdrive-search.pl | 6 +++ > opac/opac-user.pl | 1 - > 7 files changed, 68 insertions(+), 27 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_37221.pl > >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 1a7cd033e9..bed161fd8b 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -582,6 +582,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OverDriveCirculation','0','','Enable client to see their OverDrive account','YesNo'), > ('OverDriveClientKey','',NULL,'Client key for OverDrive integration','Free'), > ('OverDriveClientSecret','',NULL,'Client key for OverDrive integration','Free'), >+('OPACOverDrive','0',NULL,'Enable OverDrive integration in the OPAC','YesNo'), > ('OverDriveLibraryID','', NULL,'Library ID for OverDrive integration','Integer'), > ('OverDrivePasswordRequired','0','','Does the library require passwords for OverDrive SIP authentication','YesNo'), > ('OverDriveUsername','cardnumber','cardnumber|userid','Which patron information should be passed as OverDrive username','Choice'), >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 c92819eebf..a29cb4914c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -14,10 +14,7 @@ > [% SET RecallsEnabled = ( Koha.Preference('UseRecalls') == 1 ) && LoginEnabled %] > [% SET ArticleRequestsEnabled = ( Koha.Preference('ArticleRequests') == 1 ) && LoginEnabled %] > [% SET MultiHolds = ( Koha.Preference('DisplayMultiPlaceHold') == 1 ) && HoldsEnabled %] >- >-[% IF firstPage %] >- [% 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> >@@ -575,7 +572,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 a5d392d0ce..721f8ecd39 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</title> >@@ -1463,27 +1464,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 %] >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 a1b8b9f910..421a74f3c8 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -358,7 +358,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, > ); >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37221
:
168760
|
169594
|
173979
|
174036