You are here

function node_form_submit in Drupal 4

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

File

modules/node.module, line 1897
The core that allows content to be submitted to the site.

Code

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

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

  // Prepare the node's body:
  if ($node->nid) {

    // Check whether the current user has the proper access rights to
    // perform this operation:
    $original_node = node_load($node->nid);

    //check access rights using the unmodified node
    if (node_access('update', $original_node)) {
      node_save($node);
      watchdog('content', t('%type: updated %title.', array(
        '%type' => theme('placeholder', t($node->type)),
        '%title' => theme('placeholder', $node->title),
      )), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
      drupal_set_message(t('The %post was updated.', array(
        '%post' => node_get_name($node),
      )));
    }
  }
  else {

    // Check whether the current user has the proper access rights to
    // perform this operation:
    if (node_access('create', $node)) {
      node_save($node);
      watchdog('content', t('%type: added %title.', array(
        '%type' => theme('placeholder', t($node->type)),
        '%title' => theme('placeholder', $node->title),
      )), WATCHDOG_NOTICE, l(t('view'), "node/{$node->nid}"));
      drupal_set_message(t('Your %post was created.', array(
        '%post' => node_get_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;
}