You are here

function vars_node_type in Variable API 6.2

Same name and namespace in other branches
  1. 6 vars.module \vars_node_type()

Implements hook_node_type().

File

./vars.module, line 583
Implement an API to handle persistent variables.

Code

function vars_node_type($op, $info) {
  global $conf;
  $variables = array();
  if ($op == 'delete') {
    $variables = Vars::loadDefaults('node_type', "flags = %d", Vars::VARS_NODE_TYPE);
    if (array_key_exists('dynamic', $variables)) {
      foreach (array_keys($variables['dynamic']) as $var) {
        $name = $var . '_' . $info->type;
        unset($conf[$name]);
        $variables[] = $name;
      }
    }
    if (!empty($variables)) {
      db_query("DELETE FROM {variable} WHERE name IN (" . db_placeholders($variables, 'varchar') . ")", variables);
      cache_clear_all('variables', 'cache');
    }
  }
}