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)

Prepares a node for saving by populating the author and creation date.

2 calls to node_submit()

1 string reference to 'node_submit'

File

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

Code

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

  // If a new revision is created, save the current user as revision author.
  if (!empty($node->revision)) {
    $node->revision_uid = $user->uid;
  }

  $node->created = !empty($node->date) ? strtotime($node->date) : REQUEST_TIME;
  $node->validated = TRUE;

  return $node;
}
Login or register to post comments