You are here

function themekey_abstract_update_static_rule in ThemeKey 7.3

1 call to themekey_abstract_update_static_rule()
themekey_update_static_rule in ./themekey_build.inc
Adds or modifies a so-called static rule in the database. Static rules can be moved around in the chain and enabled or disabled by the site administrator, but the values are immutable. There's one static rule per static property.

File

./themekey_build.inc, line 544
The functions in this file are the back end of ThemeKey which should be used only if you configure something, but not when ThemeKey switches themes.

Code

function themekey_abstract_update_static_rule($table, $property, $state) {
  $existing_rule = db_select($table, 'tp')
    ->fields('tp', array(
    'id',
    'enabled',
    'parent',
  ))
    ->condition('property', $property)
    ->execute()
    ->fetchAssoc();
  if ($state) {
    $item = array(
      'property' => $property,
      'operator' => '=',
      'value' => 'static',
      'theme' => 'default',
    );
    if (!empty($existing_rule)) {
      $item['id'] = $existing_rule['id'];
      $item['enabled'] = $existing_rule['enabled'];
      $item['parent'] = $existing_rule['parent'];
    }
    else {

      // enable new rule
      $item['enabled'] = 1;
      $item['parent'] = 0;
    }
    themekey_abstract_rule_set($table, $item);
  }
  elseif (!empty($existing_rule)) {
    themekey_abstract_rule_del($table, $existing_rule['id']);
  }
}