You are here

function themekey_rule_del in ThemeKey 6.2

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

Deletes a ThemeKey rule from database.

Parameters

$id: id of the rule to be deleted from database

3 calls to themekey_rule_del()
themekey_admin_delete_rule_confirm_submit in ./themekey_admin.inc
Execute ThemeKey rule deletion
themekey_ui_del_path_theme in ./themekey_ui_helper.inc
Deletes a ThemeKey rule.
themekey_update_static_rule in ./themekey_build.inc
Adds or modifies a so called static rule in the database. Static rules could 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 356
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_rule_del($id) {

  // lock table to prevent race condition
  db_lock_table('themekey_properties');
  $num_childs = db_result(db_query("SELECT COUNT(*) FROM {themekey_properties} WHERE parent = %d", $id));
  if (FALSE !== $num_childs) {
    if ($num_childs > 0) {
      db_unlock_tables();
      drupal_set_message(t('ThemeKey rule could not be deleted because it has children in the chain'), 'error');
    }
    else {
      $result = db_query('DELETE FROM {themekey_properties} WHERE id = %d', $id);
      db_unlock_tables();
      if (!$result) {
        drupal_set_message(t('Error while deleteing ThemeKey rule'), 'error');
      }
    }
  }
  else {
    db_unlock_tables();
    drupal_set_message(t('Error while deleteing ThemeKey rule'), 'error');
  }
}