Skip to content

Commit 7c716c2

Browse files
authored
Merge pull request #145 from ebsco/Update-to-2505
Update to 25.05
2 parents bb3e40c + c6e8b5a commit 7c716c2

8 files changed

Lines changed: 341 additions & 20 deletions

File tree

Koha/Plugin/EDS.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ my ($PluginDir) = grep { -f $_ . "/Koha/Plugin/EDS.pm" } @pluginsdir;
3030
$PluginDir = $PluginDir.'/Koha/Plugin/EDS';
3131

3232
################# DO NOT TOUCH - CONTROLLED BY build.py
33-
our $MAJOR_VERSION = "24.11";
34-
our $SUB_VERSION = "002";
33+
our $MAJOR_VERSION = "25.05";
34+
our $SUB_VERSION = "001";
3535
our $VERSION = $MAJOR_VERSION . "" . $SUB_VERSION;
3636
our $SHA_ADD = "https://widgets.ebscohost.com/prod/api/koha/sha/1711.json";
37-
our $DATE_UPDATE = '2025-05-13';
37+
our $DATE_UPDATE = '2025-08-13';
3838
######################################################
3939

4040
## Here is our metadata, some keys are required, some are optional
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- DO NOT TOUCH THIS FILE - controlled by build.py -->
33
<kohaplugin>
4-
<latestversion>24.11.002</latestversion>
4+
<latestversion>25.05.001</latestversion>
55
<download>https://github.com/ebsco/edsapi-koha-plugin</download>
6-
<lastupdated>2025/05/13</lastupdated>
6+
<lastupdated>2025/08/13</lastupdated>
77
<releasenotes>
8-
<release version="24.11.002" date="2025/05/13">
9-
<note id="1" author="omuzzy@ebsco.com">minor fixes for Koha 24.11</note>
10-
<note id="2" author="omuzzy@ebsco.com">fix for EDS Autocomplete functionality</note>
8+
<release version="25.05.001" date="2025/08/13">
9+
<note id="1" author="omuzzy@ebsco.com">Updating EDS API Koha plugin to support Koha 25.05</note>
1110
</release>
1211
</releasenotes>
1312
</kohaplugin>

Koha/Plugin/EDS/js/EDSScript.tt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ edsConfig.pluginhttppath = "[% PLUGIN_HTTP_PATH %]";
4141
var searchBlockCount = 3;
4242

4343
// DO NOT TOUCH - controlled by build.py
44-
var versionEDSKoha = "24.11002";
44+
var versionEDSKoha = "25.05001";
4545
///////////////////////////////////////
4646

