mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 12:41:51 +02:00
Issue #4919 - Add support for quick custom email template without separate file.
This commit is contained in:
parent
552af19c54
commit
c419d402d7
@ -913,9 +913,16 @@ class e107Email extends PHPMailer
|
||||
{
|
||||
require_once(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_users.php"); // do not use e107::lan etc.
|
||||
|
||||
if(is_array($eml['template']) && !empty($eml['template']['plugin']) && !empty($eml['template']['name']) && !empty($eml['template']['key']))
|
||||
if(is_array($eml['template']))
|
||||
{
|
||||
$tmpl = e107::getTemplate($eml['template']['plugin'],$eml['template']['name'], $eml['template']['key']);
|
||||
if(!empty($eml['template']['plugin']) && !empty($eml['template']['name']) && !empty($eml['template']['key'])) // Plugin template
|
||||
{
|
||||
$tmpl = e107::getTemplate($eml['template']['plugin'],$eml['template']['name'], $eml['template']['key']);
|
||||
}
|
||||
elseif(isset($eml['template']['header']) && isset($eml['template']['body']) && isset($eml['template']['footer'])) // Custom Template
|
||||
{
|
||||
$tmpl = $eml['template'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -68,6 +68,41 @@
|
||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test using a custom template passed directly.
|
||||
* @return void
|
||||
*/
|
||||
public function testArraySetInlineTemplate()
|
||||
{
|
||||
$eml = array(
|
||||
'subject' => "[CUSTOM TEMPLATE EXAMPLE]",
|
||||
'sender_email' => "noreply@test.com",
|
||||
'sender_name' => "Test Person",
|
||||
'replyto' => "",
|
||||
'html' => true,
|
||||
'priority' => 1,
|
||||
'template' => ['subject'=>'{SUBJECT}', 'header'=>'<html lang="en"><body>', 'body'=>'<div><span>{NAME}</span> <small>{DATE}</small></div><div>{BODY}</div>', 'footer'=>'</body></html>'],
|
||||
'body' => "This is the body text",
|
||||
'cc' => '',
|
||||
'shortcodes' => [
|
||||
'NAME' => "TestName",
|
||||
'DATE' => 'Jan 1st, 2020'
|
||||
],
|
||||
);
|
||||
|
||||
$this->eml->arraySet($eml);
|
||||
|
||||
$this->assertStringContainsString("noreply@test.com", $this->eml->From);
|
||||
$this->assertStringContainsString("Test Person", $this->eml->FromName);
|
||||
$this->assertStringContainsString("[CUSTOM TEMPLATE EXAMPLE]", $this->eml->Subject);
|
||||
|
||||
$this->assertStringContainsString('<html lang="en"><body>', $this->eml->Body);
|
||||
|
||||
$this->assertStringContainsString('<div><span>TestName</span> <small>Jan 1st, 2020</small></div><div>This is the body text</div>', $this->eml->Body);
|
||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test using an email template from e107_plugins/_blank/templates/_blank_template.php
|
||||
* @return void
|
||||
@ -103,6 +138,8 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function testArraySetNotifyTemplate()
|
||||
{
|
||||
$eml = array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user