function gmap_taxonomy_taxonomy in GMap Module 6
Same name and namespace in other branches
- 5 gmap_taxonomy.module \gmap_taxonomy_taxonomy()
- 6.2 gmap_taxonomy.module \gmap_taxonomy_taxonomy()
Implementation of hook_taxonomy().
File
- ./
gmap_taxonomy.module, line 73 - GMap Taxonomy Markers
Code
function gmap_taxonomy_taxonomy($op, $type, $array = NULL) {
if ($type == 'vocabulary') {
switch ($op) {
case 'insert':
case 'update':
// This can get called in other places than vocabulary form submission.
// @@@ TODO move this to the form itself..
if (isset($array['gmap_taxonomy_enable'])) {
$status = variable_get('gmap_taxonomy_vocabs', array());
$status[$array['vid']] = $array['gmap_taxonomy_enable'];
variable_set('gmap_taxonomy_vocabs', $status);
}
break;
case 'delete':
$status = variable_get('gmap_taxonomy_vocabs', array());
unset($status[$array['vid']]);
variable_set('gmap_taxonomy_vocabs', $status);
}
}
else {
switch ($op) {
case 'insert':
case 'update':
$vocabs = variable_get('gmap_taxonomy_vocabs', array());
if (isset($vocabs[$array['vid']]) && $vocabs[$array['vid']]) {
db_query('DELETE FROM {gmap_taxonomy_term} WHERE tid = %d', $array['tid']);
// Do we have an assigned marker?
if (!empty($array['gmap_taxonomy_marker'])) {
db_query("INSERT INTO {gmap_taxonomy_term} (tid, marker) VALUES (%d, '%s')", $array['tid'], $array['gmap_taxonomy_marker']);
// Update name changes in the gmap_taxonomy_node table.
db_query("UPDATE {gmap_taxonomy_node} SET marker = '%s' WHERE tid = %d", $array['gmap_taxonomy_marker'], $array['tid']);
}
gmap_taxonomy_reassign_marker($array['tid']);
}
break;
case 'delete':
// Delete and reassign even if the term isn't currently gmap_taxonomy enabled.
db_query('DELETE FROM {gmap_taxonomy_term} WHERE tid = %d', $array['tid']);
// Use gmap_taxonomy_node for search because term_node rows are already gone.
gmap_taxonomy_reassign_marker($array['tid'], 'gmap_taxonomy_node');
}
}
}