function biblio_hash in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 biblio.module \biblio_hash()
- 6 biblio.module \biblio_hash()
- 7 biblio.module \biblio_hash()
Gets potential duplicate of a node
@staticvar array $sums
Parameters
object $node:
Return value
int the nid of the potential duplicate
File
- ./
biblio.module, line 2209
Code
function biblio_hash($node) {
static $sums = array();
$duplicate = NULL;
if (empty($sums)) {
$res = db_query("SELECT nid, biblio_md5 FROM {biblio} ");
foreach ($res as $md5) {
$sums[$md5->biblio_md5] = $md5->nid;
}
}
$hash_string = str_replace(' ', '', drupal_strtolower($node->title));
if (isset($node->biblio_contributors[0]['lastname'])) {
$hash_string .= str_replace(' ', '', drupal_strtolower($node->biblio_contributors[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
}