1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-22 13:41:52 +02:00

Added support for embedded mail media in mailouts.

This commit is contained in:
Cameron 2014-10-18 15:00:40 -07:00
parent 5a2ce38e08
commit 65b44a8abb
7 changed files with 100 additions and 23 deletions

@ -303,10 +303,12 @@ class mailout_main_ui extends e_admin_ui
'mail_attach' => array('title' => LAN_MAILOUT_153, 'tab'=>1, 'type'=>'method','data'=>false),
'mail_include_images' => array('title' => LAN_MAILOUT_224, 'tab'=>1, 'type'=>'boolean','data'=>false, 'proc' => 'yesno'),
'mail_send_style' => array('title' => LAN_MAILOUT_154,'type'=>'method','data'=>false),
'mail_media' => array('title' => 'Embed Media', 'type' => 'images', 'data' => 'array', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => 'video=1', 'class' => 'center', 'thclass' => 'center', ),
'mail_body' => array('title' => LAN_MAILOUT_100, 'type'=>'bbarea', 'proc' => 'trunc200'),
'mail_body_templated' => array('title' => LAN_MAILOUT_257, 'noedit'=>true, 'proc' => 'chars'),
'mail_other' => array('title' => LAN_MAILOUT_84, 'type'=>null, 'noedit'=>true, 'data'=>'array', 'nolist'=>true),
'options' => array('title' => LAN_OPTIONS, 'type'=>'method', 'width'=>'10%', 'forced' => TRUE)
);
@ -591,16 +593,17 @@ class mailout_main_ui extends e_admin_ui
function previewPage()
{
$mailData = e107::getDb()->retrieve('mail_content','*','mail_source_id='.intval($_GET['id'])." LIMIT 1");
$data = $this->mailAdmin->dbToMail($mailData);
$eml = array(
'subject' => $data['mail_subject'],
'body' => $data['mail_body'],
'template' => $data['mail_send_style'],
'shortcodes' => array('USERNAME'=>'John Example', 'DISPLAYNAME'=> 'John Example', 'USERID'=>'555', 'UNSUBSCRIBE'=>SITEURL."unsubscribe/?id=example1234567")
'shortcodes' => array('USERNAME'=>'John Example', 'DISPLAYNAME'=> 'John Example', 'USERID'=>'555', 'UNSUBSCRIBE'=>SITEURL."unsubscribe/?id=example1234567"),
'media' => $data['mail_media'],
);
return e107::getEmail()->preview($eml);
exit;
@ -1297,7 +1300,10 @@ class mailout_admin_form_ui extends e_admin_form_ui
if($mode == 'sent' || $mode == 'pending' || $mode == 'held')
{
$link = e_SELF."?searchquery=&filter_options=mail_detail_id__".$id."&mode=recipients&action=list";
$preview = e_SELF."?mode=main&action=preview&id=".$id;
$text .= "<a href='".$link."' class='btn' title='Recipients'>".E_32_USER."</a>";
$text .= "<a rel='external' class='btn e-modal' data-modal-caption='Email preview' href='".$preview."' class='btn' title='Preview'>".E_32_SEARCH."</a>";
$att['readParms']['editClass'] = e_UC_NOBODY;
$text .= $this->renderValue('options',$value,$att,$id);
return $text;

@ -273,6 +273,7 @@ CREATE TABLE mail_content (
mail_body text,
mail_body_templated text,
mail_other text,
mail_media text,
PRIMARY KEY (mail_source_id),
KEY mail_content_status (mail_content_status)
) ENGINE=MyISAM;

@ -37,8 +37,6 @@ See e_HANDLER.mail.php for more information
if (!defined('e107_INIT')) { exit; }
// @TODO: Move signup email into templated form
$includeSiteButton = e107::getPref('sitebutton');
/*
@ -159,6 +157,7 @@ LAN_SIGNUP_97." {SITENAME}<br />
* Format for individual emails sent by e107 (not bulk emails for now) - a work in progress - bulk could be ported later.
* @see e107Email::sendEmail();
* Aim: to make email templates follow the same spec. as other templates while remaining as intuitive as other v2 templates in e107.
* Note: giving a template a 'name' value will make it available in the admin->mailout area.
*/
@ -172,7 +171,8 @@ $EMAIL_TEMPLATE['default']['header'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHT
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
<style type='text/css'>
body { padding:10px; background-color: #E1E1E1 }
div#body { padding:10px; width: 800px; background-color: #FFFFFF; border-radius: 5px }
div#body { padding:10px; width: 800px; background-color: #FFFFFF; border-radius: 5px; font-family: helvetica,arial }
.video-thumbnail { max-width: 100% }
</style>
</head>
@ -264,21 +264,23 @@ $EMAIL_TEMPLATE['notify']['body'] = $EMAIL_TEMPLATE['default']['body']; // wi
$EMAIL_TEMPLATE['notify']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default header above.
// ------ User-Mailout Templates
// ------ User-Specific Templates
$EMAIL_TEMPLATE['user-monthly']['name'] = 'Monthly Update';
$EMAIL_TEMPLATE['user-monthly']['subject'] = '{SITENAME}: {SUBJECT} ';
$EMAIL_TEMPLATE['user-monthly']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
$EMAIL_TEMPLATE['user-monthly']['body'] = "Just to keep you up to date, here's a reminder of what's changed in the past month.<br />{BODY}<br />To find out more, simply click on the links!";
$EMAIL_TEMPLATE['user-monthly']['footer'] = $EMAIL_TEMPLATE['default']['footer'];
$EMAIL_TEMPLATE['monthly']['name'] = 'Monthly Update';
$EMAIL_TEMPLATE['monthly']['subject'] = '{SITENAME}: {SUBJECT} ';
$EMAIL_TEMPLATE['monthly']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
$EMAIL_TEMPLATE['monthly']['body'] = "Just to keep you up to date, here's a reminder of what's changed in the past month.<br />{BODY}{MEDIA1}{MEDIA2}{MEDIA3}{MEDIA4}{MEDIA5}To find out more, simply click on the links!";
$EMAIL_TEMPLATE['monthly']['footer'] = $EMAIL_TEMPLATE['default']['footer'];
$EMAIL_TEMPLATE['user-whatsnew']['name'] = "What's New";
$EMAIL_TEMPLATE['user-whatsnew']['subject'] = '{SITENAME}: {SUBJECT} ';
$EMAIL_TEMPLATE['user-whatsnew']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
$EMAIL_TEMPLATE['user-whatsnew']['body'] = "All the latest news and updates.<br />{BODY}<br />To find out more, simply click on the links!";
$EMAIL_TEMPLATE['user-whatsnew']['footer'] = $EMAIL_TEMPLATE['default']['footer'];
$EMAIL_TEMPLATE['whatsnew']['name'] = "What's New";
$EMAIL_TEMPLATE['whatsnew']['subject'] = '{SITENAME}: {SUBJECT} ';
$EMAIL_TEMPLATE['whatsnew']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
$EMAIL_TEMPLATE['whatsnew']['body'] = "All the latest news and updates.<br />{BODY}<br />To find out more, simply click on the links!";
$EMAIL_TEMPLATE['whatsnew']['footer'] = $EMAIL_TEMPLATE['default']['footer'];

@ -2949,6 +2949,21 @@ class e_parser
return "<img class='img-responsive' src='".$thumbSrc."' alt='Youtube Video' style='width:".vartrue($parm['w'],'80')."px'/>";
}
if($thumb == 'email')
{
$thumbSrc = "http://i1.ytimg.com/vi/".$id."/maxresdefault.jpg"; // 640 x 480
$filename = 'temp/yt-thumb-'.md5($id).".jpg";
$filepath = e_MEDIA.$filename;
$url = 'http://youtu.be/'.$id;
if(!file_exists($filepath))
{
e107::getFile()->getRemoteFile($thumbSrc, $filename,'media');
}
return "<a href='".$url."'><img class='video-responsive video-thumbnail' src='".$filepath."' alt='Youtube Video' title='Click to view on Youtube' /></a>";
}
if($thumb == 'src')
{
return $thumbSrc;

@ -619,6 +619,42 @@ class e107Email extends PHPMailer
}
function processShortcodes($eml)
{
$tp = e107::getParser();
$eml['shortcodes']['BODY'] = $tp->toEmail($eml['body']);
$eml['shortcodes']['SUBJECT'] = $eml['subject'];
$eml['shortcodes']['THEME'] = e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
if(!empty($eml['media']) && is_array($eml['media']))
{
foreach($eml['media'] as $k=>$val)
{
if(vartrue($val['path']))
{
$id = 'MEDIA'.($k+1);
if($tp->isVideo($val['path']))
{
$eml['shortcodes'][$id] = "<div class='media'>".$tp->toVideo($val['path'],array('thumb'=>'email'))."</div>";
}
else
{
$eml['shortcodes'][$id] = "<div class='media'><img class='img-responsive' src='".$tp->replaceConstants($val['path'])."' alt='' /></div>";
}
}
}
}
return $eml['shortcodes'];
}
/**
* Sets one or more parameters from an array. See @see{sendEmail()} for list of parameters
@ -645,15 +681,20 @@ class e107Email extends PHPMailer
}
if(vartrue($eml['template'])) // @see e107_core/templates/email_template.php
{
{
if($tmpl = e107::getCoreTemplate('email', $eml['template'], 'front', true)) //FIXME - Core template is failing with template 'notify'. Works with theme template. Issue with core template registry?
{
$eml['shortcodes']['BODY'] = $tp->toEmail($eml['body']);
$eml['shortcodes']['SUBJECT'] = $eml['subject'];
$eml['shortcodes']['THEME'] = e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
// $eml['shortcodes']['BODY'] = $tp->toEmail($eml['body']);
// $eml['shortcodes']['SUBJECT'] = $eml['subject'];
// $eml['shortcodes']['THEME'] = e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
$eml['shortcodes'] = $this->processShortcodes($eml);
// print_a($eml);
$emailBody = $tmpl['header']. $tmpl['body'] . $tmpl['footer'];
$eml['body'] = $tp->parseTemplate($emailBody, true, varset($eml['shortcodes'],null));

@ -315,6 +315,12 @@ class e107MailManager
$res[$f] = '';
}
}
if (isset($data['mail_media']))
{
$res['mail_media'] = e107::unserialize($data['mail_media']);
}
return $res;
}
@ -443,6 +449,12 @@ class e107MailManager
$tmp = e107::unserialize(str_replace('\\\'', '\'',$data['mail_target_info'])); // May have escaped data
$res['mail_target_info'] = $tmp;
}
if (isset($data['mail_media']))
{
$res['mail_media'] = e107::unserialize($data['mail_media']);
}
return $res;
}

@ -2049,7 +2049,7 @@ class mailoutAdminClass extends e107MailManager
foreach($templates as $key => $layout)
{
if(substr($key, 0, 5) == 'user-' || $key == 'default')
if(vartrue($layout['name']))
{
$ret[$key] = $layout['name'];
}