diff --git a/booking.emails.inc b/booking.emails.inc index 766a630..dca23a8 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -111,6 +111,11 @@ function _booking_regn_notifyonly_email($node, $balance_payment) { $body = isset($body['format']) ? $body['value'] : $body; $body = token_replace($body, $tokens); + //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); + //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', @@ -119,6 +124,7 @@ function _booking_regn_notifyonly_email($node, $balance_payment) { 'key' => 'registration_mail_notify', 'body' => $body, 'subject' => $subject, + 'footer' => $message_footer, )); watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); $params['body'] = $html_body; @@ -225,7 +231,12 @@ function _booking_balance_payment_email($nid) { } $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); + + //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); //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) { @@ -235,7 +246,8 @@ function _booking_balance_payment_email($nid) { 'key' => 'registration_mail_bal_outstanding', 'body' => $message_body, 'subject' => $subject, - )); + 'footer' => $message_footer, + )); watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); $params['body'] = $html_body; } @@ -283,7 +295,33 @@ function _booking_partialbalance_payment_email($nid) { } //TODO: Married couple version of this - $params['body'] = token_replace(variable_get('booking_email_partialpayment_received_text'), $tokens); + + $body = variable_get('booking_email_partialpayment_received_text'); + //Use the value of the field if it is an array from a HTML textarea + $body = isset($body['format']) ? $body['value'] : $body; + $body = token_replace($body, $tokens); + + //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); + + //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_bal_outstanding', + 'body' => $body, + 'subject' => $subject, + 'footer' => $message_footer, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $body; + } //send the email drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from); @@ -344,7 +382,8 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact') { //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 = isset($message_footer['format']) ? $message_footer['value'] : $message_footer; + $message_footer = token_replace($message_footer, $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) { @@ -406,9 +445,36 @@ function _booking_promoted_from_waitinglist_email($nid) { else { $params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY; } + + $body = variable_get('booking_email_waitinglistpromotion'); + //Use the value of the field if it is an array from a HTML textarea + $body = isset($body['format']) ? $body['value'] : $body; + $body = token_replace($body, $tokens); + + //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); + + //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' => 'booking_email_custom', + 'body' => $body, + 'subject' => $subject, + 'footer' => $message_footer, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $body; + } //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); //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); @@ -452,7 +518,34 @@ function _booking_demoted_to_notcoming_email($nid) { } //retrieve the body of the email - $params['body'] = token_replace(variable_get('booking_email_notcoming_demotion'), $tokens); + //$params['body'] = token_replace(variable_get('booking_email_notcoming_demotion'), $tokens); + + $body = variable_get('booking_email_notcoming_demotion'); + //Use the value of the field if it is an array from a HTML textarea + $body = isset($body['format']) ? $body['value'] : $body; + $body = token_replace($body, $tokens); + + //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); + + //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' => 'booking_email_custom', + 'body' => $body, + 'subject' => $subject, + 'footer' => $message_footer, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $body; + } //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); @@ -495,7 +588,34 @@ function _booking_missedpayment_email($nid) { $params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY; } //retrieve the body of the email - $params['body'] = token_replace(variable_get('booking_email_missedpayment'), $tokens); + //$params['body'] = token_replace(variable_get('booking_email_missedpayment'), $tokens); + + $body = variable_get('booking_email_missedpayment'); + //Use the value of the field if it is an array from a HTML textarea + $body = isset($body['format']) ? $body['value'] : $body; + $body = token_replace($body, $tokens); + + //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); + + //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' => 'booking_email_custom', + 'body' => $body, + 'subject' => $subject, + 'footer' => $message_footer, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $body; + } //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); @@ -539,7 +659,34 @@ function _booking_travelform_initial_request_email($nid) { } //retrieve the body of the email - $params['body'] = token_replace(variable_get('booking_email_travel_initial_email_text'), $tokens); + //$params['body'] = token_replace(variable_get('booking_email_travel_initial_email_text'), $tokens); + + $body = variable_get('booking_email_travel_initial_email_text'); + //Use the value of the field if it is an array from a HTML textarea + $body = isset($body['format']) ? $body['value'] : $body; + $body = token_replace($body, $tokens); + + //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); + + //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' => 'booking_email_custom', + 'body' => $body, + 'subject' => $subject, + 'footer' => $message_footer, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $body; + } //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); @@ -584,7 +731,34 @@ function _booking_travelform_reminder_request_email($nid) { } //retrieve the body of the email - $params['body'] = token_replace(variable_get('booking_email_travel_reminder_email_text'), $tokens); + //$params['body'] = token_replace(variable_get('booking_email_travel_reminder_email_text'), $tokens); + + $body = variable_get('booking_email_travel_reminder_email_text'); + //Use the value of the field if it is an array from a HTML textarea + $body = isset($body['format']) ? $body['value'] : $body; + $body = token_replace($body, $tokens); + + //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); + + //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' => 'booking_email_custom', + 'body' => $body, + 'subject' => $subject, + 'footer' => $message_footer, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $body; + } //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); @@ -632,7 +806,34 @@ function _booking_travelform_confirmation_email($nid) { } //retrieve the body of the email - $params['body'] = token_replace(variable_get('booking_email_travel_complete_text'), $tokens); + //$params['body'] = token_replace(variable_get('booking_email_travel_complete_text'), $tokens); + + $body = variable_get('booking_email_travel_complete_text'); + //Use the value of the field if it is an array from a HTML textarea + $body = isset($body['format']) ? $body['value'] : $body; + $body = token_replace($body, $tokens); + + //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); + + //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' => 'booking_email_custom', + 'body' => $body, + 'subject' => $subject, + 'footer' => $message_footer, + )); + watchdog('booking_debug', "
HTML body themed\n@info
", array('@info' => print_r($html_body, true))); + $params['body'] = $html_body; + } + else { + $params['body'] = $body; + } //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);