You are here

function biblio_pm_node_update in Bibliography Module 7

File

modules/pubmed/biblio_pm.module, line 466

Code

function biblio_pm_node_update($node) {
  if (isset($node->biblio_pubmed_id) && !empty($node->biblio_pubmed_id)) {

    // Make sure stale entries are deleted.
    db_delete('biblio_pubmed')
      ->condition('nid', $node->nid)
      ->execute();

    // Write the new data.
    $node->biblio_pm_changed = time();
    drupal_write_record('biblio_pubmed', $node);
  }
  if (isset($node->biblio_pubmed_grants) && is_array($node->biblio_pubmed_grants) && !empty($node->biblio_pubmed_grants)) {
    db_delete('biblio_pubmed_grant_info')
      ->condition('nid', $node->nid)
      ->execute();
    foreach ($node->biblio_pubmed_grants as $grant) {
      $info = array(
        'nid' => $node->nid,
        'biblio_pubmed_id' => $node->biblio_pubmed_id,
      );
      $info += $grant;
      drupal_write_record('biblio_pubmed_grant_info', $info);
    }
  }
}