You are here

function themekey_update_static_rule in ThemeKey 6.3

Same name and namespace in other branches
  1. 6.4 themekey_build.inc \themekey_update_static_rule()
  2. 6.2 themekey_build.inc \themekey_update_static_rule()
  3. 7.3 themekey_build.inc \themekey_update_static_rule()
  4. 7 themekey_build.inc \themekey_update_static_rule()
  5. 7.2 themekey_build.inc \themekey_update_static_rule()

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.

Parameters

$property: name of the static property as string

$state: boolean:

  • TRUE the rule should be created or updated
  • FALSE the rule should be deleted
1 call to themekey_update_static_rule()
themekey_ui_settings_form_submit in ./themekey_ui_admin.inc
Form submission handler for themekey_ui_settings_form().

File

./themekey_build.inc, line 416
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_update_static_rule($property, $state) {
  $id = db_result(db_query("SELECT id FROM {themekey_properties} WHERE property = '%s'", $property));
  if ($state) {
    $item = array(
      'property' => $property,
      'operator' => '=',
      'value' => 'static',
      'theme' => 'default',
    );
    if ($id) {
      $item['id'] = $id;

      // leave 'enabled' as it is in database
    }
    else {

      // enable new rule
      $item['enabled'] = 1;
    }
    themekey_rule_set($item);
  }
  elseif ($id) {
    themekey_rule_del($id);
  }
}