You are here

function advuser_update_6300 in Advanced User 7.3

Same name and namespace in other branches
  1. 6.3 advuser.install \advuser_update_6300()

Updating substitution tokens from Advanced User module only tokens to Token module tokens.

File

./advuser.install, line 78
Supply the hooks for uninstall.

Code

function advuser_update_6300(&$sandbox) {
  if (empty($sandbox['step'])) {
    $sandbox['step'] = 1;
  }
  $variables_to_update = array(
    'advuser_modify_mail',
    'advuser_modify_subject',
    'advuser_new_mail',
    'advuser_new_subject',
  );
  $token_substitutions = array(
    '%user_name' => '[user-raw]',
    '%site' => '[site-name]',
    '%uri' => '[account-url]',
    '%user_email' => '[mail]',
    '%user_status' => '[advuser-status]',
    '%user_theme' => '[advuser-theme]',
    '%user_created' => '[advuser-created]',
    '%user_language' => '[advuser-language]',
    '%user_timezone' => '[advuser-timezone]',
    '%user_signature' => '[advuser-signature-raw]',
  );
  foreach ($variables_to_update as $variable) {
    $sandbox['step']++;
    $current = variable_get($variable, "");
    if (strlen($current) == 0) {
      continue;
    }
    $new = str_replace(array_keys($token_substitutions), array_values($token_substitutions), $current);
    variable_set($variable, $new);
  }
  return t('Advuser token module requirement updates have completed.');
}