You are here

function getlocations_get_nid_from_lid in Get Locations 7

Same name and namespace in other branches
  1. 6.2 getlocations.module \getlocations_get_nid_from_lid()
  2. 6 getlocations.module \getlocations_get_nid_from_lid()
  3. 7.2 getlocations.module \getlocations_get_nid_from_lid()

Function to get nid from getlocations_fields_entities or location_instance table.

Parameters

int $lid:

Return value

Returns nid.

4 calls to getlocations_get_nid_from_lid()
getlocations_getinfo in ./getlocations.module
template_preprocess_getlocations_leaflet_view_map in modules/getlocations_leaflet/views/getlocations_leaflet.views.inc
Preprocess function for getlocations_leaflet_view_map.tpl
template_preprocess_getlocations_mapquest_view_map in modules/getlocations_mapquest/views/getlocations_mapquest.views.inc
Preprocess function for getlocations_mapquest_view_map.tpl
template_preprocess_getlocations_view_map in views/getlocations.views.inc
Preprocess function for getlocations_view_map.tpl

File

./getlocations.module, line 1769
getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_get_nid_from_lid($lid) {
  if (is_numeric($lid) && $lid) {
    $query = FALSE;
    if (module_exists('getlocations_fields')) {
      $query = db_select('getlocations_fields_entities', 'i')
        ->fields('i', array(
        'nid',
      ))
        ->condition('i.glid', $lid);
    }
    elseif (module_exists('location') && (module_exists('location_cck') || module_exists('location_node'))) {
      $query = db_select('location_instance', 'i')
        ->fields('i', array(
        'nid',
      ))
        ->condition('i.lid', $lid);
    }
    if ($query) {
      $row = $query
        ->execute()
        ->fetchAssoc();
      return isset($row['nid']) && $row['nid'] ? $row['nid'] : FALSE;
    }
  }
  return FALSE;
}