function custom_pub_edit_submit in Custom Publishing Options 6
Same name and namespace in other branches
- 7 custom_pub.admin.inc \custom_pub_edit_submit()
Form submit function for edit form.
1 string reference to 'custom_pub_edit_submit'
- custom_pub_edit in ./
custom_pub.module - Form callback function for edit form.
File
- ./
custom_pub.module, line 260 - Adds the ability to add Custom publishing options to the node Add/Edit form.
Code
function custom_pub_edit_submit($form, $form_state) {
$node_types = node_get_types();
$type = $form_state['values']['type'];
$types = variable_get('custom_pub_types', array());
if ($form_state['values']['op'] == 'Delete') {
unset($types[$type['type']]);
$ret = array();
db_drop_field($ret, 'node', $type['type']);
$success = $ret[0]['success'];
}
else {
unset($types[$type['type']]['node_types']);
foreach ($form_state['values']['node_types'] as $node_type => $value) {
if (!empty($value)) {
$types[$type['type']]['node_types'][$node_type] = $node_types[$node_type]->name;
}
}
$type['name'] = trim($form_state['values']['state']);
$types[$type['type']]['name'] = check_plain($type['name']);
$success = TRUE;
}
if ($success) {
variable_set('custom_pub_types', $types);
drupal_set_message(t('!op publishing option successful.', array(
'!op' => $form_state['values']['op'],
)));
}
else {
drupal_set_message(t('There was an error trying to !op the publishing option. Please Try Again', array(
'!op' => $form_state['values']['op'],
)), 'error');
}
}