You are here

function reroute_email_update_7001 in Reroute Email 7

Implements hook_update_N().

Now we have a separate fields for `Rerouting email addresses` and `Whitelisted email addresses`. Previously all emails was rerouted to the first email from `Rerouting email addresses`.

File

./reroute_email.install, line 54
Reroute Email module installation functions.

Code

function reroute_email_update_7001() {
  module_load_include('module', 'reroute_email');

  // Do not update values if the user sets them manually already.
  // `Whitelisted addresses` is a new variable, so it couldn't exist before.
  if (NULL !== variable_get(REROUTE_EMAIL_WHITELIST)) {
    return NULL;
  }

  // Update whitelisted email addresses value.
  $addresses = variable_get(REROUTE_EMAIL_ADDRESS);
  variable_set(REROUTE_EMAIL_WHITELIST, $addresses);

  // Update rerouting email addresses value.
  $addresses = reroute_email_split_string($addresses);
  variable_set(REROUTE_EMAIL_ADDRESS, !empty($addresses[0]) ? $addresses[0] : '');

  // Return a message to the user.
  return t('Reroute email module updates completed successfully. Please visit configuration page to check.');
}