function getlocations_update_7100 in Get Locations 7
File
- ./
getlocations.install, line 41 - getlocations.install @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_update_7100() {
$module = '';
if (module_exists('getlocations_fields')) {
$module = 'getlocations_fields';
}
elseif (module_exists('location_cck')) {
$module = 'location_cck';
}
elseif (module_exists('geolocation')) {
$module = 'geolocation';
}
elseif (module_exists('geofield')) {
$module = 'geofield';
}
if ($module) {
$var = variable_get('getlocations_node_marker', array(
'enable' => 0,
));
if ($var['enable'] == 1) {
$data = array();
$ct = 0;
$found = FALSE;
foreach ($var['content_type'] as $bundle => $m) {
if (isset($var['content_type'][$bundle]['map_marker'])) {
$found = TRUE;
$data[$ct]['bundle'] = $bundle;
$data[$ct]['map_marker'] = $m['map_marker'] ? $m['map_marker'] : 'drupal';
$query = db_select('field_config', 'f');
$query
->fields('i', array(
'field_name',
));
$query
->join('field_config_instance', 'i', 'f.id=i.field_id');
$query
->condition('i.bundle', $bundle)
->condition('i.entity_type', 'node')
->condition('f.module', $module)
->condition('f.active', 1);
$rows = $query
->execute();
foreach ($rows as $row) {
$data[$ct]['field_name'] = $row->field_name;
}
$ct++;
}
}
if ($found) {
$tmp = array();
foreach ($data as $d) {
$tmp = array_merge($tmp, array(
$d['bundle'] => array(
'field_name' => array(
$d['field_name'] => array(
'map_marker' => $d['map_marker'],
),
),
),
));
}
$data2['enable'] = 1;
$data2['content_type'] = $tmp;
variable_set('getlocations_node_marker', $data2);
}
}
}
}