mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX Ensure HTML email preview content is parsed as HTML including shortcodes
This commit is contained in:
parent
802c750a77
commit
bf20e19285
@ -221,7 +221,7 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
||||
'The email address which the recipient is able to \'reply\' to.'
|
||||
))
|
||||
));
|
||||
|
||||
|
||||
$fields->fieldByName('Root.EmailDetails')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILDETAILSTAB', 'Email Details'));
|
||||
|
||||
// Only show the preview link if the recipient has been saved.
|
||||
@ -263,7 +263,7 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
||||
'<div id="EmailPreview" class="field toggle-html-only">' . $preview . '</div>'
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
$fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content'));
|
||||
|
||||
// Custom rules for sending this field
|
||||
@ -288,7 +288,7 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
||||
),
|
||||
$grid
|
||||
));
|
||||
|
||||
|
||||
$fields->fieldByName('Root.CustomRules')->setTitle(_t('UserDefinedForm_EmailRecipient.CUSTOMRULESTAB', 'Custom Rules'));
|
||||
|
||||
$this->extend('updateCMSFields', $fields);
|
||||
@ -417,7 +417,10 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
||||
*/
|
||||
public function getEmailBodyContent()
|
||||
{
|
||||
return $this->SendPlain ? $this->EmailBody : $this->EmailBodyHtml;
|
||||
if ($this->SendPlain) {
|
||||
return DBField::create_field('HTMLText', $this->EmailBody)->NoHTML();
|
||||
}
|
||||
return DBField::create_field('HTMLText', $this->EmailBodyHtml)->RAW();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class UserDefinedForm_EmailRecipientTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'UserDefinedForm_EmailRecipientTest.yml';
|
||||
|
||||
public function testShortcodesAreRenderedInEmailPreviewContent()
|
||||
{
|
||||
$page = $this->objFromFixture('SiteTree', 'about_us');
|
||||
|
||||
$recipient = UserDefinedForm_EmailRecipient::create();
|
||||
$recipient->SendPlain = false;
|
||||
$recipient->EmailBodyHtml = '<p>Some email content. About us: [sitetree_link,id=' . $page->ID . '].</p>';
|
||||
|
||||
$result = $recipient->getEmailBodyContent();
|
||||
$this->assertContains('/about-us/', $result);
|
||||
|
||||
$recipient->SendPlain = true;
|
||||
$recipient->EmailBody = 'Some email content. About us: [sitetree_link,id=' . $page->ID . '].';
|
||||
|
||||
$result = $recipient->getEmailBodyContent();
|
||||
$this->assertContains('/about-us/', $result);
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
SiteTree:
|
||||
about_us:
|
||||
Title: About Us
|
||||
URLSegment: about-us
|
Loading…
Reference in New Issue
Block a user