| 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.
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