4747
if (document.title == "") {
@@ -752,7 +752,7 @@ async function PrepareItems() {
752752
//If we have any EDS items, we need to add the loader
753753
if (EDSItems > 0) {
754754
jQuery('.send').hide();
755-
jQuery('#download_cart').prop('action', '[% PLUGIN_HTTP_PATH %]/opac/2411/opac-downloadcart.pl');
755+
jQuery('#download_cart').prop('action', '[% PLUGIN_HTTP_PATH %]/opac/2505/opac-downloadcart.pl');
756756
jQuery('#download_cart').prop('method', 'POST');
757757
jQuery('#download-cart').hide();
758758
jQuery('.print-large, .print').attr('onclick', ''); // .print for prog
@@ -902,7 +902,7 @@ function SetEDSCartField() {
902902
//Use the EDS version of sendbasket
903903

904904
if (jQuery('#sendbasketform')) {
905-
jQuery('#sendbasketform').prop('action', '[% PLUGIN_HTTP_PATH %]/opac/2411/opac-sendbasket.pl');
905+
jQuery('#sendbasketform').prop('action', '[% PLUGIN_HTTP_PATH %]/opac/2505/opac-sendbasket.pl');
906906
}
907907
//GET record list from URL and split into array on /
908908
var recordList = document.URL;
@@ -941,7 +941,7 @@ function sendBasket() { // override function in basket.js
941941
var valCookie = readCookie(nameCookie);
942942
var strCookie = nameCookie + "=" + valCookie;
943943

944-
var loc = "[% PLUGIN_HTTP_PATH %]/opac/2411/opac-sendbasket.pl?" + strCookie;
944+
var loc = "[% PLUGIN_HTTP_PATH %]/opac/2505/opac-sendbasket.pl?" + strCookie;
945945

946946
var optWin = "scrollbars=yes,resizable=yes,height=600,width=900,top=50,left=100";
947947
var win_form = open(loc, "win_form", optWin);
@@ -952,7 +952,7 @@ function downloadBasket() { // override function in basket.js
952952
var valCookie = readCookie(nameCookie);
953953
var strCookie = nameCookie + "=" + valCookie;
954954

955-
var loc = "[% PLUGIN_HTTP_PATH %]/opac/2411/opac-downloadcart.pl?" + strCookie;
955+
var loc = "[% PLUGIN_HTTP_PATH %]/opac/2505/opac-downloadcart.pl?" + strCookie;
956956

957957
open(loc, "win_form", 'scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
958958
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/usr/bin/perl
2+
3+
# Copyright 2009 BibLibre
4+
#
5+
# This file is part of Koha.
6+
#
7+
# Koha is free software; you can redistribute it and/or modify it
8+
# under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# Koha is distributed in the hope that it will be useful, but
13+
# WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19+
20+
use Modern::Perl;
21+
22+
use CGI qw ( -utf8 );
23+
use Encode qw( encode );
24+
25+
use C4::Auth qw( get_template_and_user );
26+
use C4::Biblio qw( GetFrameworkCode GetISBDView );
27+
use C4::Output qw( output_html_with_http_headers );
28+
use C4::Record;
29+
use C4::Ris qw( marc2ris );
30+
use Koha::Biblios;
31+
use Koha::CsvProfiles;
32+
use Koha::RecordProcessor;
33+
34+
use utf8;
35+
my $query = CGI->new();
36+
do '../eds-methods.pl';
37+
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
38+
{
39+
template_name => "opac-downloadcart.tt",
40+
query => $query,
41+
type => "opac",
42+
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
43+
}
44+
);
45+
my $eds_data = "";
46+
my $bib_list = $query->param('bib_list');
47+
#convert _dot_ to . to properly search for items
48+
$bib_list =~s/\_dot\_/\./g;
49+
my $format = $query->param('format');
50+
my $dbh = C4::Context->dbh;
51+
$eds_data = $query->param('eds_data'); #EDS Patch
52+
53+
if ( $bib_list && $format ) {
54+
55+
my $patron = Koha::Patrons->find($borrowernumber);
56+
57+
my @bibs = split( /\//, $bib_list );
58+
59+
my $marcflavour = C4::Context->preference('marcflavour');
60+
my $output;
61+
my $extension;
62+
my $type;
63+
64+
# CSV
65+
if ( $format =~ /^\d+$/ ) {
66+
67+
my $csv_profile = Koha::CsvProfiles->find($format);
68+
if ( not $csv_profile or $csv_profile->staff_only ) {
69+
print $query->redirect('/cgi-bin/koha/errors/404.pl');
70+
exit;
71+
}
72+
73+
$output = marc2csv( \@bibs, $format );
74+
75+
# Other formats
76+
} else {
77+
my $record_processor = Koha::RecordProcessor->new( { filters => 'ViewPolicy' } );
78+
foreach my $biblionumber (@bibs) {
79+
my $biblio = '';
80+
my $record = '';
81+
if($biblionumber =~m/\_\_/){
82+
my $dat = '';
83+
($record,$dat)= ProcessEDSCartItems($biblionumber,$eds_data,$record,$dat); #EDS patch
84+
} else {
85+
$biblio = Koha::Biblios->find($biblionumber);
86+
$record = $biblio->metadata->record(
87+
{
88+
embed_items => 1,
89+
opac => 1,
90+
patron => $patron,
91+
}
92+
);
93+
}
94+
my $framework = &GetFrameworkCode( $biblio );
95+
$record_processor->options({
96+
interface => 'opac',
97+
frameworkcode => $framework
98+
});
99+
$record_processor->process($record);
100+
101+
next unless $record;
102+
103+
if ( $format eq 'iso2709' ) {
104+
105+
#NOTE: If we don't explicitly UTF-8 encode the output,
106+
#the browser will guess the encoding, and it won't always choose UTF-8.
107+
$output .= encode( "UTF-8", $record->as_usmarc() ) // q{};
108+
} elsif ( $format eq 'ris' ) {
109+
$output .= marc2ris($record);
110+
} elsif ( $format eq 'bibtex' ) {
111+
$output .= marc2bibtex( $record, $biblionumber );
112+
# biblio or biblionumber?
113+
} elsif ( $format eq 'isbd' ) {
114+
my $framework = GetFrameworkCode($biblio);
115+
# biblio or biblionumber?
116+
$output .= GetISBDView(
117+
{
118+
'record' => $record,
119+
'template' => 'opac',
120+
'framework' => $framework,
121+
}
122+
);
123+
$extension = "txt";
124+
$type = "text/plain";
125+
}
126+
}
127+
}
128+
129+
# If it was a CSV export we change the format after the export so the file extension is fine
130+
$format = "csv" if ( $format =~ m/^\d+$/ );
131+
132+
print $query->header(
133+
-type => ($type) ? $type : 'application/octet-stream',
134+
-'Content-Transfer-Encoding' => 'binary',
135+
-attachment => ($extension) ? "cart.$format.$extension" : "cart.$format"
136+
);
137+
print $output;
138+
139+
} else {
140+
$template->param(
141+
csv_profiles => Koha::CsvProfiles->search(
142+
{
143+
type => 'marc',
144+
used_for => 'export_records',
145+
staff_only => 0
146+
}
147+
),
148+
bib_list => $bib_list,
149+
);
150+
output_html_with_http_headers $query, $cookie, $template->output;
151+
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/usr/bin/perl
2+
3+
# Copyright Doxulting 2004
4+
#
5+
# This file is part of Koha.
6+
#
7+
# Koha is free software; you can redistribute it and/or modify it
8+
# under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# Koha is distributed in the hope that it will be useful, but
13+
# WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19+
20+
use Modern::Perl;
21+
22+
use CGI qw ( -utf8 );
23+
use Encode;
24+
25+
use C4::Auth qw( get_template_and_user );
26+
use C4::Biblio qw(GetMarcSubjects);
27+
use C4::Output qw( output_html_with_http_headers );
28+
use C4::Templates;
29+
use Koha::Biblios;
30+
use Koha::Email;
31+
use Koha::Patrons;
32+
use Koha::Token;
33+
34+
my $query = CGI->new;
35+
36+
my $pluginsdir = C4::Context->config("pluginsdir");
37+
my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir;
38+
my ($PluginDir) = grep { -f $_ . "/Koha/Plugin/EDS.pm" } @pluginsdir;
39+
$PluginDir = $PluginDir.'/Koha/Plugin/EDS';
40+
41+
do '../eds-methods.pl';
42+
my $eds_data = $query->param('eds_data'); #EDS Patch
43+
44+
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
45+
{
46+
template_name => "opac-sendbasketform.tt",
47+
query => $query,
48+
type => "opac",
49+
}
50+
);
51+
my $patron = Koha::Patrons->find($borrowernumber);
52+
my $user_email = $patron ? $patron->notice_email_address : undef;
53+
54+
my $op = $query->param('op') || q{};
55+
my $bib_list = $query->param('bib_list') || '';
56+
#convert _dot_ to . to properly search for items
57+
$bib_list =~s/\_dot\_/\./g;
58+
59+
my $email_add = $query->param('email_add');
60+
61+
if ( $op eq "cud-send" && $email_add && $user_email ) {
62+
die "Wrong CSRF token"
63+
unless Koha::Token->new->check_csrf(
64+
{
65+
session_id => scalar $query->cookie('CGISESSID'),
66+
token => scalar $query->param('csrf_token'),
67+
}
68+
);
69+
70+
my $comment = $query->param('comment');
71+
72+
my @bibs = split( /\//, $bib_list );
73+
my $iso2709;
74+
my $catbibs;
75+
my $edscounter = 0;
76+
foreach my $biblionumber (@bibs) {
77+
my $biblio = '';
78+
my $record = '';
79+
if($biblionumber =~m/\_\_/){
80+
#if biblionumber matches on __, split into an and db
81+
my ($biblio_an, $biblio_db) = split(/__/, $biblionumber);
82+
#add header if EDS items are sent in basket
83+
if ($edscounter == 0){
84+
$comment .= "\n\n________________________________";
85+
$comment .= "\n\nEBSCO Discovery Service items are listed first, followed by your library catalog items.\n";
86+
}
87+
my $dat = '';
88+
($record,$dat)= ProcessEDSCartItems($biblionumber,$eds_data,$record,$dat);
89+
$iso2709 .= $record->as_usmarc() // q{};
90+
$edscounter++;
91+
#EDS data added to comment
92+
$comment .= "\n".$edscounter.". ".$record->title."\n";
93+
$comment .= "Author(s): ".$record->author."\n";
94+
#form URL with OPACBaseURL, plugin path for Koha eds-detail.pl, and add biblio_an, biblio_db to form link back to Koha catalog for EDS item
95+
$comment .= "URL: ".C4::Context->preference('OPACBaseURL').'/plugin/Koha/Plugin/EDS/opac/eds-detail.pl?q=Retrieve?an='.$biblio_an.'|dbid='.$biblio_db."\n";
96+
} #EDS Patch
97+
else {
98+
$catbibs .= $biblionumber."|";
99+
$biblio = Koha::Biblios->find($biblionumber) or next;
100+
$iso2709 .= $biblio->metadata->record->as_usmarc();
101+
}
102+
}
103+
if ( !defined $iso2709 ) {
104+
$template->param( error => 'NO_BODY' );
105+
}
106+
else {
107+
my %loops;
108+
if ($catbibs){
109+
my @catbibsloops = split( /\|/, $catbibs );
110+
%loops = ( biblio => \@catbibsloops, );
111+
}
112+
my %substitute = ( comment => $comment, );
113+
114+
my $letter = C4::Letters::GetPreparedLetter(
115+
module => 'catalogue',
116+
letter_code => 'CART',
117+
lang => $patron->lang,
118+
tables => {
119+
borrowers => $borrowernumber,
120+
},
121+
message_transport_type => 'email',
122+
loops => \%loops,
123+
substitute => \%substitute,
124+
);
125+
126+
my $attachment = {
127+
filename => 'basket.iso2709',
128+
type => 'application/octet-stream',
129+
content => $iso2709,
130+
};
131+
132+
my $message_id = C4::Letters::EnqueueLetter(
133+
{
134+
letter => $letter,
135+
message_transport_type => 'email',
136+
to_address => $email_add,
137+
reply_address => $user_email,
138+
attachments => [$attachment],
139+
}
140+
);
141+
142+
C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id;
143+
144+
$template->param( SENT => 1 );
145+
}
146+
147+
$template->param( email_add => $email_add );
148+
output_html_with_http_headers $query, $cookie, $template->output, undef,
149+
{ force_no_caching => 1 };
150+
151+
} elsif ( !$user_email ) {
152+
$template->param( email_add => 1, error => 'NO_REPLY_ADDRESS' );
153+
output_html_with_http_headers $query, $cookie, $template->output;
154+
155+
} else {
156+
my $new_session_id = $query->cookie('CGISESSID');
157+
$template->param(
158+
bib_list => $bib_list,
159+
url => "/cgi-bin/koha/opac-sendbasket.pl",
160+
suggestion => C4::Context->preference("suggestion"),
161+
virtualshelves => C4::Context->preference("virtualshelves"),
162+
csrf_token =>
163+
Koha::Token->new->generate_csrf( { session_id => $new_session_id, } ),
164+
);
165+
output_html_with_http_headers $query, $cookie, $template->output, undef,
166+
{ force_no_caching => 1 };
167+
}

0 commit comments

Comments
 (0)