You are here

public function Creators::saveCreators in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 modules/bibtexParse/PARSECREATORS.php \Creators::saveCreators()
  2. 7.3 plugins/biblio_style/bibtex/PARSECREATORS.php \Creators::saveCreators()
  3. 7 modules/bibtexParse/PARSECREATORS.php \Creators::saveCreators()
  4. 7.2 modules/bibtexParse/PARSECREATORS.php \Creators::saveCreators()

File

bibtexParse/PARSECREATORS.php, line 85

Class

Creators

Code

public function saveCreators($nid, $vid) {
  if (!empty($this->authors)) {
    $this
      ->loadMD5();
    db_query('DELETE FROM {biblio_contributor} WHERE nid = %d AND vid = %d', $nid, $vid);
    foreach ($this->authors as $rank => $author) {
      if (empty($author['cid']) && !empty($this->md5)) {
        $author['cid'] = array_search($author['md5'], $this->md5);
      }
      if (empty($author['cid'])) {
        drupal_write_record('biblio_contributor_data', $author);
        $cid = db_last_insert_id('biblio_contributor_data', 'cid');
      }
      else {
        $cid = $author['cid'];
      }
      $link_array = array(
        'nid' => $nid,
        'vid' => $vid,
        'cid' => $cid,
        'rank' => $rank,
        'ctid' => $author['type'],
      );
      drupal_write_record('biblio_contributor', $link_array);
    }
  }
}