You are here

function getlocations_fields_update_record in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/getlocations_fields.module \getlocations_fields_update_record()

Create a location

Parameters

array $location: The location

array $relations: Relationship information

1 call to getlocations_fields_update_record()
getlocations_fields_save_locations in modules/getlocations_fields/getlocations_fields.module

File

modules/getlocations_fields/getlocations_fields.module, line 2241
getlocations_fields.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_update_record($location, $relations) {
  if (!isset($location['glid'])) {

    // this record does not exist yet
    $result = getlocations_fields_insert_record($location, $relations);
    return $result;
  }
  $noaddress = t('Enter an address');
  if (!isset($location['address']) || $location['address'] == $noaddress) {
    $location['address'] = '';
  }
  if (empty($location['latitude']) && empty($location['longitude'])) {
    return FALSE;
  }
  $num_updated = db_update('getlocations_fields')
    ->fields(array(
    'name' => getlocations_apoclean($location['name']),
    'street' => getlocations_apoclean($location['street']),
    'additional' => getlocations_apoclean($location['additional']),
    'city' => getlocations_apoclean($location['city']),
    'province' => getlocations_apoclean($location['province']),
    'postal_code' => getlocations_apoclean($location['postal_code']),
    'country' => check_plain($location['country']),
    'address' => getlocations_apoclean($location['address']),
    'latitude' => (double) $location['latitude'],
    'longitude' => (double) $location['longitude'],
    'marker' => $location['marker'] ? $location['marker'] : '',
    'data' => !empty($location['data']) ? serialize($location['data']) : '',
  ))
    ->condition('glid', $location['glid'])
    ->execute();
  getlocations_fields_update_record_relations($relations, $location['glid']);
}