/**
* Implementation of hook_nodeapi().
*
* get taxonomy terms from node that's about to be inserted
* and query them on existing content of content type 'klant' to see
* if there are any matching nodes by term.
**/
function matchmaker_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'insert':
db_query("INSERT INTO {matchmaker} (nid, matchid1, matchid2) VALUES (%d, %d, %d)",
$node->nid, $node->field_off_land_cur[0]['value'], $node->field_off_land_new[1]['value']);
drupal_set_message('Match Maker Module triggered: ' . $node->nid.' + '.$node->field_off_land_cur[0]['value'] . ' + ' . $node->field_off_land_new[1]['value']);
break;
case 'view':
// haal alle nodes op die overeenkomen met de taxonomy terms van de huidige offerte
$related = db_query("SELECT DISTINCT tn.nid FROM {term_node} tn WHERE (tn.tid = %d OR tn.tid = %d) ORDER BY RAND() LIMIT 0,5",
$node->field_off_land_cur[0]['value'], $node->field_off_land_new[1]['value']);
$nids = array();
while ($book = db_fetch_array($related)) {
$nids[] = $book['nid'];
}
// return an unordered list of related nodes by using the Drupal theme() function.
return theme('item_list', $nids);
break;
}
}