@@ -, +, @@ 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 --- C4/Auth.pm | 6 ++- .../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, 142 insertions(+), 17 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 --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -501,7 +501,11 @@ sub get_template_and_user { EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), UseKohaPlugins => C4::Context->preference('UseKohaPlugins'), UseCourseReserves => C4::Context->preference("UseCourseReserves"), - useDischarge => C4::Context->preference('useDischarge') + 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 { --- a/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl +++ a/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"; --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -108,7 +108,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'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref +++ a/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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ a/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 %] @@ -848,6 +868,7 @@ [% INCLUDE 'catalog-strings.inc' %] [% INCLUDE 'greybox.inc' %] + + [% END %] -[% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] +[% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %]