Same name in other branches
- 7.x-2.x advagg.admin.inc \advagg_admin_settings_form_submit()
Validate form values. Used to unset variables before they get saved.
File
-
includes/
admin.inc, line 502
Code
function advagg_admin_settings_form_submit($form, &$form_state) {
global $conf;
// 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_unmanaged_delete($css_path);
file_unmanaged_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();
}
}