You are here

function domain_rules_action_set_domain_theme in Domain Rules 7

Custom hook Do on action 'set domain theme'

Parameters

string $subdomain:

string $theme:

File

./domain_rules.module, line 318
domain_rules.module @description Port of 'Domain rules' by shushu for Drupal7

Code

function domain_rules_action_set_domain_theme($subdomain, $theme) {
  $domain = domain_lookup(NULL, $subdomain, TRUE);
  if (isset($domain['domain_id'])) {
    $domain_id = $domain['domain_id'];
    db_query('UPDATE {domain_theme} SET status = 0 WHERE domain_id = :domain_id', array(
      ':domain_id' => $domain_id,
    ));
    $check = domain_theme_lookup($domain_id, $theme);
    if ($check == -1) {
      db_query('INSERT INTO {domain_theme} (domain_id, theme, status) VALUES (:domain_id, :theme, 1)', array(
        ':domain_id' => $domain_id,
        ':theme' => $theme,
      ));
    }
    else {
      db_query('UPDATE {domain_theme} SET status = 1 WHERE domain_id = :domain_id AND theme = :theme', array(
        ':domain_id' => $domain_id,
        ':theme' => $theme,
      ));
    }
    cache_clear_all();
  }
  else {
    drupal_set_message(t('The domain %domain does not exist.', array(
      '%domain' => $subdomain,
    )), 'error');
  }
}