You are here

function rules_action_set_domain_theme in Domain Rules 6

File

./domain_rules.rules.inc, line 177
The rules hook and action

Code

function rules_action_set_domain_theme($settings) {
  $theme = $settings['theme'];
  $domain = domain_lookup(NULL, $settings['subdomain'], TRUE);
  if (isset($domain['domain_id'])) {
    $domain_id = $domain['domain_id'];
    $settings = NULL;
    db_query("UPDATE {domain_theme} SET status = 0 WHERE domain_id = %d", $domain_id);
    $check = domain_theme_lookup($domain_id, $theme);
    if ($check == -1) {
      db_query("INSERT INTO {domain_theme} (domain_id, theme, settings, status) VALUES (%d, '%s', %b, 1)", $domain_id, $theme, $settings);
    }
    else {
      db_query("UPDATE {domain_theme} SET status = 1 WHERE domain_id = %d AND theme = '%s'", $domain_id, $theme);
    }

    // Clear the cache.
    cache_clear_all();
  }
  else {
    drupal_set_message(t('The domain @domain does not exist.', array(
      '@domain' => $settings['subdomain'],
    )), 'error');
  }
}