function node_submit

You are here

7 node.module node_submit($node)
4.6 node.module node_submit(&$node)
4.7 node.module node_submit($node)
5 node.module node_submit($node)
6 node.module node_submit($node)

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 modules/node/node.test
Checks whether custom node IDs are saved properly during an import operation.
node_form_submit_build_node in modules/node/node.pages.inc
Updates the form state's node entity by processing this submission's values.
1 string reference to 'node_submit'
node_form_submit_build_node in modules/node/node.pages.inc
Updates the form state's node entity by processing this submission's values.

File

modules/node/node.module, line 1051
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;
}