? enable-disable.patch Index: reroute_email.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/reroute_email/reroute_email.module,v retrieving revision 1.6 diff -u -p -r1.6 reroute_email.module --- reroute_email.module 24 Jul 2008 14:32:35 -0000 1.6 +++ reroute_email.module 28 Dec 2009 11:03:08 -0000 @@ -3,6 +3,7 @@ // $Id: reroute_email.module,v 1.6 2008/07/24 14:32:35 kbahey Exp $ define('REROUTE_EMAIL_ADDRESS', 'reroute_email_address'); +define('REROUTE_ENABLE_ROUTING', 'reroute_enable_routing'); /** * Implementation of hook_perm(). @@ -34,38 +35,48 @@ function reroute_email_settings() { '#size' => 35, '#description' => t('The email address to reroute all emails from the site to.') ); + + $form[REROUTE_ENABLE_ROUTING] = array( + '#type' => 'checkbox', + '#title' => t('Enable routing'), + '#required' => TRUE, + '#default_value' => variable_get(REROUTE_ENABLE_ROUTING, 1), + '#description' => t('Check this box if you want to enable email rerouting. Uncheck to disable rerouting.'), + ); return system_settings_form($form); } function reroute_email_mail_alter(&$message) { - global $base_url; + if (variable_get(REROUTE_ENABLE_ROUTING, 1)) { + global $base_url; - if (!empty($message) && is_array($message)) { - $mailkey = isset($message['id']) ? $message['id'] : t(' is missing'); - $to = isset($message['to']) ? $message['to'] : t(' is missing'); - // Suppress Bcc and Cc fields otherwise email will still go out to those addresses - if (isset($message['headers']) && is_array($message['headers'])) { - if (isset($message['headers']['Bcc'])) { - unset($message['headers']['Bcc']); - } - if (isset($message['headers']['Cc'])) { - unset($message['headers']['Cc']); + if (!empty($message) && is_array($message)) { + $mailkey = isset($message['id']) ? $message['id'] : t(' is missing'); + $to = isset($message['to']) ? $message['to'] : t(' is missing'); + // Suppress Bcc and Cc fields otherwise email will still go out to those addresses + if (isset($message['headers']) && is_array($message['headers'])) { + if (isset($message['headers']['Bcc'])) { + unset($message['headers']['Bcc']); + } + if (isset($message['headers']['Cc'])) { + unset($message['headers']['Cc']); + } } } - } - // Format a message to show at the top - $msg[] = t("This email was rerouted."); - $msg[] = t("Web site: @site", array('@site' => $base_url)); - $msg[] = t("Mail key: @key", array('@key' => $mailkey)); - $msg[] = t("Originally to: <@to>", array('@to' => $to)); - $msg[] = "-----------------------"; + // Format a message to show at the top + $msg[] = t("This email was rerouted."); + $msg[] = t("Web site: @site", array('@site' => $base_url)); + $msg[] = t("Mail key: @key", array('@key' => $mailkey)); + $msg[] = t("Originally to: <@to>", array('@to' => $to)); + $msg[] = "-----------------------"; - // Prepend to the body of the email - $message['body'] = array_merge($msg, isset($message['body']) ? (is_array($message['body']) ? $message['body'] : array($message['body'])) : array()); + // Prepend to the body of the email + $message['body'] = array_merge($msg, isset($message['body']) ? (is_array($message['body']) ? $message['body'] : array($message['body'])) : array()); - // Change the $to address to be the one we defined - $message['to'] = variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from')); + // Change the $to address to be the one we defined + $message['to'] = variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from')); + } }