You are here

function domain_theme_batch_submit in Domain Access 7.3

Same name and namespace in other branches
  1. 7.2 domain_theme/domain_theme.module \domain_theme_batch_submit()

Custom handler for domain_theme_domain_batch().

Parameters

$values: The form values passed by the FormsAPI.

1 string reference to 'domain_theme_batch_submit'
domain_theme_domain_batch in domain_theme/domain_theme.domain.inc
Implements hook_domain_batch().

File

domain_theme/domain_theme.module, line 187
Domain Theme module for the Domain Access module group.

Code

function domain_theme_batch_submit($values) {
  foreach ($values['domain_batch'] as $key => $value) {
    if ((int) $key != domain_default_id()) {

      // Clear out the old theme.
      db_update('domain_theme')
        ->fields(array(
        'status' => 0,
      ))
        ->condition('domain_id', $key)
        ->execute();
      $data = db_query("SELECT theme FROM {domain_theme} WHERE theme = :theme AND domain_id = :domain_id", array(
        ':theme' => $value,
        ':domain_id' => $key,
      ))
        ->fetchField();
      if (!empty($data) && $data == $value) {
        db_update('domain_theme')
          ->fields(array(
          'status' => 1,
        ))
          ->condition('domain_id', $key)
          ->condition('theme', $value)
          ->execute();
      }
      else {
        db_insert('domain_theme')
          ->fields(array(
          'domain_id' => $key,
          'theme' => $value,
          'status' => 1,
        ))
          ->execute();
      }
    }
    else {
      variable_set('theme_default', $value);
    }
  }
}