function node_form_submit($form, &$form_state) {
$item = &$form_state['values']['menu'];
if (preg_match('/[^a-z A-Z0-9-]/', $item['link_title'])) {
form_set_error('link_title', t('The title name may only consist of lowercase letters, numbers, and hyphens.'));
}
else
{
global $user;
$node = node_form_submit_build_node($form, $form_state);
$insert = empty($node->nid);
node_save($node);
$node_link = l(t('view'), 'node/'. $node->nid);
$watchdog_args = array('@type' => $node->type, '%title' => $node->title);
$t_args = array('@type' => node_get_types('name', $node), '%title' => $node->title);
if ($insert) {
watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
drupal_set_message(t('@type %title has been created.', $t_args));
}
else {
watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
drupal_set_message(t('@type %title has been updated.', $t_args));
}
if ($node->nid) {
unset($form_state['rebuild']);
$form_state['nid'] = $node->nid;
$form_state['redirect'] = 'node/'. $node->nid;
}
else {
// In the unlikely case something went wrong on save, the node will be
// rebuilt and node form redisplayed the same way as in preview.
drupal_set_message(t('The post could not be saved.'), 'error');
}
}
}
$item = &$form_state['values']['menu'];
if (preg_match('/[^a-z A-Z0-9-]/', $item['link_title'])) {
form_set_error('link_title', t('The title name may only consist of lowercase letters, numbers, and hyphens.'));
}
else
{
global $user;
$node = node_form_submit_build_node($form, $form_state);
$insert = empty($node->nid);
node_save($node);
$node_link = l(t('view'), 'node/'. $node->nid);
$watchdog_args = array('@type' => $node->type, '%title' => $node->title);
$t_args = array('@type' => node_get_types('name', $node), '%title' => $node->title);
if ($insert) {
watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
drupal_set_message(t('@type %title has been created.', $t_args));
}
else {
watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
drupal_set_message(t('@type %title has been updated.', $t_args));
}
if ($node->nid) {
unset($form_state['rebuild']);
$form_state['nid'] = $node->nid;
$form_state['redirect'] = 'node/'. $node->nid;
}
else {
// In the unlikely case something went wrong on save, the node will be
// rebuilt and node form redisplayed the same way as in preview.
drupal_set_message(t('The post could not be saved.'), 'error');
}
}
}
No comments:
Post a Comment