function context_node_node_update in Context Node 7
Implements hook_node_update()
File
- ./
context_node.module, line 214
Code
function context_node_node_update($node) {
$option = variable_get("context_node_default_" . $node->type, '');
if ($option == "none" || empty($option)) {
return;
}
else {
if (empty($node->context)) {
$node->context = $option;
}
// Check for a new revision
if (!empty($node->revision)) {
db_insert('context_node')
->fields(array(
'nid' => $node->nid,
'vid' => $node->vid,
'context' => $node->context,
))
->execute();
}
elseif (_context_node_check_for_context($node)) {
db_update('context_node')
->fields(array(
'context' => $node->context,
))
->condition('vid', $node->vid)
->execute();
}
else {
db_insert('context_node')
->fields(array(
'nid' => $node->nid,
'vid' => $node->vid,
'context' => $node->context,
))
->execute();
}
}
}