1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-30 01:08:46 +02:00

Email admin->notify template working with new template standard.

This commit is contained in:
Cameron 2014-08-26 15:49:24 -07:00
parent 7cc591a180
commit 2f9dae5eed
4 changed files with 65 additions and 42 deletions

@ -228,26 +228,7 @@ LAN_SIGNUP_97." {SITENAME}<br />
//-------------------------------------------------------------
// 'NOTIFY' TEMPLATE
//-------------------------------------------------------------
$NOTIFY_TEMPLATE = array(
'template_name' => 'Notify',
'template_type' => 'system',
'email_overrides' => '',
'email_header' => "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
<html xmlns='http://www.w3.org/1999/xhtml' >
<head>
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
</head>
<body>
<div style='padding:0px 10px'>
",
'email_body' => '{BODY}',
'email_footer' => "<br /><br />
{SITENAME=link}
</div>
</body>
</html>",
'email_plainText' => ''
);
//-------------------------------------------------------------
@ -308,14 +289,6 @@ $MONTHLYUPDATE_TEMPLATE = array(
$QUICKADDUSER_TEMPLATE = array(
'template_name' => 'Quick-Add-User',
'template_type' => 'quickadd',
'email_overrides' => '',
// 'email_header' - any header information (usually loaded from the default)
'email_body' => USRLAN_185.USRLAN_186,
// 'email_footer' => 'footer'
);
@ -421,16 +394,23 @@ $EMAIL_TEMPLATE['quickadduser']['header'] = $EMAIL_TEMPLATE['default']['header'
$EMAIL_TEMPLATE['quickadduser']['body'] = USRLAN_185.USRLAN_186;
$EMAIL_TEMPLATE['quickadduser']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default footer above.
// ---------------------------------
// Notify (@see admin-> notify) // TODO
// Notify (@see admin-> notify)
$EMAIL_TEMPLATE['notify']['subject'] = '{SITENAME}: {SUBJECT} ';
$EMAIL_TEMPLATE['notify']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
$EMAIL_TEMPLATE['notify']['body'] = $EMAIL_TEMPLATE['default']['body']; // will use default header above.
$EMAIL_TEMPLATE['notify']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default header above.
// ---------------------------------
// A Dummy Example for theme developers.
$EMAIL_TEMPLATE['example']['subject'] = '{SITENAME}: {SUBJECT} ';
$EMAIL_TEMPLATE['example']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.

@ -606,7 +606,7 @@ class e107Email extends PHPMailer
{
if($tmpl = e107::getCoreTemplate('email', $eml['template'], true, true)) // $EMAIL_TEMPLATE['default']
if($tmpl = e107::getCoreTemplate('email', $eml['template'], true, true)) //FIXME - Core template is failing with template 'notify'. Works with theme template. Issue with core template registry?
{
// $filter = array("\n", "\t");
// $tmpl['header'] = str_replace($filter,'', $tmpl['header']);
@ -623,6 +623,7 @@ class e107Email extends PHPMailer
if($this->debug)
{
echo "<h4>e107Email::arraySet() - line ".__LINE__."</h4>";
print_a($tmpl);
}
@ -630,6 +631,15 @@ class e107Email extends PHPMailer
$this->Subject = $tp->parseTemplate($tmpl['subject'], true, varset($eml['shortcodes'],null));
}
else
{
if($this->debug)
{
echo "<h4>Couldn't find email template: ".$eml['template']."</h4>";
}
if (vartrue($eml['email_subject'])) $this->Subject = $tp->parseTemplate($eml['email_subject'], true, varset($eml['shortcodes'],null));
e107::getMessage()->addDebug("Couldn't find email template: ".$eml['template']);
}
}
else
@ -658,12 +668,11 @@ class e107Email extends PHPMailer
if($this->debug)
{
echo "<h4>e107Email::arraySet() - line ".__LINE__."</h4>";
print_a($eml);
}
if (vartrue($eml['returnreceipt'])) $this->ConfirmReadingTo = $eml['returnreceipt'];
if (vartrue($eml['email_inline_images'])) $this->addInlineImages($eml['email_inline_images']);
if (vartrue($eml['email_priority'])) $this->Priority = $eml['email_priority'];

@ -799,6 +799,8 @@ class e107MailManager
//'extra_header' - additional headers (format is name: value
//'wordwrap' - Set wordwrap value
//'split' - If true, sends an individual email to each recipient
'template' => 'template', // required
'shortcodes' => 'shortcodes' // required
);
$result = array();
if (!isset($email['mail_source_id'])) $email['mail_source_id'] = 0;
@ -828,6 +830,8 @@ class e107MailManager
$result['send_html'] = ($email['mail_send_style'] != 'textonly');
$result['add_html_header'] = FALSE; // We look after our own headers
// Set up any extra mailer parameters that need it
if (!vartrue($email['e107_header']))
{
@ -1497,7 +1501,7 @@ class e107MailManager
// Get template data, override email settings as appropriate
require_once(e_HANDLER.'mail_template_class.php');
$ourTemplate = new e107MailTemplate();
if (!$ourTemplate->setNewTemplate($templateName)) return FALSE; // Probably template not found if error
if (!$ourTemplate->setNewTemplate($templateName) && empty($emailData['template'])) return FALSE; // Probably template not found if error
if (!$ourTemplate->makeEmailBody($emailData['mail_body'], varset($emailData['mail_include_images'], TRUE))) return FALSE; // Create body text
$emailData['mail_body_templated'] = $ourTemplate->mainBodyText;
$this->currentMailBody = $emailData['mail_body_templated']; // In case we send immediately
@ -1507,6 +1511,17 @@ class e107MailManager
{
$emailData['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides'];
}
if(!empty($emailData['template'])) // Quick Fix for new email template standards.
{
$this->currentMailBody = $emailData['mail_body'];
unset($emailData['mail_body_templated']);
if($this->debugMode)
{
echo "<h4>".$emailData['template']." Template detected</h4>";
}
}
$forceQueue = FALSE;
@ -1516,6 +1531,13 @@ class e107MailManager
unset($extra['mail_force_queue']);
}
if($this->debugMode)
{
print_a($emailData);
print_a($recipientData);
}
if ((count($recipientData) <= 5) && !$forceQueue) // Arbitrary upper limit for sending multiple emails immediately
{
if ($this->mailer == NULL)
@ -1537,9 +1559,19 @@ class e107MailManager
if (FALSE == $this->mailer->sendEmail($recip['mail_recipient_email'], $recip['mail_recipient_name'], $mailToSend, TRUE))
{
$tempResult = FALSE;
if($this->debugMode)
{
echo "<h4>Failed to send to: ".$recip['mail_recipient_email']." [". $recip['mail_recipient_name'] ."]</h4>";
print_a($mailToSend);
}
}
else
{ // Success here
if($this->debugMode)
{
echo "<h4>Mail Sent successfully to: ".$recip['mail_recipient_email']." [". $recip['mail_recipient_name'] ."]</h4>";
print_a($mailToSend);
}
if ($eCount == 0)
{ // Only send these on first email - otherwise someone could get inundated!
unset($emailData['mail_copy_to']);

@ -147,16 +147,18 @@ class notify
// Create the mail body
$mailData = array(
'mail_content_status' => MAIL_STATUS_TEMP,
'mail_create_app' => 'notify',
'mail_title' => 'NOTIFY',
'mail_subject' => $subject,
'mail_sender_email' => e107::getPref('siteadminemail'),
'mail_sender_name' => e107::getPref('siteadmin'),
'mail_send_style' => 'textonly',
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
'mail_body' => $message
'mail_content_status' => MAIL_STATUS_TEMP,
'mail_create_app' => 'notify',
'mail_title' => 'NOTIFY',
'mail_subject' => $subject,
'mail_sender_email' => e107::getPref('siteadminemail'),
'mail_sender_name' => e107::getPref('siteadmin'),
// 'mail_send_style' => 'textonly',
'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
'mail_body' => $message,
'template' => 'notify'
);
$result = $mailer->sendEmails('NOTIFY_TEMPLATE', $mailData, $recipients);
$e107->admin_log->e_log_event(10,-1,'NOTIFY',$subject,$message,FALSE,LOG_TO_ROLLING);
}