function biblio_hash in Bibliography Module 6.2
Same name and namespace in other branches
- 6 biblio.module \biblio_hash()
- 7 biblio.module \biblio_hash()
- 7.2 biblio.module \biblio_hash()
Return value
integer The node ID of a potential duplicate biblio content.
1 call to biblio_hash()
- _biblio_prepare_submit in ./
biblio.module - Prepares a biblio node for submit to database.
File
- ./
biblio.module, line 2345 - Main file for Drupal module biblio.
Code
function biblio_hash($node) {
static $sums = array();
$duplicate = NULL;
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));
if (isset($node->biblio_contributors[1][0]['lastname'])) {
$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
}