Bugzilla – Attachment 186787 Details for
Bug 40860
ILL get_notice does not consider HTML template notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40860: Consider is_html template notice
Bug-40860-Consider-ishtml-template-notice.patch (text/plain), 4.13 KB, created by
Pedro Amorim
on 2025-09-23 11:04:35 UTC
(
hide
)
Description:
Bug 40860: Consider is_html template notice
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-09-23 11:04:35 UTC
Size:
4.13 KB
patch
obsolete
>From 655bf7ea26bcfcf7282d581c9ad1ab8a918f3a4e Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Tue, 23 Sep 2025 11:03:05 +0000 >Subject: [PATCH] Bug 40860: Consider is_html template notice > >Change logic of get_notice to fetch the template before GetPreparedLetter. >This allows to verify is the template is HTML or not, and act accordingly. > >Test plan, before applying patch: > >1) Enable ILLModule >2) Edit the default ktd ILL partner patron and add a primary email address: > <staff_url>/cgi-bin/koha/circ/circulation.pl?borrowernumber=16 >3) Create a new ILL request, visit: > <staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard >4) Add some metadata like title and author, after creation click 'Place request with partners'. 'FRL - Walker' should show up as an option. Select that and click 'Send email'. >5) Run the following query to grab the produced email content: >$ koha-mysql kohadev >$ SELECT content FROM message_queue; >6) Utilize an HTML previewer (to avoid having to send the mail for testing): >https://html.onlineviewer.net/ >7) Paste the contents there, notice there's no line breaks when shown as HTML. >8) Apply patch, restart plack, repeat test plan. Notice the HTML preview has appropriate line breaks for each metadata entry. Please note that any other remaining line breaks need to replaced by a <p> tag but that is besides the ill_full_metadata substitution scope of this patch. >--- > Koha/ILL/Request.pm | 39 +++++++++++++++++++++++++++++---------- > 1 file changed, 29 insertions(+), 10 deletions(-) > >diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm >index 3284f209b84..6fa595775fc 100644 >--- a/Koha/ILL/Request.pm >+++ b/Koha/ILL/Request.pm >@@ -26,6 +26,7 @@ use DateTime; > use C4::Letters; > use Mojo::Util qw(deprecated); > use File::Basename qw(dirname); >+use Carp qw( croak ); > > use Koha::AuthorisedValue; > use Koha::AuthorisedValues; >@@ -1929,25 +1930,43 @@ and transport type > sub get_notice { > my ( $self, $params ) = @_; > >- my $title = $self->extended_attributes->find( { type => 'title' } ); >- my $author = $self->extended_attributes->find( { type => 'author' } ); >- my $metahash = $self->metadata; >+ my $title = $self->extended_attributes->find( { type => 'title' } ); >+ my $author = $self->extended_attributes->find( { type => 'author' } ); >+ my $metahash = $self->metadata; >+ my $template = Koha::Notice::Templates->find_effective_template( >+ { >+ module => 'ill', >+ code => $params->{notice_code}, >+ branchcode => $self->branchcode, >+ message_transport_type => $params->{transport}, >+ lang => $self->patron ? $self->patron->lang : undef >+ } >+ ); >+ >+ unless ($template) { >+ croak "No 'ill' " . $params->{notice_code} . " letter transported by " . $params->{transport}; >+ return; >+ } >+ >+ my $metastring; > my @metaarray = (); > foreach my $key ( sort { lc $a cmp lc $b } keys %{$metahash} ) { > my $value = $metahash->{$key}; > push @metaarray, "- $key: $value" if $value; > } >- my $metastring = join( "\n", @metaarray ); > >+ my $template_hash = $template->unblessed; >+ if ( $template_hash->{is_html} ) { >+ $metastring = join( "<br>\n", @metaarray ); >+ $template_hash->{'content-type'} = 'text/html; charset="UTF-8"'; >+ } else { >+ $metastring = join( "\n", @metaarray ); >+ } > my $illrequestattributes = { map { $_->type => $_->value } $self->extended_attributes->as_list }; > > my $letter = C4::Letters::GetPreparedLetter( >- module => 'ill', >- letter_code => $params->{notice_code}, >- branchcode => $self->branchcode, >- message_transport_type => $params->{transport}, >- lang => $self->patron ? $self->patron->lang : undef, >- tables => { >+ letter => $template_hash, >+ tables => { > illrequests => $self->illrequest_id, > borrowers => $self->borrowernumber, > biblio => $self->biblio_id, >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40860
:
186787
|
186788