You are here

function glossify_admin_settings_submit in Glossify 6.3

Same name and namespace in other branches
  1. 6 glossify.admin.inc \glossify_admin_settings_submit()

Form evaluation of administrative settings.

1 string reference to 'glossify_admin_settings_submit'
glossify_admin_settings in ./glossify.admin.inc
Form builder for administrative settings.

File

./glossify.admin.inc, line 310
Glossify Administration

Code

function glossify_admin_settings_submit($form, &$form_state) {
  $configurations = variable_get('glossify_configurations', array());
  $goto = 'admin/settings/glossify';
  if ($form_state['clicked_button']['#value'] == t('Delete configuration') && $form_state['values']['config_id'] !== 'global') {
    unset($configurations[$form_state['values']['name']]);
    drupal_set_message(t('Configuration deleted.'));
  }
  else {
    $methods = array(
      'use_title' => $form_state['values']['use_title'],
      'use_internal' => $form_state['values']['use_internal'],
      'use_cck' => $form_state['values']['use_cck'],
      'keyword_field' => $form_state['values']['keyword_field'],
      'override_field' => $form_state['values']['override_field'],
      'use_taxonomy' => $form_state['values']['use_taxonomy'],
      'vocabulary' => $form_state['values']['vocabulary'],
      'link_term' => $form_state['values']['link_term'],
    );
    $configuration = array(
      'from' => $form_state['values']['from'],
      'to' => $form_state['values']['to'],
      'only_first' => $form_state['values']['only_first'],
      'unicode' => $form_state['values']['unicode'],
      'teaser' => $form_state['values']['teaser'],
      'style' => $form_state['values']['style'],
      'link_self' => $form_state['values']['link_self'],
      'case_insensitivity' => $form_state['values']['case_insensitivity'],
      'break' => $form_state['values']['break'],
      'language' => $form_state['values']['language'],
      'excl_mode' => $form_state['values']['excl_mode'],
      'excl_tags' => $form_state['values']['excl_tags'],
      'methods' => $methods,
    );
    $name = empty($form_state['values']['name']) ? 'global' : $form_state['values']['name'];
    if (isset($configurations[$name])) {
      $last_methods = $configurations[$name]['methods'];
      $methods_to_update = array();
      if ($last_methods['use_title'] !== $methods['use_title']) {
        $methods_to_update['title'] = $methods['use_title'];
        drupal_set_message('Title-keywords were updated.', 'status');
      }
      if ($last_methods['use_internal'] !== $methods['use_internal']) {
        $methods_to_update['internal'] = $methods['use_internal'];
        drupal_set_message('Internal-keywords were updated.', 'status');
      }
      if ($last_methods['use_cck'] !== $methods['use_cck'] || $last_methods['keyword_field'] !== $methods['keyword_field'] || $last_methods['override_field'] !== $methods['override_field']) {
        $methods_to_update['cck'] = array(
          'use_cck' => $methods['use_cck'],
          'keyword_field' => $methods['keyword_field'],
          'override_field' => $methods['override_field'],
        );
        drupal_set_message('CCK-keywords were updated.', 'status');
      }
      if ($last_methods['use_taxonomy'] !== $methods['use_taxonomy'] || $last_methods['vocabulary'] !== $methods['vocabulary'] || $last_methods['link_term'] !== $methods['link_term']) {
        $methods_to_update['taxonomy'] = array(
          'use_taxonomy' => $methods['use_taxonomy'],
          'vocabulary' => $methods['vocabulary'],
        );
        drupal_set_message('Taxonomy-keywords were updated.', 'status');
      }
      if (count($methods_to_update) > 0) {
        unset($configurations[$name]);
        _update_keywords_for_methods($configuration['to'], $methods_to_update, $name);
      }
    }
    $configurations[$name] = $configuration;
    $goto .= '/' . $name;
  }
  variable_set('glossify_configurations', $configurations);
  if ($form_state['values']['config_id'] == 'global') {
    variable_set('glossify_process_mode', (int) $form_state['values']['glossify_mode']);
  }
  drupal_set_message(t('Configuration stored.'));
  $form_state['redirect'] = $goto;
  menu_rebuild();
  cache_clear_all('*', 'cache_filter', TRUE);
}