You are here

function advuser_update_7300 in Advanced User 7.3

Updating substitution tokens from D6 Token module to D7 tokens.

File

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

Code

function advuser_update_7300(&$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-raw]' => '[user:name:raw]',
    '[site-name]' => '[site:name]',
    '[account-url]' => '[user:edit-url]',
    '[mail]' => '[user:mail]',
    '[advuser-status]' => '[user:status]',
    '[advuser-theme]' => '[user:theme]',
    '[advuser-created]' => '[user:created]',
    '[advuser-language]' => '[user:language]',
    '[advuser-timezone]' => '[user:timezone]',
    '[advuser-signature]' => '[user:signature]',
    '[advuser-signature-raw]' => '[user: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.');
}