function similarterms_node_save in Similar By Terms 7
Same name and namespace in other branches
- 6 similarterms.module \similarterms_node_save()
Function to populate overrides table
2 calls to similarterms_node_save()
- similarterms_node_insert in ./
similarterms.module - Implements hook_node_insert().
- similarterms_node_update in ./
similarterms.module - Implements hook_node_update().
File
- ./
similarterms.module, line 411 - Similar By Terms module displays a block with similar content based on taxonomy terms.
Code
function similarterms_node_save($node) {
if (!variable_get('similarterms_override_options', 0)) {
return;
}
$result = array();
$query = "INSERT INTO {similarterms_override} (nid, path, vid) VALUES(%d, %d, %d)";
foreach (similarterms_taxonomy_get_vocabularies() as $v) {
$vid = 'similarterms_vid_' . $v->vid;
$alias =& $node->{$vid};
similarterms_node_delete($node, $v->vid);
if ($alias['similarterms_override_delete']) {
continue;
}
foreach ($alias['similarterms_paths'] as $id => $path) {
$pieces = explode('/', $path);
if (sizeof($pieces) == 2 && $pieces[0] == "node" && is_numeric($pieces[1])) {
$nid = $pieces[1];
}
else {
$path = drupal_lookup_path('source', $path);
$pieces = explode('/', $path);
$nid = $pieces[1];
}
if ($nid) {
$args = array(
$node->nid,
$nid,
$v->vid,
);
$result[$id] = db_query($query, $args);
}
}
}
}