You are here

function gmap_taxonomy_taxonomy_term_update in GMap Module 7.2

Same name and namespace in other branches
  1. 7 gmap_taxonomy.module \gmap_taxonomy_taxonomy_term_update()

Implements hook_taxonomy_term_update().

@todo move this to GmapTaxonomyCRUDi class

1 call to gmap_taxonomy_taxonomy_term_update()
gmap_taxonomy_taxonomy_term_insert in ./gmap_taxonomy.module
Implements hook_taxonomy_term_insert().

File

./gmap_taxonomy.module, line 117
GMap Taxonomy Markers

Code

function gmap_taxonomy_taxonomy_term_update($term) {
  if (gmap_taxonomy_vocabulary_is_enabled($term->vid)) {

    // If Synchronize translations module is enabled,
    // and the term reference field is set to a i18n_sync field,
    // when we update a node, will trigger a term
    // update, and the $term->gmap_taxonomy_marker is not set.
    // Indicates this is a term edit form submit.
    if (isset($term->gmap_taxonomy_marker)) {
      db_delete('gmap_taxonomy_term')
        ->condition('tid', $term->tid)
        ->execute();

      // Do we have an assigned marker?
      if (!empty($term->gmap_taxonomy_marker)) {
        db_insert('gmap_taxonomy_term')
          ->fields(array(
          'tid' => $term->tid,
          'marker' => $term->gmap_taxonomy_marker,
        ))
          ->execute();

        // Update name changes in the gmap_taxonomy_node table.
        db_update('gmap_taxonomy_node')
          ->fields(array(
          'marker' => $term->gmap_taxonomy_marker,
        ))
          ->condition('tid', $term->tid)
          ->execute();
      }
      gmap_taxonomy_reassign_marker($term->tid);
    }
  }
}