Bug 30287: Conditionally render notice preview

This patch adds conditional formatting based on whether the notice was
generated from an HTML template or a plaintext one. We simply drop the
'html_line_break' filter for the case where the notice should already be
html formatted.

I was tempted to replace the html_line_break for plaintext formatted
notices too as I believe this closer resembles how we actually output
such generated notices.. but I decided that should be for another bug.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2023-11-06 12:50:05 +00:00 committed by Katrin Fischer
parent 8bb8282d68
commit f83b9ab1ff
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 6 additions and 1 deletions

View file

@ -1,5 +1,6 @@
[% USE raw %]
[% USE Asset %]
[% USE String %]
[% USE Koha %]
[% USE AuthorisedValues %]
[% USE Branches %]
@ -65,7 +66,11 @@
<tr>
<td>
<a class="notice-title" data-noticeid="[% QUEUED_MESSAGE.message_id | html %]" href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber | uri %]&amp;noticeid=[% QUEUED_MESSAGE.message_id | uri %]">[% QUEUED_MESSAGE.subject | html %]</a>
[% IF QUEUED_MESSAGE.content_type.search('html') %]
<iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.content | html %]"></iframe>
[% ELSE %]
<iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.content | html | html_line_break %]"></iframe>
[% END %]
</td>
<td>
[% IF ( QUEUED_MESSAGE.message_transport_type == 'email' ) %]<span>email</span>

View file

@ -110,7 +110,7 @@ if ( $op eq 'send_password_reset' ) {
}
# Getting the messages
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
my $queued_messages = Koha::Notice::Messages->search({borrowernumber => $borrowernumber});
$template->param(
patron => $patron,