function globalredirect_settings_submit_save in Global Redirect 7
Same name and namespace in other branches
- 6 globalredirect.admin.inc \globalredirect_settings_submit_save()
Save submit handler for the globalredirect_settings form. Compares the submitted settings to the defaults and unsets any that are equal. This was we only store overrides.
1 string reference to 'globalredirect_settings_submit_save'
- globalredirect_settings in ./
globalredirect.admin.inc - Function to generate the form setting array
File
- ./
globalredirect.admin.inc, line 135 - This is the GlobalRedirect admin include which provides an interface to global redirect to change some of the default settings
Code
function globalredirect_settings_submit_save($form_id, &$form_state) {
// Grab the defaults
$defaults = _globalredirect_get_settings(TRUE);
// Copy out the settings
$settings = $form_state['values']['settings'];
// Compare each setting to the default. If equal, remove. If not, cast to an int (FormAPI converts keys to string).
foreach ($settings as $key => $value) {
if ($value == $defaults[$key]) {
unset($settings[$key]);
}
else {
$settings[$key] = (int) $value;
}
}
// If we've ended up with an empty settings array, delete the settings variable...
if (empty($settings)) {
variable_del('globalredirect_settings');
}
else {
variable_set('globalredirect_settings', $settings);
}
drupal_set_message(t('Globalredirect settings have been saved.'));
}