You are here

function getlocations_get_type_from_lid in Get Locations 7.2

Same name and namespace in other branches
  1. 7 getlocations.module \getlocations_get_type_from_lid()

Function to get type for getlocations_fields and location modules only

Parameters

int $lid:

Return value

Returns node type

1 call to getlocations_get_type_from_lid()
getlocations_getinfo in ./getlocations.module

File

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

Code

function getlocations_get_type_from_lid($lid) {
  if (is_numeric($lid) && $lid) {
    $query = FALSE;
    if (module_exists('getlocations_fields')) {
      $info = getlocations_get_entity_info_from_glid($lid);
      return $info['entity_type'];
    }
    elseif (module_exists('location') && (module_exists('location_cck') || module_exists('location_node') || module_exists('location_user'))) {
      $query = db_select('location_instance', 'i')
        ->fields('i', array(
        'nid',
        'uid',
      ))
        ->condition('i.lid', $lid);
    }
    if ($query) {
      $row = $query
        ->execute()
        ->fetchAssoc();
      $type = '';
      if (isset($row['nid']) && $row['nid'] > 0) {
        $type = 'node';
      }
      elseif (isset($row['uid']) && $row['uid'] > 0) {
        $type = 'user';
      }
      elseif (isset($row['tid']) && $row['tid'] > 0 && module_exists('taxonomy')) {
        $type = 'vocabulary';
      }
      elseif (isset($row['cid']) && $row['cid'] > 0 && module_exists('comment')) {
        $type = 'comment';
      }
      return $type;
    }
  }
  return FALSE;
}