From: larssandergreen Date: Wed, 26 Apr 2023 19:17:12 +0000 (-0600) Subject: Don't add newlines to html activities X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2e976ade9faa4b6dbe31aa9e1f16771e027e0ee6;p=civicrm-core.git Don't add newlines to html activities --- diff --git a/CRM/Core/Smarty/plugins/modifier.nl2brIfNotHTML.php b/CRM/Core/Smarty/plugins/modifier.nl2brIfNotHTML.php new file mode 100644 index 0000000000..b752cd9870 --- /dev/null +++ b/CRM/Core/Smarty/plugins/modifier.nl2brIfNotHTML.php @@ -0,0 +1,34 @@ + {$form.details.html} - {elseif $activityTypeNameAndLabel.machineName eq "Inbound Email"} + {elseif $activityTypeNameAndLabel.machineName eq "Inbound Email" && $form.details.value|crmStripAlternatives|strip_tags eq $form.details.value|crmStripAlternatives} {$form.details.html|crmStripAlternatives|nl2br} diff --git a/templates/CRM/Activity/Form/ActivityView.tpl b/templates/CRM/Activity/Form/ActivityView.tpl index 35c0297cfe..81f4c6d989 100644 --- a/templates/CRM/Activity/Form/ActivityView.tpl +++ b/templates/CRM/Activity/Form/ActivityView.tpl @@ -15,12 +15,12 @@ {ts}Added by{/ts}{$values.source_contact} - {if $values.target_contact_value} + {if array_key_exists('target_contact_value', $values)} {ts}With Contact{/ts}{$values.target_contact_value} {/if} - {if $values.mailingId} + {if array_key_exists('mailingId', $values)} {ts}With Contact{/ts}{ts}Mailing Report{/ts} @@ -29,13 +29,13 @@ {ts}Subject{/ts}{$values.subject} - {if $values.campaign} + {if array_key_exists('campaign', $values)} {ts}Campaign{/ts}{$values.campaign} {/if} - {if $values.engagement_level AND + {if array_key_exists('engagement_level', $values) AND call_user_func( array( 'CRM_Campaign_BAO_Campaign', 'isComponentEnabled' ) )} {ts}Engagement Level{/ts}{$values.engagement_level} {/if} @@ -43,7 +43,7 @@ {ts}Date and Time{/ts}{$values.activity_date_time|crmDate } - {if $values.mailingId} + {if array_key_exists('mailingId', $values)} # of opens @@ -119,7 +119,9 @@ {else} - {ts}Details{/ts}{$values.details|crmStripAlternatives|purify|nl2br} + {ts}Details{/ts} + {if array_key_exists('details', $values)}{$values.details|crmStripAlternatives|purify|nl2brIfNotHTML}{/if} + {/if} {if $values.attachment} diff --git a/templates/CRM/Case/Form/ActivityView.tpl b/templates/CRM/Case/Form/ActivityView.tpl index 9bc3c3d781..d2113d9f78 100644 --- a/templates/CRM/Case/Form/ActivityView.tpl +++ b/templates/CRM/Case/Form/ActivityView.tpl @@ -41,7 +41,8 @@ {if $parentID} {ts}Prompted by{/ts}{/if} {else} - {if $row.label eq 'Details'}{$row.value|crmStripAlternatives|nl2br|purify}{elseif $row.type eq 'Date'}{$row.value|crmDate}{else}{$row.value}{/if} + + {if $row.label eq 'Details'}{$row.value|crmStripAlternatives|nl2brIfNotHTML|purify}{elseif $row.type eq 'Date'}{$row.value|crmDate}{else}{$row.value}{/if} {/if} {/foreach}