diff --git a/booking.MailSystemInterface.inc b/booking.MailSystemInterface.inc index 3a47793..5bcab02 100644 --- a/booking.MailSystemInterface.inc +++ b/booking.MailSystemInterface.inc @@ -15,7 +15,7 @@ class BookingMailSystem implements MailSystemInterface { */ public function format(array $message) { $message['body'] = implode("\n\n", $message['body']); - watchdog('booking_debug', "
BookingMailSystem format:\n@info
", array('@info' => print_r( $message, true))); + //watchdog('booking_debug', "
BookingMailSystem format:\n@info
", array('@info' => print_r( $message, true))); return $message; } @@ -39,7 +39,7 @@ class BookingMailSystem implements MailSystemInterface { preg_replace('@\r?\n@', $line_endings, $message['body']), join("\n", $mimeheaders) ); - watchdog('booking_debug', "
BookingMailSystem mail:\n@info
", array('@info' => print_r( $mail, true))); + //watchdog('booking_debug', "
BookingMailSystem mail:\n@info
", array('@info' => print_r( $mail, true))); return $mail; } } \ No newline at end of file diff --git a/booking.emails.inc b/booking.emails.inc index 9a41ce7..dedea3c 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -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'))) )); - //send the registering person an email + //calculate fields for email to be sent $to = $node->booking_email; - //$body = _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual); - //$params['body'] = $body; + if ($balance_payment == TRUE) { $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; - //apply a theme to the HTML body of the email - $html_body = theme('booking_htmlmail_registration_mail', - array( - 'module' => 'booking', - 'key' => 'registration_mail', - 'body' => _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual), - 'subject' => $subject, - )); - watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); - $params['body'] = $html_body; + //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' => _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual), + 'subject' => $subject, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", 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) { $params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); @@ -58,7 +63,8 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) { else { $params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY; } - + + //send the email to the person drupal_mail('booking', 'registration_mail', $to, $language, $params, $from); //send a notification email if we didn't automatically send one earlier @@ -155,7 +161,8 @@ function _booking_regn_notifyonly_email($node, $balance_payment) { function _booking_balance_payment_email($nid) { global $event; global $user; - $language = user_preferred_language($user); + $language = user_preferred_language($user); + $message_body = ""; //load the node matching this id $node = node_load($nid); @@ -188,12 +195,31 @@ function _booking_balance_payment_email($nid) { 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", 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 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', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $message_body; + } //send the email drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from); @@ -288,9 +314,31 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact') { else { $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', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $message_body; + } + //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 drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);