From d7f5ecb98ce6b4a190c4a07c7027ecdf55e02b3a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 10 May 2021 15:30:51 +0000 Subject: [PATCH] Bug 28307: Make BakerTaylorEnabled preference separate for staff and OPAC This patch updates the system preferences controlling Baker & Taylor content so that there are separate preferences for the OPAC and the staff interface. The patch also adds Baker & Taylor cover images to the staff client. To test, apply the patch and run the database update. - Go to Admnistration -> System preferences -> Enhanced content - You should see a BakerTaylorEnabled and a OPACBakerTaylorEnabled preference. The OPACBakerTaylorEnabled should have the same setting you previously had for BakerTaylorEnabled. The BakerTaylorEnabled preference should be turned off. - Note that the description of the preferences have been updated to include links to the Baker & Taylor username and password preferences. - Enable both and make sure you have a valid Baker & Taylor username and password entered. - Perform a search in both the OPAC and staff interface. A Baker & Taylor cover image should appear on the bibliographic detail page in the OPAC, and on the search results and bibliographic detail page in the staff interface. Signed-off-by: Lucas Gass --- catalogue/detail.pl | 22 +++++++++++++++++++ .../bug-28307-BakerTaylorEnabled-staff.perl | 9 ++++++++ .../admin/preferences/enhanced_content.pref | 12 +++++++--- .../prog/en/modules/catalogue/detail.tt | 20 +++++++++++++++++ .../prog/en/modules/catalogue/results.tt | 17 ++++++++++++++ .../bootstrap/en/modules/opac-detail.tt | 19 +++++++++------- opac/opac-detail.pl | 4 ++-- 7 files changed, 90 insertions(+), 13 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug-28307-BakerTaylorEnabled-staff.perl diff --git a/catalogue/detail.pl b/catalogue/detail.pl index b5801cca71..da1e9eb925 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -39,6 +39,7 @@ use C4::Reserves; use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); use C4::XISBN qw( get_xisbns ); use C4::External::Amazon qw( get_amazon_tld ); +use C4::External::BakerTaylor qw( image_url link_url ); use C4::Search qw( z3950_search_args enabled_staff_search_views ); use C4::Tags qw( get_tags ); use C4::XSLT qw( XSLTParse4Display ); @@ -502,6 +503,27 @@ foreach ( keys %{$dat} ) { # does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews'); # method query not found?!?! $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages")); + +if (C4::Context->preference("BakerTaylorEnabled")) { + $template->param( + BakerTaylorEnabled => 1, + BakerTaylorImageURL => &image_url(), + BakerTaylorLinkURL => &link_url(), + BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'), + ); + my ($bt_user, $bt_pass); + if ($isbn and + $bt_user = C4::Context->preference('BakerTaylorUsername') and + $bt_pass = C4::Context->preference('BakerTaylorPassword') ) + { + $template->param( + BakerTaylorContentURL => + sprintf("https://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y", + $bt_user,$bt_pass,$isbn) + ); + } +} + $template->param( itemloop => \@itemloop, otheritemloop => \@otheritemloop, diff --git a/installer/data/mysql/atomicupdate/bug-28307-BakerTaylorEnabled-staff.perl b/installer/data/mysql/atomicupdate/bug-28307-BakerTaylorEnabled-staff.perl new file mode 100644 index 0000000000..5fc7869e30 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-28307-BakerTaylorEnabled-staff.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + $dbh->do("UPDATE systempreferences SET `variable` = 'OPACBakerTaylorEnabled', `explanation` = 'Enable or disable all Baker & Taylor features in the OPAC' WHERE `variable` = 'BakerTaylorEnabled'"); + $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, options, type) VALUES ( 'BakerTaylorEnabled', '0', 'Enable or disable all Baker & Taylor features in the staff interface', NULL, 'YesNo' )"); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 28307, "Bug 28307: Make BakerTaylorEnabled preference separate for staff and OPAC"); +} 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 2e25114a35..4428369b2f 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 @@ -80,20 +80,26 @@ Enhanced content: - pref: Babeltheque_url_update class: url - (e.g. http://www.babeltheque.com/.../file.csv.bz2). - Baker and Taylor: + Baker & Taylor: - - pref: BakerTaylorEnabled choices: 1: Add 0: "Don't add" - - Baker and Taylor links and cover images to the OPAC and staff interface. This requires that you have entered in a username and password (which can be seen in image links). + - Baker & Taylor links and cover images to the staff interface. This requires that you have entered your BakerTaylorUsername and BakerTaylorPassword (which will be publicly visible in image links). + - + - pref: OPACBakerTaylorEnabled + choices: + 1: Add + 0: "Don't add" + - Baker & Taylor links and cover images to the OPAC. This requires that you have entered your BakerTaylorUsername and BakerTaylorPassword (which will be publicly visible in image links). - - 'Baker and Taylor "My Library Bookstore" links should be accessed at https://' - pref: BakerTaylorBookstoreURL class: url - isbn (this should be filled in with something like ocls.mylibrarybookstore.com/MLB/actions/searchHandler.do?nextPage=bookDetails&parentNum=10923&key=). Leave it blank to disable these links. - - - Access Baker and Taylor using username + - Access Baker & Taylor using username - pref: BakerTaylorUsername class: password - and password diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 7c2b961d6c..11b21da5da 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -241,6 +241,23 @@ [% END %] + [% bt_id = ( normalized_upc || normalized_isbn ) %] + [% IF ( Koha.Preference('BakerTaylorEnabled') && bt_id ) %] + [% SET BakerTaylorImageURL = "https://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=${ Koha.Preference('BakerTaylorUsername') }&Password=${ Koha.Preference('BakerTaylorPassword') }&Options=Y&Return=T&Type=S&Value=$bt_id" %] +
+ [% IF BakerTaylorBookstoreURL %] + + See Baker & Taylor + + [% ELSE %] + + See Baker & Taylor + + [% END %] +
Image from Baker & Taylor
+
+ [% END %] + [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %] [% SET custom_cover_image_url = biblio.custom_cover_image_url %] [% IF custom_cover_image_url %] @@ -1080,6 +1097,9 @@ Note that permanent location is a code, and location may be an authval. lightbox_descriptions.push(coce_description); } else if ( div.attr("id") == "adlibris-coverimg" ){ lightbox_descriptions.push(_("Image from Adlibris (see the original image)").format($(img).data('link'))); + + } else if ( div.attr("id") == "bakertaylor-coverimg" ){ + lightbox_descriptions.push(_("Image from Baker & Taylor")); } else if ( div.attr("class") == "cover-image local-coverimg" ) { lightbox_descriptions.push(_("Local cover image (edit)").format($(img).data('link'))); } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 4764f4f409..636360a4e0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -475,6 +475,23 @@ [% END %] [% END %] + [% bt_id = ( SEARCH_RESULT.normalized_upc || SEARCH_RESULT.normalized_isbn ) %] + [% IF ( Koha.Preference('BakerTaylorEnabled') && bt_id ) %] + [% SET BakerTaylorImageURL = "https://contentcafe2.btol.com/ContentCafe/Jacket.aspx?UserID=${ Koha.Preference('BakerTaylorUsername') }&Password=${ Koha.Preference('BakerTaylorPassword') }&Options=Y&Return=T&Type=S&Value=$bt_id" %] +
+ [% IF BakerTaylorBookstoreURL %] + + See Baker & Taylor + + [% ELSE %] + + See Baker & Taylor + + [% END %] +
Image from Baker & Taylor
+
+ [% END %] + [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %] [% SET custom_cover_image_url = SEARCH_RESULT.biblio_object.custom_cover_image_url %] [% IF custom_cover_image_url %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index fe2b35da26..cf11e81480 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -101,16 +101,19 @@
[% END %] [% bt_id = ( normalized_upc || normalized_isbn ) %] - [% IF ( BakerTaylorEnabled && bt_id ) %] - [% IF BakerTaylorBookstoreURL %] - [% IF ( OPACURLOpenInNewWindow ) %] - See Baker & Taylor + [% IF ( OPACBakerTaylorEnabled && bt_id ) %] +
+ [% IF BakerTaylorBookstoreURL %] + + See Baker & Taylor + [% ELSE %] - See Baker & Taylor + + See Baker & Taylor + [% END %] - [% ELSE %] - See Baker & Taylor - [% END %] +
Image from Baker & Taylor
+
[% END %] [% IF Koha.Preference('OPACCustomCoverImages') AND Koha.Preference('CustomCoverImagesURL') %] [% SET custom_cover_image_url = biblio.custom_cover_image_url %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 0860aa487a..3b60464f7b 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1116,9 +1116,9 @@ if (C4::Context->preference("OPACShelfBrowser")) { $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("OPACAmazonCoverImages")); -if (C4::Context->preference("BakerTaylorEnabled")) { +if (C4::Context->preference("OPACBakerTaylorEnabled")) { $template->param( - BakerTaylorEnabled => 1, + OPACBakerTaylorEnabled => 1, BakerTaylorImageURL => &image_url(), BakerTaylorLinkURL => &link_url(), BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'), -- 2.20.1