You are here

function i18n_variable_del in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_variable_del()
  2. 5 i18n.module \i18n_variable_del()
  3. 5.2 i18n.module \i18n_variable_del()
  4. 7 i18n_variable/i18n_variable.module \i18n_variable_del()

Unset a persistent multilingual variable.

Parameters

$name: The name of the variable to undefine.

$langcode: Optional language code. If not set it will delete the variable for all languages.

Related topics

1 call to i18n_variable_del()
i18n_variable_form_submit in ./i18n.module
Save multilingual variables and remove them from form.

File

./i18n.module, line 916
Internationalization (i18n) module.

Code

function i18n_variable_del($name, $langcode = NULL) {
  global $conf, $i18n_conf;
  if ($langcode) {
    db_query("DELETE FROM {i18n_variable} WHERE name = '%s' AND language='%s'", $name, $langcode);
    cache_clear_all('variables:' . $langcode, 'cache');
    unset($i18n_conf[$langcode][$name]);

    // If current language, unset also global conf
    if ($langcode == i18n_get_lang()) {
      unset($conf[$name]);
    }
  }
  else {
    db_query("DELETE FROM {i18n_variable} WHERE name = '%s'", $name);
    if (db_affected_rows()) {
      cache_clear_all('variables:', 'cache', TRUE);
      if (is_array($i18n_conf)) {
        foreach (array_keys($i18n_conf) as $lang) {
          unset($i18n_conf[$lang][$name]);
        }
      }
    }
  }
}