From 97bd469d989c4f041b3928f62257026faafe1796 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sat, 12 Sep 2015 09:38:28 +1000 Subject: [PATCH] Added option to include notify email address as BCC --- booking.admin.inc | 7 ++++ booking.emails.inc | 81 +++++++++++++++++++++++++++++++++++-------- booking.regn_form.inc | 9 ++++- 3 files changed, 82 insertions(+), 15 deletions(-) diff --git a/booking.admin.inc b/booking.admin.inc index 00dcfdb..b795f3c 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -231,6 +231,13 @@ function booking_admin() { '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_auto_workflow_email', 0), ); + $form['misc']['booking_bcc_notify_email_workflow'] = array ( + '#type' => 'radios', + '#title' => t('Include notification email address on outgoing workflow emails?'), + '#description' => t('Send a BCC of any workflow email generated to the notification email address as well'), + '#options' => array (0 => t('No'), t('Yes')), + '#default_value' => variable_get('booking_bcc_notify_email_workflow', 0), + ); $form['misc']['booking_auto_show_on_lists'] = array ( '#type' => 'radios', '#title' => t('Show on lists once booked in?'), diff --git a/booking.emails.inc b/booking.emails.inc index 2ca15a6..80eb8e3 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -248,7 +248,14 @@ function booking_manual_email_submit($form, &$form_state) { $params['subject'] = $subject; $params['body'] = $body; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } + drupal_mail('booking', 'registration_mail', $to, $language, $params, $from); //drupal_mail('booking', 'registration_mail', 'it@coadcorp.com', $language, $params, $from); @@ -290,7 +297,14 @@ function booking_manual_email_submit($form, &$form_state) { //$params['body'] = _booking_details_email_summary($node); $params['body'] = token_replace(variable_get('booking_email_notification_text'), $tokens); - $params['headers']['Bcc'] = "it@coadcorp.com"; + + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } + drupal_mail('booking', 'registration_mail_notify', $to, $language, $params, $from); } @@ -359,8 +373,14 @@ function _booking_balance_payment_email($nid) //$params['subject'] = $subject; $params['subject'] = token_replace(variable_get('booking_email_paymentoutstanding_subject', t('!event Payment Required', array('!event' => $event->booking_eventname))), $tokens); - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); - + + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } + //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) { @@ -374,8 +394,7 @@ function _booking_balance_payment_email($nid) } //send the email - drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from); - //$params['headers']['Bcc'] = "it@coadcorp.com"; + drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from); } /** @@ -408,7 +427,12 @@ function _booking_partialbalance_payment_email($nid) $to = $node->booking_email; $subject = t('!event Partial Payment Received', array('!event' => $event->booking_eventname)); $params['subject'] = $subject; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } //TODO: Married couple version of this $params['body'] = token_replace(variable_get('booking_email_partialpayment_received_text'), $tokens); @@ -447,7 +471,12 @@ function _booking_custom_email($nid, $email_type) $to = $node->booking_email; $subject = token_replace(variable_get($email_subject_variable, t('!event', array('!event' => $event->booking_eventname))), $tokens); $params['subject'] = $subject; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } //retrieve the body of the email $params['body'] = token_replace(variable_get($email_body_variable), $tokens); @@ -488,7 +517,12 @@ function _booking_promoted_from_waitinglist_email($nid) $to = $node->booking_email; $subject = t('!event Position Available', array('!event' => $event->booking_eventname)); $params['subject'] = $subject; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } //retrieve the body of the email $params['body'] = token_replace(variable_get('booking_email_waitinglistpromotion'), $tokens); @@ -529,7 +563,12 @@ function _booking_demoted_to_notcoming_email($nid) $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; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } //retrieve the body of the email $params['body'] = token_replace(variable_get('booking_email_notcoming_demotion'), $tokens); @@ -570,8 +609,12 @@ function _booking_missedpayment_email($nid) $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; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); - + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } //retrieve the body of the email $params['body'] = token_replace(variable_get('booking_email_missedpayment'), $tokens); @@ -613,7 +656,12 @@ function _booking_travelform_request_email($nid) $subject = token_replace(variable_get('booking_email_travel_required_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens); $params['subject'] = $subject; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } //retrieve the body of the email $params['body'] = token_replace(variable_get('booking_email_travel_required_text'), $tokens); @@ -657,7 +705,12 @@ function _booking_travelform_confirmation_email($nid) //$subject = t('!event Travel Details Received', array('!event' => $event->booking_eventname)); $params['subject'] = $subject; - $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from'))); + if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) + { + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + } else { + $params['headers']['Bcc'] = "it@coadcorp.com"; + } //retrieve the body of the email $params['body'] = token_replace(variable_get('booking_email_travel_complete_text'), $tokens); diff --git a/booking.regn_form.inc b/booking.regn_form.inc index 9eb66fc..194659b 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -552,7 +552,8 @@ function booking_form($node, &$form_state, $inserting = FALSE) { '#title' => t('Your Medicare Number'), '#maxlength' => 15, '#size' => 15, - '#required' => variable_get('booking_enforce_medicare_verification', 1) == 1 ? TRUE : FALSE, + '#required' => FALSE, + //'#required' => variable_get('booking_enforce_medicare_verification', 1) == 1 ? TRUE : FALSE, '#default_value' => empty($data->booking_medicare) ? '' : $data->booking_medicare ); } @@ -1158,6 +1159,12 @@ function _booking_validate($node, &$form_state) { } } } + + //verify international address has updated the state field + if ((strcasecmp($form_state['booking_country'], 'Australia') !== 0) && (strcasecmp($form_state['booking_state'], 'Other') !== 0)) + { + form_set_error('booking_state', t('You must enter your State in the address section of the Contact details. Please choose a state of Other and specify N/A if your country does not have states.')); + } //verify passport number if (variable_get('booking_enable_passport', 0) == 1 && $form_state['booking_country'] == 'Australia')