function node_submit

Prepares node for saving by populating author and creation date.

Parameters

$node: A node object.

Return value

An updated node object.

2 calls to node_submit()
NodeSaveTestCase::testImport in drupal/modules/node/node.test
Checks whether custom node IDs are saved properly during an import operation.
node_form_submit_build_node in drupal/modules/node/node.pages.inc
Updates the form state's node entity by processing this submission's values.

File

drupal/modules/node/node.module, line 1052
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_submit($node) {

  // A user might assign the node author by entering a user name in the node
  // form, which we then need to translate to a user ID.
  if (isset($node->name)) {
    if ($account = user_load_by_name($node->name)) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }
  $node->created = !empty($node->date) ? strtotime($node->date) : REQUEST_TIME;
  $node->validated = TRUE;
  return $node;
}