You are here

function biblio_hash in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 biblio.module \biblio_hash()
  2. 7 biblio.module \biblio_hash()
  3. 7.2 biblio.module \biblio_hash()
1 call to biblio_hash()
_biblio_prepare_submit in ./biblio.module
Prepare a node for submit to database. Contains code common to insert and update.

File

./biblio.module, line 2266

Code

function biblio_hash($node) {
  static $sums = array();
  if (empty($sums)) {
    $res = db_query("SELECT nid, biblio_md5 FROM {biblio} ");
    while ($md5 = db_fetch_object($res)) {
      $sums[$md5->biblio_md5] = $md5->nid;
    }
  }
  $hash_string = str_replace(' ', '', drupal_strtolower($node->title));
  $hash_string .= str_replace(' ', '', drupal_strtolower($node->biblio_contributors[1][0]['lastname']));
  $hash_string .= $node->biblio_year;
  $sum = md5($hash_string);
  if (isset($sums[$sum])) {
    $duplicate = $sums[$sum];
  }
  else {
    $sums[$sum] = $node->nid;
  }
  $node->biblio_md5 = $sum;
  return $duplicate;

  //return the nid of the potential duplicate
}