662 lines
26 KiB
PHP
662 lines
26 KiB
PHP
<?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
|
|
*
|
|
* @param $nid - the node id relating to the registration node
|
|
* @return nothing
|
|
*/
|
|
function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
//$account = $user;
|
|
|
|
//flush cache for this node
|
|
entity_get_controller('node')->resetCache(array($nid));
|
|
|
|
//load the node matching this id
|
|
$node = node_load($nid);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
watchdog('booking', 'Sending registration email to !first !last',
|
|
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
|
|
|
//waiting list has already been calculated, stored in node
|
|
$waiting_list = $node->booking_status == 2 ? TRUE : FALSE;
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate fields for email to be sent
|
|
$to = $node->booking_email;
|
|
|
|
if ($balance_payment == TRUE) {
|
|
$subject = t('!event Payment Complete', array('!event' => $event->booking_eventname));
|
|
}
|
|
else {
|
|
$subject = t('!event Registration', array('!event' => $event->booking_eventname));
|
|
}
|
|
$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;
|
|
|
|
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')));
|
|
}
|
|
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
|
|
if (variable_get('booking_auto_confirm_email', 0) == 1) {
|
|
_booking_regn_notifyonly_email($node, $balance_payment);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Function to send notification email only, nothing to the end user
|
|
*
|
|
* @param $node - variable representing the booking node
|
|
* @return nothing
|
|
*/
|
|
function _booking_regn_notifyonly_email($node, $balance_payment) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
watchdog('booking', 'Sending notification email about !first !last',
|
|
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//just put the registration info in this email to notify the appropriate people
|
|
$to = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
|
|
|
if ($balance_payment == TRUE) {
|
|
$subject = t('Registration Fully Paid: !first !last',
|
|
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
|
}
|
|
else {
|
|
$subject = t('New Registration: !first !last',
|
|
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
|
}
|
|
$params['subject'] = $subject;
|
|
|
|
$message_body = variable_get('booking_email_notification_text');
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$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;
|
|
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
drupal_mail('booking', 'registration_mail_notify', $to, $language, $params, $from);
|
|
}
|
|
|
|
/**
|
|
* Function to generate email text to be sent to registrant after completing registration process
|
|
*
|
|
* @param $node - the registration node
|
|
* @param $booking_count - the number of bookings already made for this event id
|
|
* @param $waiting_list - whether this registration is on on the waiting list
|
|
* @return array containing email text
|
|
*/
|
|
function _booking_registration_email_generate($node, $tokens, $waiting_list, $balance_payment, $manual) {
|
|
global $event;
|
|
//$tokens = booking_define_personspecific_tokens($node);
|
|
$body = "";
|
|
|
|
if ($balance_payment == True) {
|
|
$body = variable_get('booking_email_regn_complete_text');
|
|
//$contact_message = token_replace(variable_get('booking_email_regn_complete_text'), $tokens);
|
|
}
|
|
elseif ($waiting_list == False) {
|
|
$body = variable_get('booking_email_bookedin_text');
|
|
//$contact_message = token_replace(variable_get('booking_email_bookedin_text'), $tokens);
|
|
}
|
|
else {
|
|
//booking is on the waiting list
|
|
$body = variable_get('booking_email_waitinglist_text');
|
|
//$contact_message = token_replace(variable_get('booking_email_waitinglist_text'), $tokens);
|
|
}
|
|
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$body = isset($body['format']) ? $body['value'] : $body;
|
|
//watchdog('booking_debug', "<pre>Email generation:\n@info</pre>", array('@info' => print_r( $body, true)));
|
|
//$contact_message .= "\n\n" . t("!details", array('!details' => _booking_details_email_summary($node)));
|
|
return token_replace($body, $tokens);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Function to generate email to be sent to the registrant to remind them of how much they owe, and include a payment link
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_balance_payment_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
$message_body = "";
|
|
|
|
//load the node matching this id
|
|
$node = node_load($nid);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
if ($tokens['payment-required'] <= 0) {
|
|
drupal_set_message(t("Ignore below status - didn't send unnecessary balance outstanding email to: !person",
|
|
array('!person' => $node->booking_firstname . ' ' . $node->booking_lastname)));
|
|
watchdog('booking', "Not sending amount owing email, since this person doesn't owe any money: @info",
|
|
array('@info' => var_export($node, TRUE)));
|
|
return;
|
|
}
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = token_replace(variable_get('booking_email_paymentoutstanding_subject',
|
|
t('!event Payment Required', array('!event' => $event->booking_eventname))), $tokens);
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
//retrieve the body of the email for a married couple only if we're combining pricing for couples
|
|
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)));
|
|
$message_body = variable_get('booking_email_paymentoutstanding_married_text');
|
|
}
|
|
//otherwise retrieve the body of the email for individuals
|
|
else {
|
|
$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);
|
|
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
|
$params['subject'] = $subject;
|
|
$params['body'] = $themed_body;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
|
|
}
|
|
|
|
/**
|
|
* Function to generate email to be sent to the registrant thanking them for a partial balance payment
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_partialbalance_payment_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//load the node matching this id
|
|
$node = node_load($nid);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
if ($tokens['payment-required'] <= 0) {
|
|
watchdog('booking', "Not sending amount owing email, since this person doesn't owe any money: @info", array('@info' => var_export($node, TRUE)));
|
|
return;
|
|
}
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = t('!event Partial Payment Received', array('!event' => $event->booking_eventname));
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
//TODO: Married couple version of this
|
|
|
|
$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;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
|
|
}
|
|
|
|
|
|
/**
|
|
* Function to generate email to be sent to the registrant based on custom email template configured in text tokens page
|
|
*
|
|
* @param $nid - the registration node
|
|
* @param $email_type - select which custom email template to use
|
|
* @return nothing
|
|
*/
|
|
function _booking_custom_email($nid, $email_type, $sender = 'contact') {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//calculate the drupal variables to use
|
|
$email_subject_variable = 'booking_email_subject_' . $email_type;
|
|
$email_body_variable = 'booking_email_' . $email_type;
|
|
|
|
if ($sender == 'contact') {
|
|
//watchdog('booking', 'Sending a custom email from the contact email address.');
|
|
//calculate the from email address for a contact email
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
}
|
|
elseif ($sender == 'logistics') {
|
|
watchdog('booking_debug', "<pre>Custom logistics email\n@subject\n@body</pre>",
|
|
array('@subject' => $email_subject_variable, '@body' => $email_body_variable));
|
|
//calculate the from email address for a logistics email
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
}
|
|
|
|
//load the node matching this id
|
|
$node = node_load($nid);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = token_replace(variable_get($email_subject_variable, t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
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);
|
|
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
|
$params['body'] = $themed_body;
|
|
|
|
//send the email to the person
|
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
|
}
|
|
|
|
/**
|
|
* Function to generate email to be sent to the registrant once they move from the waiting list to the coming list
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_promoted_from_waitinglist_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//return without doing anything if we shouldn't send workflow emails
|
|
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
|
watchdog('booking', 'Not sending promoted-from-waitinglist email since that feature is currently disabled.');
|
|
return;
|
|
}
|
|
|
|
//load the node matching this id
|
|
$node = node_load($nid);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = t('!event Position Available', array('!event' => $event->booking_eventname));
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
if ($tokens['payment-required'] == 0) {
|
|
watchdog('booking_debug', 'This person has fully paid so sending promoted-from-waitinglist-fullypaid email.');
|
|
$message_body = variable_get('booking_email_waitinglistpromotion_fullypaid');
|
|
}
|
|
else {
|
|
watchdog('booking_debug', 'This person has an outstanding balance of ' . $tokens['payment-required']);
|
|
$message_body = variable_get('booking_email_waitinglistpromotion');
|
|
}
|
|
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$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;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
|
}
|
|
|
|
/**
|
|
* Function to generate email to be sent to the attendee once they pull out and move to the not-coming list
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_demoted_to_notcoming_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//return without doing anything if we shouldn't send workflow emails
|
|
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
|
watchdog('booking', 'Not sending not-coming email since that feature is currently disabled.');
|
|
return;
|
|
}
|
|
|
|
//load the node matching this id
|
|
$node = node_load($nid);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = token_replace(variable_get('booking_email_notcoming_demotion_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
|
//$subject = t('!event withdrawal confirmation', array('!event' => $event->booking_eventname));
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
//retrieve the body of the email
|
|
$message_body = variable_get('booking_email_notcoming_demotion');
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$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;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
|
}
|
|
|
|
/**
|
|
* Function to generate email to be sent to the attendee if they miss the payment deadline
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_missedpayment_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//return without doing anything if we shouldn't send workflow emails
|
|
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
|
watchdog('booking', 'Not sending missed-payment email since that feature is currently disabled.');
|
|
return;
|
|
}
|
|
|
|
//load the node matching this id
|
|
$node = node_load($nid);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = token_replace(variable_get('booking_email_missedpayment_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
|
//$subject = t('!event withdrawal confirmation', array('!event' => $event->booking_eventname));
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
//retrieve the body of the email
|
|
$message_body = variable_get('booking_email_missedpayment');
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$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;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
|
}
|
|
|
|
/**
|
|
* Function to generate email to be sent to the attendee with the _initial_ request to complete their travel form
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_travelform_initial_request_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//return without doing anything if we shouldn't send workflow emails
|
|
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
|
watchdog('booking', 'Not sending travelform initial request email since that feature is currently disabled.');
|
|
return;
|
|
}
|
|
|
|
//load the node matching this id from the database, ignoring the cache
|
|
$node = node_load($nid, NULL, TRUE);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Travel <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = token_replace(variable_get('booking_email_travel_initial_email_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
|
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
//retrieve the body of the email
|
|
$message_body = variable_get('booking_email_travel_initial_email_text');
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$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;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
|
}
|
|
|
|
|
|
/**
|
|
* Function to generate email to be sent to the attendee with the _reminder_ request to complete their travel form
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_travelform_reminder_request_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//return without doing anything if we shouldn't send workflow emails
|
|
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
|
watchdog('booking', 'Not sending travelform reminder request email since that feature is currently disabled.');
|
|
return;
|
|
}
|
|
|
|
//load the node matching this id from the database, ignoring the cache
|
|
$node = node_load($nid, NULL, TRUE);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Travel <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = token_replace(variable_get('booking_email_travel_reminder_email_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
|
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
//retrieve the body of the email
|
|
$message_body = variable_get('booking_email_travel_reminder_email_text');
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$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;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
|
}
|
|
|
|
|
|
/**
|
|
* Function to generate email to be sent to the attendee once they complete their travel form
|
|
*
|
|
* @param $nid - the registration node
|
|
*/
|
|
function _booking_travelform_confirmation_email($nid) {
|
|
global $event;
|
|
global $user;
|
|
$language = user_preferred_language($user);
|
|
|
|
//return without doing anything if we shouldn't send workflow emails
|
|
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
|
watchdog('booking', 'Not sending travelform confirmation email since that feature is currently disabled.');
|
|
return;
|
|
}
|
|
|
|
//load the node matching this id from the database, ignoring the cache
|
|
$node = node_load($nid, NULL, TRUE);
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
watchdog('booking', 'Sending travelform confirmation email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
|
|
|
//calculate the from email address
|
|
$from = t('!event Travel <!email>', array('!event' => $event->booking_eventname,
|
|
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
|
));
|
|
|
|
//calculate the remaining parameters
|
|
$to = $node->booking_email;
|
|
$subject = token_replace(variable_get('booking_email_travel_complete_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
|
//$subject = t('!event Travel Details Received', array('!event' => $event->booking_eventname));
|
|
|
|
$params['subject'] = $subject;
|
|
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')));
|
|
}
|
|
else {
|
|
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
|
}
|
|
|
|
//retrieve the body of the email
|
|
$message_body = variable_get('booking_email_travel_complete_text');
|
|
//Use the value of the field if it is an array from a HTML textarea
|
|
$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;
|
|
|
|
//send the email
|
|
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
|
}
|
|
|