function node_form_submit

You are here

7 node.pages.inc node_form_submit($form, &$form_state)
4.7 node.module node_form_submit($form_id, $edit)
5 node.module node_form_submit($form_id, $form_values)
6 node.pages.inc node_form_submit($form, &$form_state)

File

modules/node/node.module, line 2359
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function node_form_submit($form_id, $form_values) {
  global $user;

  // Fix up the node when required:
  $node = node_submit($form_values);

  // Prepare the node's body:
  if ($node->nid) {
    node_save($node);
    watchdog('content', t('@type: updated %title.', array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
    drupal_set_message(t('The %post has been updated.', array('%post' => node_get_types('name', $node))));
  }
  else {
    node_save($node);
    watchdog('content', t('@type: added %title.', array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
    drupal_set_message(t('Your %post has been created.', array('%post' => node_get_types('name', $node))));
  }
  if ($node->nid) {
    if (node_access('view', $node)) {
      return 'node/' . $node->nid;
    }
    else {
      return '';
    }
  }
  // it is very unlikely we get here
  return FALSE;
}