You are here

function _simplenews_convert_tokens_in_variable in Simplenews 7.2

Same name and namespace in other branches
  1. 7 simplenews.install \_simplenews_convert_tokens_in_variable()

Helper function to convert tokens in variables to D7 format.

1 call to _simplenews_convert_tokens_in_variable()
simplenews_update_7000 in ./simplenews.install
Create table {simplenews_category} to replace taxonomy terms. Migrate Newsletter taxonomy data to Newsletter categories.

File

./simplenews.install, line 417
Install, update and uninstall functions for the simplenews module

Code

function _simplenews_convert_tokens_in_variable($variables) {
  if (!is_array($variables)) {
    $variables = array(
      $variables,
    );
  }
  $old = array(
    '[site-name]',
    '[user-mail]',
    '[site-url]/user',
    '[site-url]',
    '[simplenews-subscribe-url]',
    '[simplenews-unsubscribe-url]',
    '[simplenews-newsletter-url]',
    '[simplenews-newsletters-name]',
    '[simplenews-newsletters-url]',
    '[simplenews-receiver-mail]',
  );
  $new = array(
    '[site:name]',
    '[user:mail]',
    '[site:login-url]',
    '[site:url]',
    '[simplenews-subscriber:subscribe-url]',
    '[simplenews-subscriber:unsubscribe-url]',
    '[simplenews-newsletter:url]',
    '[simplenews-list:name]',
    '[simplenews-list:url]',
    '[simplenews-subscriber:mail]',
  );
  foreach ($variables as $variable) {
    if ($text = variable_get($variable, FALSE)) {
      $text = str_replace($old, $new, $text);
      variable_set($variable, $text);
    }
  }
}