You are here

function domain_theme_form_submit in Domain Access 7.2

Same name and namespace in other branches
  1. 7.3 domain_theme/domain_theme.admin.inc \domain_theme_form_submit()

Form submit handler.

File

domain_theme/domain_theme.admin.inc, line 89
Include file to handle theme configration screen

Code

function domain_theme_form_submit($form, &$form_state) {

  // Update or Insert?
  $domain_id = $form_state['values']['domain_id'];
  $theme = $form_state['values']['theme'];

  // Set all themes in this domain to null status.
  db_update('domain_theme')
    ->fields(array(
    'status' => 0,
  ))
    ->condition('domain_id', $domain_id)
    ->execute();

  // Now activate the selected theme.
  // This lookup returns -1 on failure.
  $check = domain_theme_lookup($domain_id, $theme);

  // Update.
  if ($check != -1) {
    db_update('domain_theme')
      ->fields(array(
      'status' => 1,
    ))
      ->condition('domain_id', $domain_id)
      ->condition('theme', $theme)
      ->execute();
  }
  else {
    db_insert('domain_theme')
      ->fields(array(
      'domain_id' => $domain_id,
      'theme' => $theme,
      'settings' => '',
      'status' => 1,
      'filepath' => '',
    ))
      ->execute();
  }

  // Return to the correct page.
  $form_state['redirect'] = 'admin/structure/domain/theme/' . $domain_id;

  // Clear the cache.
  cache_clear_all();
}