Bug 13736 - Enable EDS Plugin Patch
Summary: Enable EDS Plugin Patch
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Alvet
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-20 04:32 UTC by Alvet
Modified: 2020-11-30 21:45 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
EDS Plugin Patch (2.24 KB, patch)
2015-02-20 04:45 UTC, Alvet
Details | Diff | Splinter Review
EDS Plugin Patches Code checks to see if setting EDSEnabled is ON and integrates the EDS Plugin to the Opac (5.26 KB, patch)
2015-09-26 14:43 UTC, Alvet
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alvet 2015-02-20 04:32:30 UTC
The EDS plugin requires 2 files to be patched.

OPEN doc-dead-close.inc in \opac\htdocs\opac-tmpl\<themelang>\includes and add the below line to the end of the file. 
[% IF ( EDSEnabled ) %]<script type="text/javascript" language="javascript" src="/plugin/Koha/Plugin/EDS/js/EDSScript.js"></script>[% END %] 


OPEN Auth.pm in \lib\C4 and add the below line after CalendarFirstDayOfWeek => at approx. line 397
EDSEnabled                   => C4::Context->preference("EDSEnabled"),
Comment 1 Alvet 2015-02-20 04:45:15 UTC Comment hidden (obsolete)
Comment 2 Alvet 2015-09-26 14:43:08 UTC
Created attachment 42894 [details] [review]
EDS Plugin Patches Code checks to see if  setting EDSEnabled is ON and integrates the EDS Plugin to the Opac

From 5851a06cc13c93f40c2d58613e16aa4bf2c2e1b7 Mon Sep 17 00:00:00 2001
From: Alvet <contact@alvet.com.au>
Date: Sun, 27 Sep 2015 00:01:57 +1000
Subject: [PATCH] BUG 13736 [ENH] EDS Plugin Patches Code checks to see if
 setting EDSEnabled is ON and integrates the EDS Plugin to the Opac Auth.pm
 makes EDSEnabled accessible to the Opac doc-head-close.inc adds EDSScript.js
 to the opac opac-downloadcart.pl; contains code to add EDS records to the
 download list opac-sendbasket.pl; contains code to add EDS records to the
 email message

Test Plan
- Without Plugin
1) Apply the patch
2) Use Koha as normal.
- With Plugin (optional test)
1) Apply the patch
2) Install the EDS Koha Plugin
3) A Discovery Dropdown appears in the search dropdown to search subscription resources
-Updating the EDS plugin.(optional test)
1) Visit https://github.com/ebsco/edsapi-koha-plugin
2) Download the .kpz file
3) Upload file using Koha's plugin manager
---
 C4/Auth.pm                                                |  1 +
 .../opac-tmpl/bootstrap/en/includes/doc-head-close.inc    |  1 +
 opac/opac-downloadcart.pl                                 | 15 +++++++++++++++
 opac/opac-sendbasket.pl                                   | 15 +++++++++++++++
 4 files changed, 32 insertions(+)

