function gmap_taxonomy_reassign_marker in GMap Module 6
Same name and namespace in other branches
- 5 gmap_taxonomy.module \gmap_taxonomy_reassign_marker()
- 6.2 gmap_taxonomy.module \gmap_taxonomy_reassign_marker()
- 7.2 gmap_taxonomy.module \gmap_taxonomy_reassign_marker()
- 7 gmap_taxonomy.module \gmap_taxonomy_reassign_marker()
Reassign markers associated with a term that's going away.
1 call to gmap_taxonomy_reassign_marker()
- gmap_taxonomy_taxonomy in ./
gmap_taxonomy.module - Implementation of hook_taxonomy().
File
- ./
gmap_taxonomy.module, line 159 - GMap Taxonomy Markers
Code
function gmap_taxonomy_reassign_marker($tid, $table = 'term_node') {
$result = db_query('SELECT vid FROM {' . db_escape_table($table) . '} WHERE tid = %d', $tid);
while ($node = db_fetch_object($result)) {
$markers = db_query('SELECT t.tid, gt.marker FROM {term_node} r INNER JOIN {gmap_taxonomy_term} gt ON r.tid = gt.tid INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight DESC, t.weight DESC, t.name DESC', $node->vid);
if ($marker = db_fetch_object($markers)) {
// Fallback found.
db_query("UPDATE {gmap_taxonomy_node} SET tid = %d, marker = '%s' WHERE vid = %d", $marker->tid, $marker->marker, $node->vid);
}
else {
// No replacement marker, delete the row.
db_query("DELETE FROM {gmap_taxonomy_node} WHERE vid = %d", $marker->vid);
}
}
}