Same name and namespace in other branches
  1. 4.7.x modules/node.module \node_form_submit()
  2. 6.x modules/node/node.pages.inc \node_form_submit()
  3. 7.x modules/node/node.pages.inc \node_form_submit()

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;
}