You are here

function location_taxonomy_taxonomy in Location 6.3

Same name and namespace in other branches
  1. 7.4 contrib/location_taxonomy/location_taxonomy.module \location_taxonomy_taxonomy()

Implementation of hook_taxonomy().

File

contrib/location_taxonomy/location_taxonomy.module, line 17
Associate locations with taxonomy terms.

Code

function location_taxonomy_taxonomy($op, $type, $array = NULL) {
  if ($type == 'vocabulary') {
    switch ($op) {
      case 'insert':
      case 'update':
        if (isset($array['location_settings'])) {
          variable_set('location_taxonomy_' . $array['vid'], $array['location_settings']);
        }
        break;
      case 'delete':
        variable_del('location_taxonomy_' . $array['vid']);
        break;
    }
  }
  else {
    switch ($op) {
      case 'insert':
      case 'update':
        $settings = variable_get('location_taxonomy_' . $array['vid'], FALSE);
        if ($settings && $settings['multiple']['max']) {
          location_save_locations($array['locations'], array(
            'genid' => 'taxonomy:' . $array['tid'],
          ));
        }
        break;
      case 'delete':
        $locations = array();
        location_save_locations($locations, array(
          'genid' => 'taxonomy:' . $array['tid'],
        ));
        break;
    }
  }
}