You are here

function themekey_rule_del in ThemeKey 7

Same name and namespace in other branches
  1. 6.4 themekey_build.inc \themekey_rule_del()
  2. 6.2 themekey_build.inc \themekey_rule_del()
  3. 6.3 themekey_build.inc \themekey_rule_del()
  4. 7.3 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 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 370
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) {

  // TRANSACTIONS - SEE http://drupal.org/node/355875
  // The transaction opens here.
  $txn = db_transaction();
  $result = db_select('themekey_properties', 'tp');
  $result
    ->condition('parent', $id);
  $result
    ->addExpression('COUNT(*)', 'num_childs');
  $num_childs = $result
    ->execute()
    ->fetchField();
  if (FALSE !== $num_childs) {
    if ($num_childs > 0) {
      drupal_set_message(t('ThemeKey rule could not be deleted because it has children in the chain'), 'error');
    }
    else {
      $result = db_delete('themekey_properties')
        ->condition('id', $id)
        ->execute();
      if (!$result) {
        drupal_set_message(t('Error while deleting ThemeKey rule'), 'error');
      }
    }
  }
  else {
    drupal_set_message(t('Error while deleting ThemeKey rule'), 'error');
  }

  // $txn goes out of scope here, and the entire transaction commits.
}