Community Documentation

node_submit

5 node.module node_submit($node)
6 node.module node_submit($node)
7 node.module node_submit($node)
8 node.module node_submit($node)

Prepare node for saving by populating author and creation date.

▾ 2 functions call node_submit()

NodeSaveTestCase::testImport in modules/node/node.test
Import test, to check if custom node ids are saved properly. Workflow:
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 1004
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

<?php
function node_submit($node) {
  global $user;

  // 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;
}
?>
Login or register to post comments