function custom_pub_add_submit in Custom Publishing Options 6
Same name and namespace in other branches
- 7 custom_pub.admin.inc \custom_pub_add_submit()
Form submit function for add form.
File
- ./
custom_pub.module, line 173 - Adds the ability to add Custom publishing options to the node Add/Edit form.
Code
function custom_pub_add_submit($form, $form_state) {
$types = variable_get('custom_pub_types', array());
$node_types = node_get_types();
$type = array();
$type[trim($form_state['values']['state_machine'])]['type'] = trim($form_state['values']['state_machine']);
$type[trim($form_state['values']['state_machine'])]['name'] = check_plain(trim($form_state['values']['state']));
foreach ($form_state['values']['node_types'] as $node_type => $value) {
if (!empty($value)) {
$type[trim($form_state['values']['state_machine'])]['node_types'][$node_type] = $node_types[$node_type]->name;
}
}
$ret = array();
$spec = array(
'description' => 'Custom publishing option ' . t(check_plain(trim($form_state['values']['state']))),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
db_add_field($ret, 'node', trim($form_state['values']['state_machine']), $spec);
if ($ret[0]['success']) {
variable_set('custom_pub_types', array_merge($types, $type));
cache_clear_all('schema', 'cache');
drupal_set_message(t('Publishing option created.'));
}
else {
drupal_set_message(t('There was an error creating your Publishing option.'), 'error');
}
}