From e2e25d59bb48835176802127da7179d2bf3ba144 Mon Sep 17 00:00:00 2001 From: Charles Farmer Date: Mon, 19 Feb 2018 23:32:25 -0500 Subject: [PATCH] Bug18421 - Add Coce to the staff intranet TEST PLAN: 1) Apply the patch with git-bz 2) Run updatedatabase.pl 2.1) Console output should confirm database modification 3) Visit the 'Enhanced Content' tab of admin/syspref 3.1) ressource is /cgi-bin/koha/admin/preferences.pl?tab=enhanced_content 3.2) You should see that the previous preference, Coce, is now CoceOPAC, and that a new preference was added, CoceIntranet 4) Activate CoceIntranet 5) Do a search for a book for which you have a Coce cover 5.1) The cover image url should now point to a provider you defined in Coce 5.2) Your Coce log should show a query 6) Click on the book's name to visit the detail.pl page 6.1) The book's cover should also be provided by Coce on that page Signed-off-by: Brendan Gallagher --- C4/Auth.pm | 3 ++ .../atomicupdate/bug_18421_add_coce_intranet.perl | 30 +++++++++++++++ installer/data/mysql/sysprefs.sql | 3 +- .../admin/preferences/enhanced_content.pref | 10 ++++- .../prog/en/modules/catalogue/detail.tt | 31 ++++++++++++++-- .../prog/en/modules/catalogue/results.tt | 20 +++++++++- koha-tmpl/intranet-tmpl/prog/js/coce.js | 43 ++++++++++++++++++++++ .../bootstrap/en/includes/opac-bottom.inc | 2 +- .../bootstrap/en/includes/shelfbrowser.inc | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 8 ++-- .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 4 +- 11 files changed, 140 insertions(+), 16 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl create mode 100644 koha-tmpl/intranet-tmpl/prog/js/coce.js diff --git a/C4/Auth.pm b/C4/Auth.pm index c3ad351..79a2633 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -473,6 +473,9 @@ sub get_template_and_user { UseCourseReserves => C4::Context->preference("UseCourseReserves"), useDischarge => C4::Context->preference('useDischarge'), KOHA_VERSION => C4::Context->preference('Version'), + CoceIntranet => C4::Context->preference('CoceIntranet'), + CoceProviders => C4::Context->preference('CoceProviders'), + CoceHost => C4::Context->preference('CoceHost'), ); } else { diff --git a/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl b/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl new file mode 100755 index 0000000..74aef50 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl @@ -0,0 +1,30 @@ +#! /usr/bin/perl + +use strict; +use warnings; +use C4::Context; +use Data::Dumper; +my $dbh=C4::Context->dbh; + +################# +# Coce intranet # +################# + +# validate systempreferences.Coce and save the config for CoceOpac +my $select = "SELECT * FROM systempreferences WHERE variable = 'Coce'"; +my $sth = $dbh->prepare($select); +$sth->execute; +my $rows = $sth->fetchall_hashref(['variable']); +my $current_coce_pref = 0; +if ($rows and $rows->{Coce} and $rows->{Coce}->{value}) { + $current_coce_pref = $rows->{Coce}->{value}; +} + +# add two new systempreferences in order to have distinct behavior between intranet and OPAC +$dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES + ('CoceIntranet','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff intranet', 'YesNo'), + ('CoceOPAC','$current_coce_pref', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo') + ;") or die "Impossible d\'executer cam5446_ajouter_coce_intranet: erreur lors de l'ajout des nouvelles prefs: ". $dbh->errstr . "\n"; +$dbh->do("DELETE FROM systempreferences WHERE variable = 'Coce';") + or die "Impossible d\'executer cam5446_ajouter_coce_intranet: erreur lors de la suppression de la préférence 'Coce': ". $dbh->errstr . "\n"; +print "cam5446: Add Coce image cache to the staff intranet.\n"; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 76bb2cc..0130059 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -109,7 +109,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'), ('CircSidebar','0',NULL,'Activate or deactivate the navigation sidebar on all Circulation pages','YesNo'), ('ClaimsBccCopy','0','','Bcc the ClaimAcquisition and ClaimIssues alerts','YesNo'), -('Coce','0', NULL, 'If on, enables cover retrieval from the configured Coce server', 'YesNo'), +('CoceIntranet','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff intranet', 'YesNo'), +('CoceOPAC','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo'), ('CoceHost', '', NULL, 'Coce server URL', 'Free'), ('CoceProviders', '', 'aws,gb,ol', 'Coce providers', 'multiple'), ('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','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 f62882d..be314f7 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 @@ -374,11 +374,17 @@ Enhanced Content: - with OverDrive. Coce Cover images cache: - - - pref: Coce + - pref: CoceOPAC choices: yes: Enable no: "Don't enable" - - a Coce image cache service. + - a Coce image cache service in the OPAC. + - + - pref: CoceIntranet + choices: + yes: Enable + no: "Don't enable" + - a Coce image cache service in the staff intranet. - - Coce server URL - pref: CoceHost 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 3640a9c..5c824fe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -64,7 +64,7 @@ [% END %] - [% IF ( AmazonCoverImages || LocalCoverImages ) %] + [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] [% IF ( XSLTDetailsDisplay ) %]
@@ -125,7 +125,7 @@ [% END %] - [% IF ( AmazonCoverImages || LocalCoverImages ) %] + [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %]
[% IF ( LocalCoverImages ) %]
@@ -136,6 +136,16 @@
[% END %] + [% IF ( CoceIntranet && CoceProviders ) %] + [% coce_id = normalized_ean || normalized_isbn %] + + [% IF ( coce_id ) %] + + [% ELSE %] + No cover image available + [% END %] + + [% END %] [% END %] [% ELSE %] @@ -199,7 +209,7 @@
- [% IF ( AmazonCoverImages || LocalCoverImages ) %] + [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %]
[% IF ( LocalCoverImages ) %]
@@ -211,6 +221,16 @@
[% END %] + [% IF ( CoceIntranet && CoceProviders ) %] + [% coce_id = normalized_ean || normalized_isbn %] + + [% IF ( coce_id ) %] + + [% ELSE %] + No cover image available + [% END %] + + [% END %] [% END %] @@ -840,6 +860,7 @@ [% INCLUDE 'catalog-strings.inc' %] [% INCLUDE 'greybox.inc' %] + + [% END %] -[% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] +[% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %]