node_submit
- Versions
- 4.6
node_submit(&$node)- 4.7 – 7
node_submit($node)
Prepare node for save and allow modules to make changes.
Code
modules/node/node.module, line 1981
<?php
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;
}
?>Login or register to post comments 