diff --git a/includes/webform.emails.inc b/includes/webform.emails.inc index 016d124..894d223 100644 --- a/includes/webform.emails.inc +++ b/includes/webform.emails.inc @@ -280,6 +280,13 @@ function webform_email_edit_form($form, $form_state, $node, $email = array(), $c $form['from_name_component']['#access'] = FALSE; } + // Add the checkbox to disable the email for current recipients. + $form['disable'] = array( + '#title' => t('Disable sending emails for above recipients.'), + '#type' => 'checkbox', + '#default_value' => !empty($email['disable']) ? $email['disable'] : FALSE, + ); + // Add the template fieldset. $form['template'] = array( '#type' => 'fieldset', @@ -392,6 +399,7 @@ function theme_webform_email_edit_form($variables) { $details .= drupal_render($form['from_address_option']); $details .= drupal_render($form['from_address_mapping']); $details .= drupal_render($form['from_name_option']); + $form['details'] = array( '#type' => 'fieldset', '#title' => t('E-mail header details'), @@ -545,6 +553,8 @@ function webform_email_edit_form_submit($form, &$form_state) { $email['exclude_empty'] = empty($form_state['values']['exclude_empty']) ? 0 : 1; + $email['disable'] = empty($form_state['values']['disable']) ? 0 : 1; + if ($form_state['values']['clone']) { drupal_set_message(t('Email settings cloned.')); $form_state['values']['eid'] = webform_email_clone($email); @@ -627,6 +637,7 @@ function webform_email_load($eid, $nid) { 'html' => webform_variable_get('webform_default_format'), 'attachments' => 0, 'extra' => '', + 'disable' => '', ); } else { diff --git a/includes/webform.submissions.inc b/includes/webform.submissions.inc index a145b13..253da3d 100644 --- a/includes/webform.submissions.inc +++ b/includes/webform.submissions.inc @@ -232,6 +232,10 @@ function webform_submission_send_mail($node, $submission, $emails = NULL) { // Create a themed message for mailing. $send_count = 0; foreach ($emails as $eid => $email) { + // Continue with next email recipients array if disabled for current. + if ($email['disable']) + continue; + // Set the HTML property based on availablity of MIME Mail. $email['html'] = ($email['html'] && webform_variable_get('webform_email_html_capable')); diff --git a/webform.install b/webform.install index 65c5ac4..4e834df 100644 --- a/webform.install +++ b/webform.install @@ -491,6 +491,14 @@ function webform_schema() { 'type' => 'text', 'not null' => TRUE, ), + 'disable' => array( + 'description' => 'Disable sending email to current recipients.', + 'type' => 'int', + 'unsigned' => TRUE, + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + ), ), 'primary key' => array('nid', 'eid'), ); @@ -2260,3 +2268,21 @@ function webform_update_7429() { return t('Webforms will now resume draft submissions on the page where the submitter left off.'); } +/** + * Add a column to the emails table to disable the email sending for current recipients. + */ +function webform_update_7430() { + // Add disable column to webform_emails. + if (!db_field_exists('webform_emails', 'disable')) { + $spec = array( + 'description' => 'Disable sending email to current recipients.', + 'type' => 'int', + 'size' => 'small', + 'not null' => TRUE, + 'default' => 0, + ); + db_add_field('webform_emails', 'disable', $spec); + } + + return t('Webform emails may be configured to disabled now.'); +}