You are here

function location_load_locations in Location 5

Same name and namespace in other branches
  1. 5.3 location.module \location_load_locations()
  2. 6.3 location.module \location_load_locations()
  3. 7.5 location.module \location_load_locations()
  4. 7.3 location.module \location_load_locations()
  5. 7.4 location.module \location_load_locations()
1 call to location_load_locations()
location_nodeapi in ./location.module
Implementation of hook_nodeapi().

File

./location.module, line 1281

Code

function location_load_locations($type, $node_or_user) {
  $res = db_query("SELECT * FROM {location} WHERE type = '%s' AND eid = %d ORDER BY lid", $type, $type == 'user' ? $node_or_user->uid : $node_or_user->vid);
  $locations = array();
  $location = array();
  $index = 0;
  while ($row = db_fetch_object($res)) {
    $locations[$index] = (array) $row;
    if (isset($locations[$index]['latitude'])) {
      $locations[$index]['lat'] = $locations[$index]['latitude'];
      $locations[$index]['lon'] = $locations[$index]['longitude'];
    }
    if ($extra = location_invoke_locationapi($locations[$index], 'load')) {
      $locations[$index] = array_merge($locations[$index], $extra);
    }
    $index++;
  }
  $location = count($locations) ? $locations[0] : array();
  return array(
    'locations' => $locations,
    'location' => $location,
  );
}