From 6c3b7ce6148f188402b8789a92229484468ed8e0 Mon Sep 17 00:00:00 2001 From: Eric Phetteplace Date: Thu, 12 Feb 2026 12:30:37 -0800 Subject: [PATCH] Bug 2172: Cart attaches an iso2709 file, which confuses 99% of patrons This simply removes the code that was attaching a MARC file to every "send basket" email. MARC files of baskets can still be downloaded. Testing plan: - Set KohaAdminEmailAddress to a valid email - Add an email to a patron (e.g. the "koha" patron in ktd) - In the OPAC as that patron, search for & add a bib to your basket - Send the basket; note the attached .iso2709 file - APPLY PATCH - Send the basket; there is no attachment --- basket/sendbasket.pl | 21 +----- .../mysql/en/mandatory/sample_notices.yml | 1 - opac/opac-sendbasket.pl | 68 +++++++------------ 3 files changed, 27 insertions(+), 63 deletions(-) diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index 8bc97420e1..0c97876414 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -17,8 +17,7 @@ use Modern::Perl; -use CGI qw ( -utf8 ); -use Encode; +use CGI qw ( -utf8 ); use Carp qw( carp ); use Try::Tiny qw( catch try ); @@ -56,17 +55,8 @@ if ( $op eq "cud-send" && $email_add ) { my $comment = $query->param('comment'); my @bibs = split( /\//, $bib_list ); - my $iso2709; - foreach my $bib (@bibs) { - my $biblio = Koha::Biblios->find($bib) or next; - $iso2709 .= $biblio->metadata_record()->as_usmarc(); - } - - if ( !defined $iso2709 ) { - carp "Error sending mail: empty basket"; - $template->param( error => 1 ); - } elsif ( !defined $user_email or $user_email eq '' ) { + if ( !defined $user_email or $user_email eq '' ) { carp "Error sending mail: sender's email address is invalid"; $template->param( error => 1 ); } else { @@ -86,19 +76,12 @@ if ( $op eq "cud-send" && $email_add ) { substitute => \%substitute, ); - my $attachment = { - filename => 'basket.iso2709', - type => 'application/octet-stream', - content => Encode::encode( "UTF-8", $iso2709 ), - }; - my $message_id = C4::Letters::EnqueueLetter( { letter => $letter, message_transport_type => 'email', to_address => $email_add, reply_address => $user_email, - attachments => [$attachment], } ); diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 69ff86f532..efb11aab7c 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -2637,7 +2637,6 @@ tables: - "[%- PROCESS 'html_helpers.inc' -%]" - "Hi,

" - "[% borrower.firstname | html %] [% borrower.surname | html %] sent you a cart from our online catalog.
" - - "Please note that the attached file is a MARC bibliographic records file which can be imported into personal bibliographic software like EndNote, Reference Manager or ProCite.
" - "[% IF ( comment ) %]

[% comment | html | html_line_break %]

[% END %]
" - "
    [% FOREACH biblio IN biblios %]
  1. " - "[% biblio.title | html %]" diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index 3f5a21727d..46fd36fb27 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -20,7 +20,6 @@ use Modern::Perl; use CGI qw ( -utf8 ); -use Encode; use C4::Auth qw( get_template_and_user ); use C4::Biblio qw(GetMarcSubjects); @@ -50,52 +49,35 @@ if ( $op eq "cud-send" && $email_add && $user_email ) { my $comment = $query->param('comment'); my @bibs = split( /\//, $bib_list ); - my $iso2709; - foreach my $bib (@bibs) { - $bib = int($bib); - my $biblio = Koha::Biblios->find($bib) or next; - $iso2709 .= $biblio->metadata_record( { interface => 'opac' } )->as_usmarc(); - } - if ( !defined $iso2709 ) { - $template->param( error => 'NO_BODY' ); - } else { - my %loops = ( biblio => \@bibs, ); + my %loops = ( biblio => \@bibs, ); + + my %substitute = ( comment => $comment, ); - my %substitute = ( comment => $comment, ); + my $letter = C4::Letters::GetPreparedLetter( + module => 'catalogue', + letter_code => 'CART', + lang => $patron->lang, + tables => { + borrowers => $borrowernumber, + }, + message_transport_type => 'email', + loops => \%loops, + substitute => \%substitute, + ); - my $letter = C4::Letters::GetPreparedLetter( - module => 'catalogue', - letter_code => 'CART', - lang => $patron->lang, - tables => { - borrowers => $borrowernumber, - }, + my $message_id = C4::Letters::EnqueueLetter( + { + letter => $letter, message_transport_type => 'email', - loops => \%loops, - substitute => \%substitute, - ); - - my $attachment = { - filename => 'basket.iso2709', - type => 'application/octet-stream', - content => Encode::encode( "UTF-8", $iso2709 ), - }; - - my $message_id = C4::Letters::EnqueueLetter( - { - letter => $letter, - message_transport_type => 'email', - to_address => $email_add, - reply_address => $user_email, - attachments => [$attachment], - } - ); - - C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; - - $template->param( SENT => 1 ); - } + to_address => $email_add, + reply_address => $user_email, + } + ); + + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; + + $template->param( SENT => 1 ); $template->param( email_add => $email_add ); output_html_with_http_headers $query, $cookie, $template->output, undef, -- 2.53.0