make email generation more consistent

This commit is contained in:
2017-09-15 17:24:07 +10:00
parent d1f82c4ecb
commit 332dcabd52
2 changed files with 80 additions and 48 deletions

View File

@@ -161,11 +161,14 @@ function _booking_regn_notifyonly_email($node, $balance_payment) {
} }
$params['subject'] = $subject; $params['subject'] = $subject;
$body = variable_get('booking_email_notification_text'); $message_body = variable_get('booking_email_notification_text');
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$body = token_replace($body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -188,7 +191,7 @@ function _booking_regn_notifyonly_email($node, $balance_payment) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//$params['body'] = token_replace(variable_get('booking_email_notification_text'), $tokens); //$params['body'] = token_replace(variable_get('booking_email_notification_text'), $tokens);
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) { if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
@@ -265,9 +268,8 @@ function _booking_balance_payment_email($nid) {
//calculate the remaining parameters //calculate the remaining parameters
$to = $node->booking_email; $to = $node->booking_email;
$params['subject'] = token_replace(variable_get('booking_email_paymentoutstanding_subject', $subject = token_replace(variable_get('booking_email_paymentoutstanding_subject',
t('!event Payment Required', array('!event' => $event->booking_eventname))), $tokens); t('!event Payment Required', array('!event' => $event->booking_eventname))), $tokens);
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) { 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'))); $params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
} }
@@ -288,7 +290,11 @@ function _booking_balance_payment_email($nid) {
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$message_body = token_replace($message_body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['subject'] = $subject;
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -311,6 +317,7 @@ function _booking_balance_payment_email($nid) {
else { else {
$params['body'] = $message_body; $params['body'] = $message_body;
} }
*/
//send the email //send the email
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from); drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
@@ -353,7 +360,13 @@ function _booking_partialbalance_payment_email($nid) {
//TODO: Married couple version of this //TODO: Married couple version of this
$body = variable_get('booking_email_partialpayment_received_text'); $message_body = variable_get('booking_email_partialpayment_received_text');
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $body = isset($body['format']) ? $body['value'] : $body;
$body = token_replace($body, $tokens); $body = token_replace($body, $tokens);
@@ -380,6 +393,7 @@ function _booking_partialbalance_payment_email($nid) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//send the email //send the email
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from); drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
@@ -437,7 +451,10 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact') {
$message_body = variable_get($email_body_variable); $message_body = variable_get($email_body_variable);
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$message_body = token_replace($message_body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -460,7 +477,7 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact') {
else { else {
$params['body'] = $message_body; $params['body'] = $message_body;
} }
*/
//retrieve the body of the email //retrieve the body of the email
//$params['body'] = token_replace(variable_get($email_body_variable), $tokens); //$params['body'] = token_replace(variable_get($email_body_variable), $tokens);
@@ -505,11 +522,14 @@ function _booking_promoted_from_waitinglist_email($nid) {
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY; $params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
} }
$body = variable_get('booking_email_waitinglistpromotion'); $message_body = variable_get('booking_email_waitinglistpromotion');
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$body = token_replace($body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -532,6 +552,7 @@ function _booking_promoted_from_waitinglist_email($nid) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//retrieve the body of the email //retrieve the body of the email
//$params['body'] = token_replace(variable_get('booking_email_waitinglistpromotion'), $tokens); //$params['body'] = token_replace(variable_get('booking_email_waitinglistpromotion'), $tokens);
@@ -578,13 +599,14 @@ function _booking_demoted_to_notcoming_email($nid) {
} }
//retrieve the body of the email //retrieve the body of the email
//$params['body'] = token_replace(variable_get('booking_email_notcoming_demotion'), $tokens); $message_body = variable_get('booking_email_notcoming_demotion');
$body = variable_get('booking_email_notcoming_demotion');
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$body = token_replace($body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -607,6 +629,7 @@ function _booking_demoted_to_notcoming_email($nid) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//send the email //send the email
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
@@ -648,14 +671,16 @@ function _booking_missedpayment_email($nid) {
else { else {
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY; $params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
} }
//retrieve the body of the email //retrieve the body of the email
//$params['body'] = token_replace(variable_get('booking_email_missedpayment'), $tokens); $message_body = variable_get('booking_email_missedpayment');
$body = variable_get('booking_email_missedpayment');
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$body = token_replace($body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -678,6 +703,7 @@ function _booking_missedpayment_email($nid) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//send the email //send the email
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
@@ -721,13 +747,14 @@ function _booking_travelform_initial_request_email($nid) {
} }
//retrieve the body of the email //retrieve the body of the email
//$params['body'] = token_replace(variable_get('booking_email_travel_initial_email_text'), $tokens); $message_body = variable_get('booking_email_travel_initial_email_text');
$body = variable_get('booking_email_travel_initial_email_text');
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$body = token_replace($body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -750,6 +777,7 @@ function _booking_travelform_initial_request_email($nid) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//send the email //send the email
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
@@ -794,13 +822,14 @@ function _booking_travelform_reminder_request_email($nid) {
} }
//retrieve the body of the email //retrieve the body of the email
//$params['body'] = token_replace(variable_get('booking_email_travel_reminder_email_text'), $tokens); $message_body = variable_get('booking_email_travel_reminder_email_text');
$body = variable_get('booking_email_travel_reminder_email_text');
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$body = token_replace($body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -823,6 +852,7 @@ function _booking_travelform_reminder_request_email($nid) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//send the email //send the email
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
@@ -870,13 +900,14 @@ function _booking_travelform_confirmation_email($nid) {
} }
//retrieve the body of the email //retrieve the body of the email
//$params['body'] = token_replace(variable_get('booking_email_travel_complete_text'), $tokens); $message_body = variable_get('booking_email_travel_complete_text');
$body = variable_get('booking_email_travel_complete_text');
//Use the value of the field if it is an array from a HTML textarea //Use the value of the field if it is an array from a HTML textarea
$body = isset($body['format']) ? $body['value'] : $body; $message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
$body = token_replace($body, $tokens); $message_body = token_replace($message_body, $tokens);
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
$params['body'] = $themed_body;
/*
//get the footer text //get the footer text
$message_footer = variable_get('booking_html_mail_footer'); $message_footer = variable_get('booking_html_mail_footer');
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; $message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
@@ -899,6 +930,7 @@ function _booking_travelform_confirmation_email($nid) {
else { else {
$params['body'] = $body; $params['body'] = $body;
} }
*/
//send the email //send the email
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);

View File

@@ -20,7 +20,7 @@
$social_links = json_decode(variable_get('booking_mailtemplate_social_links'), TRUE); $social_links = json_decode(variable_get('booking_mailtemplate_social_links'), TRUE);
//watchdog('booking_debug', "<pre>Mail template navigation links loaded\n@info</pre>", array('@info' => print_r($header_links, true))); //watchdog('booking_debug', "<pre>Mail template navigation links loaded\n@info</pre>", array('@info' => print_r($header_links, true)));
watchdog('booking_debug', "<pre>Mail template social links loaded\n@info</pre>", array('@info' => print_r($social_links, true))); //watchdog('booking_debug', "<pre>Mail template social links loaded\n@info</pre>", array('@info' => print_r($social_links, true)));
$form['colors'] = array( $form['colors'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',