function bulk_photo_nodes_submit in Bulk File Nodes 7
Form submission handler for bulk_photo_nodes_form_node_type_form_alter().
1 string reference to 'bulk_photo_nodes_submit'
- bulk_photo_nodes_form_node_type_form_alter in ./
bulk_photo_nodes.module - Implements hook_form_node_type_form_alter().
File
- ./
bulk_photo_nodes.module, line 113 - hooks and helper functions for bulk photo node.
Code
function bulk_photo_nodes_submit($form, &$form_state) {
$image_field = $form_state['values']['bulk_photo_nodes']['image_field'];
$override_add_form = $form_state['values']['bulk_photo_nodes']['override_add_form'];
$node_type = $form['#node_type']->type;
$orig_bpn_var = variable_get('bulk_photo_node_types', array());
$new_bpn_var = $orig_bpn_var;
// We need $bpn_var[$node_type] to be set, as we check it later on.
if (!isset($bpn_var[$node_type])) {
$bpn_var[$node_type] = NULL;
}
// Always save field even if set to none.
if ($image_field == 'none') {
if (array_key_exists($node_type, $new_bpn_var)) {
unset($new_bpn_var[$node_type]);
}
}
else {
$new_bpn_var[$node_type] = $image_field;
}
// Override the form?
$new_bpn_var[$node_type . '_override'] = $override_add_form;
// Only save if something has changed.
foreach ($new_bpn_var as $key => $val) {
if (!array_key_exists($key, $orig_bpn_var) || $orig_bpn_var[$key] != $val) {
// Save as soon as anything's different.
variable_set('bulk_photo_node_types', $new_bpn_var);
menu_rebuild();
drupal_set_message("Bulk photo node settings saved.");
// No need to keep checking.
continue;
}
}
}