function document_update in Document 8.x
Same name and namespace in other branches
- 6 document.module \document_update()
- 7 document.module \document_update()
Implementation of hook_update().
File
- ./
document.module, line 390
Code
function document_update($node) {
//$revisions = node_revision_list($node);
// if this is a new node or we're adding a new revision,
if (property_exists($node, 'revision') && $node->revision) {
document_insert($node);
}
else {
if (!isset($node->document_publishing)) {
//While publishing a document in the callback, other fields cannot change. But taxonomy is not available,
//and hence we should not make any updations during async document publishing by the node.
$author = $node->document_author;
$year = $node->document_year;
$type = _document_get_node_terms($node);
$keywords = $node->document_keywords;
$abstract = $node->document_abstract;
//The Url/External status of a document cannot change without creating a revision.
//A revision would lead to insertion code above. So, no need to update Url/External status.
db_update('document')
->fields(array(
'type' => $type,
'author' => $author,
'publish_year' => $year,
'abstract' => $abstract,
'keywords' => $keywords,
))
->condition('nid', $node->nid)
->condition('vid', $node->vid)
->execute();
}
}
}