You are here

function themekey_update_static_rule in ThemeKey 7

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. 6.3 themekey_build.inc \themekey_update_static_rule()
  4. 7.3 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
6 calls to themekey_update_static_rule()
themekey_compat_modules_disabled in ./themekey_compat.module
Implements hook_modules_disabled().
themekey_compat_settings_form_submit in ./themekey_compat_admin.inc
Form submission handler for themekey_compat_settings_form().
themekey_ui_disable in ./themekey_ui.install
Implements hook_disable().
themekey_ui_settings_form_submit in ./themekey_ui_admin.inc
Form submission handler for themekey_ui_settings_form().
themekey_user_profile_disable in ./themekey_user_profile.install
Implements hook_disable().

... See full list

File

./themekey_build.inc, line 446
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_select('themekey_properties', 'tp')
    ->fields('tp', array(
    'id',
  ))
    ->condition('property', $property)
    ->execute()
    ->fetchField();
  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);
  }
}