You are here

function getlocations_get_uid_from_lid in Get Locations 7

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

Function to get uid from getlocations_fields_entities or location_instance table.

Parameters

int $lid:

Return value

Returns uid.

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

File

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

Code

function getlocations_get_uid_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(
        'uid',
      ))
        ->condition('i.glid', $lid);
    }
    elseif (module_exists('location') && module_exists('location_user')) {
      $query = db_select('location_instance', 'i')
        ->fields('i', array(
        'uid',
      ))
        ->condition('i.lid', $lid);
    }
    if ($query) {
      $row = $query
        ->execute()
        ->fetchAssoc();
      return isset($row['uid']) && $row['uid'] ? $row['uid'] : FALSE;
    }
  }
  return FALSE;
}