mailtemplate stored as json in variable table

This commit is contained in:
2017-09-15 15:00:28 +10:00
parent 19978d51f5
commit 8f1319c79a
4 changed files with 101 additions and 20 deletions

View File

@@ -1,5 +1,46 @@
<?php
/**
* Helper function to put together all the information for theming a HTML based email, if enabled
*
* @param
* @return themed message text
*/
function _booking_generate_html_body($subject, $body, $tokens) {
global $event;
$output_text = "";
//Check if we should apply a HTML theme to the email text or just send a normal email
if(variable_get('booking_enable_html_mail', 0) == 1) {
//get the footer text
$message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
$message_footer = token_replace($message_footer, $tokens);
$colors = json_decode(variable_get('booking_mailtemplate_colors'), TRUE);
$header_links = json_decode(variable_get('booking_mailtemplate_header_links'), TRUE);
$social_links = json_decode(variable_get('booking_mailtemplate_social_links'), TRUE);
$output_text = theme('booking_htmlmail_registration_mail',
array(
'module' => 'booking',
'key' => 'registration_mail',
'body' => $body,
'subject' => $subject,
'footer' => $message_footer,
'colors' => $colors,
'header_links' => $header_links,
'social_links' => $social_links,
));
}
else {
$output_text = $body;
}
watchdog('booking_debug', "<pre>HTML body themed\n@info</pre>", array('@info' => print_r($output_text, true)));
return $output_text;
}
/**
* Function to send email to registrant after completing registration process
*
@@ -41,6 +82,11 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) {
}
$params['subject'] = $subject;
$raw_body = _booking_registration_email_generate($node, $tokens, $waiting_list, $balance_payment, $manual);
$themed_body = _booking_generate_html_body($subject, $raw_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text
$message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -64,6 +110,7 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) {
$body = _booking_registration_email_generate($node, $tokens, $waiting_list, $balance_payment, $manual);
$params['body'] = $body;
}
*/
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));