You are here

function node_submit in Drupal 5

Same name and namespace in other branches
  1. 4 modules/node.module \node_submit()
  2. 6 modules/node/node.module \node_submit()
  3. 7 modules/node/node.module \node_submit()

Prepare node for save and allow modules to make changes.

3 calls to node_submit()
blogapi_blogger_edit_post in modules/blogapi/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_new_post in modules/blogapi/blogapi.module
Blogging API callback. Inserts a new blog post as a node.
node_form_submit in modules/node/node.module

File

modules/node/node.module, line 1981
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) {
  global $user;

  // Convert the node to an object, if necessary.
  $node = (object) $node;

  // Auto-generate the teaser, but only if it hasn't been set (e.g. by a
  // module-provided 'teaser' form item).
  if (!isset($node->teaser)) {
    $node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
  }
  if (user_access('administer nodes')) {

    // Populate the "authored by" field.
    if ($account = user_load(array(
      'name' => $node->name,
    ))) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }
  $node->created = !empty($node->date) ? strtotime($node->date) : time();

  // Do node-type-specific validation checks.
  node_invoke($node, 'submit');
  node_invoke_nodeapi($node, 'submit');
  $node->validated = TRUE;
  return $node;
}