function cloud_zoom_admin_preset_edit_form_submit_save in Cloud Zoom 6
Submit handler for the save button - this saves any settings which differ from the defaults. If there are no differing options, the sub-section is removed.
1 string reference to 'cloud_zoom_admin_preset_edit_form_submit_save'
- cloud_zoom_admin_preset_edit_form in ./
cloud_zoom.admin.inc - The edit form callback - provides editable fields for all the "default" options
File
- ./
cloud_zoom.admin.inc, line 294 - This file contains al the admin-only function
Code
function cloud_zoom_admin_preset_edit_form_submit_save(&$form, &$form_state) {
// Get the preset from the form
$preset = $form_state['values']['preset'];
// If there is an original preset, delete the old name
if (isset($form['#original_preset'])) {
// If the original preset isn't 'normal' (ie it IS module defined)
// Then lock the name
if ($form['#original_preset']['storage'] != CLOUD_ZOOM_STORAGE_NORMAL) {
$preset['name'] = $form['#original_preset']['name'];
}
// Remove the old settings - this stops dupes when you rename
db_query("DELETE FROM {cloud_zoom_presets} WHERE name = '%s'", $form['#original_preset']['name']);
}
// Get the default settings
$defaults = _cloud_zoom_default_settings();
// For every submitted setting, if the value equals the default then unset it
foreach ($preset['settings'] as $option => $val) {
if ($val == $defaults[$option]['default']) {
unset($preset['settings'][$option]);
}
}
// Write changes
drupal_write_record('cloud_zoom_presets', $preset);
// Clear the cache
cloud_zoom_get_settings(NULL, TRUE);
// Rebuild some other caches - need to do this in case a preset is renamed or new
// @todo - make a flag to make this 'optional'
drupal_rebuild_theme_registry();
content_clear_type_cache();
// Redirect to the overview
$form_state['redirect'] = 'admin/settings/cloudzoom';
}