You are here

function advagg_admin_settings_form_submit in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7.2 advagg.admin.inc \advagg_admin_settings_form_submit()
  2. 7 includes/admin.inc \advagg_admin_settings_form_submit()

Validate form values. Used to unset variables before they get saved.

1 string reference to 'advagg_admin_settings_form_submit'
advagg_admin_settings_form in ./advagg.admin.inc
Form builder; Configure advagg settings.

File

./advagg.admin.inc, line 472
Admin page callbacks for the advanced CSS/JS aggregation module.

Code

function advagg_admin_settings_form_submit($form, &$form_state) {
  global $conf;

  // Pull the old password if it wasn't changed by the user.
  if (!empty($form_state['values']['advagg_async_test_username']) && empty($form_state['values']['advagg_async_test_password'])) {
    $form_state['values']['advagg_async_test_password'] = variable_get('advagg_async_test_password', '');
  }

  // Gzip & htaccess checks.
  list($css_path, $js_path) = advagg_get_root_files_dir();
  $css_path .= '/.htaccess';
  $js_path .= '/.htaccess';
  if ($conf['advagg_gzip_compression'] != $form_state['values']['advagg_gzip_compression'] && $form_state['values']['advagg_dir_htaccess']) {
    $conf['advagg_gzip_compression'] = $form_state['values']['advagg_gzip_compression'];
    $conf['advagg_dir_htaccess'] = $form_state['values']['advagg_dir_htaccess'];
    advagg_admin_recreate_htaccess();
  }
  if ($form_state['values']['advagg_dir_htaccess'] == FALSE) {
    $conf['advagg_dir_htaccess'] = FALSE;
    advagg_clearstatcache(TRUE, $css_path);
    advagg_clearstatcache(TRUE, $js_path);
    if (file_exists($css_path) || file_exists($js_path)) {
      file_delete($css_path);
      file_delete($js_path);
      drupal_set_message(t('Advanced CSS/JS Aggregation directory level htaccess files have been removed.'));
    }
  }
  elseif ($conf['advagg_dir_htaccess'] != $form_state['values']['advagg_dir_htaccess']) {
    $conf['advagg_dir_htaccess'] = $form_state['values']['advagg_dir_htaccess'];
    advagg_admin_recreate_htaccess();
  }
  advagg_clearstatcache(TRUE, $css_path);
  advagg_clearstatcache(TRUE, $js_path);
  if ($conf['advagg_dir_htaccess'] && (!file_exists($css_path) || !file_exists($js_path))) {
    advagg_admin_recreate_htaccess();
  }

  // If checksum mode changed, smart flush cache with new checksum mode selected.
  if ($conf['advagg_checksum_mode'] != $form_state['values']['advagg_checksum_mode']) {
    $conf['advagg_checksum_mode'] = $form_state['values']['advagg_checksum_mode'];
    advagg_admin_flush_cache_button();
  }

  // If advagg is enabled/disabled, smart flush the cache.
  if ($conf['advagg_enabled'] != $form_state['values']['advagg_enabled']) {
    advagg_admin_flush_cache_button();
  }
}