function _better_statistics_settings_form_submit in Better Statistics 7
Submit handler for Better Statistics configuration settings.
2 calls to _better_statistics_settings_form_submit()
- better_statistics_settings_form_submit in ./
better_statistics.module - Submit handler for the Better Statistics configuration form.
- better_statistics_update_7100 in ./
better_statistics.install - Enable the Statistics API.
File
- ./
better_statistics.admin.inc, line 228 - Admin and config code for the Better Statistics module.
Code
function _better_statistics_settings_form_submit($form, &$form_state) {
// Get all declared fields.
$declared = _better_statistics_get_custom_fields_by_module();
// Compare the declared fields to what was submitted in the form.
$customizations = array();
foreach ($declared as $module => $fields) {
foreach ($fields as $name => $field) {
if ($form_state['values']['better_statistics'][$module]['fields'][$name]) {
$customizations[$name] = $field;
}
}
}
// Get various combinations of fields for schema comparisons.
$defaults = better_statistics_get_default_fields();
$default_and_custom = $defaults + $customizations;
$active = variable_get('better_statistics_fields', $defaults);
// Compare the fields we turned up above to what currently exists.
$fields_added = array_keys(array_diff_key($default_and_custom, $active));
better_statistics_enable_fields($fields_added);
$fields_removed = array_keys(array_diff_key($active, $default_and_custom));
better_statistics_disable_fields($fields_removed);
// Ensure Better Statistics data isn't unintentionally processed.
unset($form_state['values']['better_statistics']);
}