You are here

function document_update in Document 6

Same name and namespace in other branches
  1. 7 document.module \document_update()
  2. 8.x document.module \document_update()

Implementation of hook_update().

File

./document.module, line 344

Code

function document_update($node) {

  //$revisions = node_revision_list($node);

  // if this is a new node or we're adding a new revision,
  if ($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;

      //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_query("UPDATE {document} SET type = '%s', author = '%s', publish_year = %d, keywords = '%s' WHERE nid = %d AND vid = %d", $type, $author, $year, $keywords, $node->nid, $node->vid);
    }
  }
}