diff --git a/C4/Auth.pm b/C4/Auth.pm
index ef0c585..266c29a 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -471,6 +471,7 @@ sub get_template_and_user {
             AuthorisedValueImages                 => C4::Context->preference("AuthorisedValueImages"),
             BranchesLoop                          => GetBranchesLoop($opac_name),
             BranchCategoriesLoop                  => GetBranchCategories( 'searchdomain', 1, $opac_name ),
+	    EDSEnabled                            => C4::Context->preference("EDSEnabled"),
             LibraryName                           => "" . C4::Context->preference("LibraryName"),
             LibraryNameTitle                      => "" . $LibraryNameTitle,
             LoginBranchname                       => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "",
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc
index bce0da2..e8b819c 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc
@@ -48,3 +48,4 @@
     function _(s) { return s } // dummy function for gettext
 </script>
 <script type="text/javascript" src="[% interface %]/[% theme %]/lib/modernizr.min.js"></script>
+[% IF ( EDSEnabled ) %]<script type="text/javascript" language="javascript" src="/plugin/Koha/Plugin/EDS/js/EDSScript.js"></script>[% END %]
diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl
index f14eb9e..10d1fcd 100755
--- a/opac/opac-downloadcart.pl
+++ b/opac/opac-downloadcart.pl
@@ -34,6 +34,14 @@ use C4::Csv;
 use utf8;
 my $query = new CGI;
 
+my $eds_data = "";
+if ( ( eval { C4::Context->preference('EDSEnabled') } ) ) {
+    my $PluginDir = C4::Context->config("pluginsdir");
+    $PluginDir = $PluginDir . '/Koha/Plugin/EDS';
+    require $PluginDir . '/opac/eds-methods.pl';
+    $eds_data = $query->param('eds_data');
+}
+
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
     {
         template_name   => "opac-downloadcart.tt",
@@ -66,6 +74,13 @@ if ($bib_list && $format) {
         foreach my $biblio (@bibs) {
 
             my $record = GetMarcBiblio($biblio, 1);
+            if ( ( eval { C4::Context->preference('EDSEnabled') } ) ) {
+                my $dat = "";
+                if ( $biblio =~ m/\|/ ) {
+                    ( $record, $dat ) =
+                      ProcessEDSCartItems( $biblio, $eds_data, $record, $dat );
+                }
+            }
             next unless $record;
 
             if ($format eq 'iso2709') {
diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl
index 6b2d62f..7f7d616 100755
--- a/opac/opac-sendbasket.pl
+++ b/opac/opac-sendbasket.pl
@@ -36,6 +36,13 @@ use C4::Members;
 use Koha::Email;
 
 my $query = new CGI;
+my $eds_data = "";
+if ( ( eval { C4::Context->preference('EDSEnabled') } ) ) {
+    my $PluginDir = C4::Context->config("pluginsdir");
+    $PluginDir = $PluginDir . '/Koha/Plugin/EDS';
+    require $PluginDir . '/opac/eds-methods.pl';
+    $eds_data = $query->param('eds_data');
+}
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
     {
@@ -86,6 +93,11 @@ if ( $email_add ) {
         my $dat              = GetBiblioData($biblionumber);
         next unless $dat;
         my $record           = GetMarcBiblio($biblionumber, 1);
+	if((eval{C4::Context->preference('EDSEnabled')})){
+		if($biblionumber =~m/\|/){
+			($record,$dat)= ProcessEDSCartItems($biblionumber,$eds_data,$record,$dat);
+		}
+	}
         my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
         my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
         my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
@@ -122,6 +134,9 @@ if ( $email_add ) {
     # Getting template result
     my $template_res = $template2->output();
     my $body;
+	if((eval{C4::Context->preference('EDSEnabled')})){
+		$template_res = CartSendLinks($template_res,@bibs);
+	}
 
     # Analysing information and getting mail properties
 
-- 
1.9.1
Comment 3 Owen Leonard 2016-06-21 15:40:15 UTC
Is this patch ready for testing? If so, please set the status to 'Needs signoff.'

If this patch has been written specifically for 3.18.x, can you please update it for master? 3.18.x is no longer maintained.
Comment 4 Katrin Fischer 2016-08-14 16:45:05 UTC
I feel like there is a bit of a mismatch between EDS-specific system preferences in the templats and having it as a plugin in the first place. Could those change be generalized in some way? For example we could enable plugins to add specific JavaScript to the files maybe.

Patch doesn't apply to master - I am moving this to master and "Patch doesn't apply" for the moment. The installation instructions still include:
'Click on Run Tool and follow instructions to patch core Koha files.'
Comment 5 Mark Tompsett 2016-08-17 14:36:58 UTC
Comment on attachment 42894 [details] [review]
EDS Plugin Patches Code checks to see if  setting EDSEnabled is ON and integrates the EDS Plugin to the Opac

Review of attachment 42894 [details] [review]:
-----------------------------------------------------------------

I'm pretty sure something jquery/ajax-y could be written to get the plugin to accomplish the same thing. I too, like Katrin in comment #4, have some misgivings about this implementation.

::: C4/Auth.pm
@@ +471,4 @@
>              AuthorisedValueImages                 => C4::Context->preference("AuthorisedValueImages"),
>              BranchesLoop                          => GetBranchesLoop($opac_name),
>              BranchCategoriesLoop                  => GetBranchCategories( 'searchdomain', 1, $opac_name ),
> +	    EDSEnabled                            => C4::Context->preference("EDSEnabled"),

Never needed.
Access [% Koha.Preference('EDSEnabled') %] in template files.

::: koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc
@@ +48,4 @@
>      function _(s) { return s } // dummy function for gettext
>  </script>
>  <script type="text/javascript" src="[% interface %]/[% theme %]/lib/modernizr.min.js"></script>
> +[% IF ( EDSEnabled ) %]<script type="text/javascript" language="javascript" src="/plugin/Koha/Plugin/EDS/js/EDSScript.js"></script>[% END %]

Including a plugin javascript link should be possible in the OPACUserJS system preference. Make sure to carefully add/remove as needed!
Comment 6 Fridolin Somers 2019-12-18 08:48:36 UTC
> The EDS plugin requires 2 files to be patched.
Actual version of EDS plugin 17.11 no longer requires those patches