send html emails for more mail types
This commit is contained in:
@@ -15,7 +15,7 @@ class BookingMailSystem implements MailSystemInterface {
|
|||||||
*/
|
*/
|
||||||
public function format(array $message) {
|
public function format(array $message) {
|
||||||
$message['body'] = implode("\n\n", $message['body']);
|
$message['body'] = implode("\n\n", $message['body']);
|
||||||
watchdog('booking_debug', "<pre>BookingMailSystem format:\n@info</pre>", array('@info' => print_r( $message, true)));
|
//watchdog('booking_debug', "<pre>BookingMailSystem format:\n@info</pre>", array('@info' => print_r( $message, true)));
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ class BookingMailSystem implements MailSystemInterface {
|
|||||||
preg_replace('@\r?\n@', $line_endings, $message['body']),
|
preg_replace('@\r?\n@', $line_endings, $message['body']),
|
||||||
join("\n", $mimeheaders)
|
join("\n", $mimeheaders)
|
||||||
);
|
);
|
||||||
watchdog('booking_debug', "<pre>BookingMailSystem mail:\n@info</pre>", array('@info' => print_r( $mail, true)));
|
//watchdog('booking_debug', "<pre>BookingMailSystem mail:\n@info</pre>", array('@info' => print_r( $mail, true)));
|
||||||
return $mail;
|
return $mail;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -29,10 +29,9 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
|||||||
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||||
));
|
));
|
||||||
|
|
||||||
//send the registering person an email
|
//calculate fields for email to be sent
|
||||||
$to = $node->booking_email;
|
$to = $node->booking_email;
|
||||||
//$body = _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual);
|
|
||||||
//$params['body'] = $body;
|
|
||||||
if ($balance_payment == TRUE) {
|
if ($balance_payment == TRUE) {
|
||||||
$subject = t('!event Payment Complete', array('!event' => $event->booking_eventname));
|
$subject = t('!event Payment Complete', array('!event' => $event->booking_eventname));
|
||||||
}
|
}
|
||||||
@@ -41,16 +40,22 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
|||||||
}
|
}
|
||||||
$params['subject'] = $subject;
|
$params['subject'] = $subject;
|
||||||
|
|
||||||
//apply a theme to the HTML body of the email
|
//Check if we should apply a HTML theme to the email text or just send a normal email
|
||||||
$html_body = theme('booking_htmlmail_registration_mail',
|
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||||
array(
|
$html_body = theme('booking_htmlmail_registration_mail',
|
||||||
'module' => 'booking',
|
array(
|
||||||
'key' => 'registration_mail',
|
'module' => 'booking',
|
||||||
'body' => _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual),
|
'key' => 'registration_mail',
|
||||||
'subject' => $subject,
|
'body' => _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual),
|
||||||
));
|
'subject' => $subject,
|
||||||
watchdog('booking_debug', "<pre>HTML body themed\n@info</pre>", array('@info' => print_r($html_body, true)));
|
));
|
||||||
$params['body'] = $html_body;
|
watchdog('booking_debug', "<pre>HTML body themed\n@info</pre>", array('@info' => print_r($html_body, true)));
|
||||||
|
$params['body'] = $html_body;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$body = _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual);
|
||||||
|
$params['body'] = $body;
|
||||||
|
}
|
||||||
|
|
||||||
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')));
|
||||||
@@ -59,6 +64,7 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
|||||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//send the email to the person
|
||||||
drupal_mail('booking', 'registration_mail', $to, $language, $params, $from);
|
drupal_mail('booking', 'registration_mail', $to, $language, $params, $from);
|
||||||
|
|
||||||
//send a notification email if we didn't automatically send one earlier
|
//send a notification email if we didn't automatically send one earlier
|
||||||
@@ -156,6 +162,7 @@ function _booking_balance_payment_email($nid) {
|
|||||||
global $event;
|
global $event;
|
||||||
global $user;
|
global $user;
|
||||||
$language = user_preferred_language($user);
|
$language = user_preferred_language($user);
|
||||||
|
$message_body = "";
|
||||||
|
|
||||||
//load the node matching this id
|
//load the node matching this id
|
||||||
$node = node_load($nid);
|
$node = node_load($nid);
|
||||||
@@ -188,11 +195,30 @@ function _booking_balance_payment_email($nid) {
|
|||||||
if (variable_get('booking_enable_combined_pricing', 0) == 1 && $node->booking_partner_id > 0) {
|
if (variable_get('booking_enable_combined_pricing', 0) == 1 && $node->booking_partner_id > 0) {
|
||||||
watchdog('booking', "Sending the married-couple specific outstanding balance email for this person: @info",
|
watchdog('booking', "Sending the married-couple specific outstanding balance email for this person: @info",
|
||||||
array('@info' => var_export($node, TRUE)));
|
array('@info' => var_export($node, TRUE)));
|
||||||
$params['body'] = token_replace(variable_get('booking_email_paymentoutstanding_married_text'), $tokens);
|
$message_body = variable_get('booking_email_paymentoutstanding_married_text');
|
||||||
}
|
}
|
||||||
//otherwise retrieve the body of the email for individuals
|
//otherwise retrieve the body of the email for individuals
|
||||||
else {
|
else {
|
||||||
$params['body'] = token_replace(variable_get('booking_email_paymentoutstanding_text'), $tokens);
|
$message_body = variable_get('booking_email_paymentoutstanding_text');
|
||||||
|
}
|
||||||
|
|
||||||
|
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||||
|
$message_body = token_replace($message_body, $tokens);
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
$html_body = theme('booking_htmlmail_registration_mail',
|
||||||
|
array(
|
||||||
|
'module' => 'booking',
|
||||||
|
'key' => 'registration_mail',
|
||||||
|
'body' => $message_body,
|
||||||
|
'subject' => $subject,
|
||||||
|
));
|
||||||
|
watchdog('booking_debug', "<pre>HTML body themed\n@info</pre>", array('@info' => print_r($html_body, true)));
|
||||||
|
$params['body'] = $html_body;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$params['body'] = $message_body;
|
||||||
}
|
}
|
||||||
|
|
||||||
//send the email
|
//send the email
|
||||||
@@ -289,8 +315,30 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact') {
|
|||||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the matching message text and replace any tokens needed
|
||||||
|
$message_body = variable_get($email_body_variable);
|
||||||
|
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||||
|
$message_body = token_replace($message_body, $tokens);
|
||||||
|
|
||||||
|
//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) {
|
||||||
|
$html_body = theme('booking_htmlmail_registration_mail',
|
||||||
|
array(
|
||||||
|
'module' => 'booking',
|
||||||
|
'key' => 'registration_mail',
|
||||||
|
'body' => $message_body,
|
||||||
|
'subject' => $subject,
|
||||||
|
));
|
||||||
|
watchdog('booking_debug', "<pre>HTML body themed\n@info</pre>", array('@info' => print_r($html_body, true)));
|
||||||
|
$params['body'] = $html_body;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$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);
|
||||||
|
|
||||||
//send the email to the person
|
//send the email to the person
|
||||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||||
|
Reference in New Issue
Block a user