You are here

function domain_locale_form_submit in Domain Locale 7

FormsAPI submit handler for domain language settings

File

./domain_locale.admin.inc, line 121
Provides admin functionality for domain specific language settings

Code

function domain_locale_form_submit($form, &$form_state) {
  $domain_id = $form_state['values']['domain_id'];
  $check = domain_locale_lookup($domain_id);
  if (is_array($check) && count($check) >= 1) {
    domain_locale_delete_domain($domain_id);
  }
  $default = $form_state['input']['domain_languages']['site_default'];

  //Construct the array for inserts and updates. Looping over existing languages list.
  $params = array();
  foreach ($form_state['input']['domain_language'] as $langcode => $values) {
    if (!$values['enabled'] && $default != $langcode) {
      continue;
    }
    $params[$langcode] = array(
      'language' => $langcode,
      'weight' => $values['weight'],
    );
  }
  domain_locale_insert_domain($domain_id, $params);

  //Update domain_conf language_default variable
  domain_conf_variable_set($domain_id, 'language_default', $default);

  // Changing the language settings impacts the interface.
  cache_clear_all('*', 'cache_page', TRUE);
  drupal_set_message(t('Updated domain specific language settings.'));

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