You are here

function node_object_prepare in Drupal 6

Same name and namespace in other branches
  1. 4 modules/node.module \node_object_prepare()
  2. 5 modules/node/node.module \node_object_prepare()
  3. 7 modules/node/node.module \node_object_prepare()
1 call to node_object_prepare()
node_form in modules/node/node.pages.inc
Generate the node add/edit form array.

File

modules/node/node.pages.inc, line 70
Page callbacks for adding, editing, deleting, and revisions management for content.

Code

function node_object_prepare(&$node) {

  // Set up default values, if required.
  $node_options = variable_get('node_options_' . $node->type, array(
    'status',
    'promote',
  ));

  // If this is a new node, fill in the default values.
  if (!isset($node->nid)) {
    foreach (array(
      'status',
      'promote',
      'sticky',
    ) as $key) {
      $node->{$key} = in_array($key, $node_options);
    }
    global $user;
    $node->uid = $user->uid;
    $node->created = time();
  }
  else {
    $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');

    // Remove the log message from the original node object.
    $node->log = NULL;
  }

  // Always use the default revision setting.
  $node->revision = in_array('revision', $node_options);
  node_invoke($node, 'prepare');
  node_invoke_nodeapi($node, 'prepare');
}