function commentformsettings_settings_submit in Node and Comments Form Settings 6.2
Same name and namespace in other branches
- 6.3 commentformsettings/commentformsettings.module \commentformsettings_settings_submit()
- 7.3 commentformsettings/commentformsettings.module \commentformsettings_settings_submit()
- 7.2 commentformsettings/commentformsettings.module \commentformsettings_settings_submit()
Submit callback for the node form alter
See also
commentformsettings_form_alter()
1 string reference to 'commentformsettings_settings_submit'
- commentformsettings_form_alter in commentformsettings/
commentformsettings.module - Implementation of hook_form_alter()
File
- commentformsettings/
commentformsettings.module, line 173 - main file, only one hook_form_alter to change several settings
Code
function commentformsettings_settings_submit($form, &$form_state) {
// Get the values sent from the form and save them in $values
$values = $form_state['values'];
// Save the value of $values['var'] in $name. This variable will
// be used to define the name in variable_set($name, $values)
// This will be something like commentformsettings_contenttype
$name = 'commentformsettings_' . $values['var_comments'];
// Get the elements from the function and loop to get only the keys, not the values
$elements = commentformsettings_elements_default();
foreach ($elements as $k => $v) {
// Build the $ignore array with only the keys ($k)
$ignore[] = $k;
}
// Add to the $ignore array the $name
$ignore[] = $name;
// Loop thought the array of $values to unset everything but our values in $ignore
foreach ($values as $key => $value) {
// if the key IS NOT in the $ignore array, then unset that value
if (!in_array($key, $ignore)) {
unset($values[$key]);
}
else {
// Build the $data array wich we will send to the variable_set function
$data[$key] = $value;
}
}
variable_set($name, $data);
// Purge all variables created by hook_node_type
commentformsettings_purge($values['var_comments']);
}