You are here

function getlocations_usermap in Get Locations 7

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

Page callback: Displays a map.

Parameters

int $uid:

Return value

Returns a map of locations of a user

1 call to getlocations_usermap()
getlocations_box in ./getlocations.module
Function for colorbox and suchlike
1 string reference to 'getlocations_usermap'
getlocations_menu in ./getlocations.module
Implements hook_menu().

File

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

Code

function getlocations_usermap($uid) {
  $getlocations_defaults = getlocations_defaults();
  $marker = $getlocations_defaults['user_map_marker'];
  $locations = getlocations_load_locations($uid, 'uid');
  $account = user_load($uid);
  $latlons = array();
  $minmaxes = array(
    'minlat' => 0,
    'minlon' => 0,
    'maxlat' => 0,
    'maxlon' => 0,
  );
  $ct = 0;
  $extra_info = array();
  $sv_info = FALSE;
  $map_info = FALSE;
  $module = getlocations_get_current_supported_module();
  if (count($locations)) {

    // we should loop over them and dump bummers with no lat/lon
    foreach ($locations as $key => $location) {
      if ($latlon = getlocations_latlon_check($location['latitude'] . ',' . $location['longitude'])) {
        $ll = explode(',', $latlon);
        $location['latitude'] = $ll[0];
        $location['longitude'] = $ll[1];
        $minmaxes = getlocations_do_minmaxes($ct, $location, $minmaxes);
        if (!isset($location['key'])) {
          $location['key'] = '';
        }
        else {
          $location['lid'] = $uid;
        }

        // per location marker
        if (isset($location['marker']) && !empty($location['marker'])) {
          $marker = $location['marker'];
        }
        $name = htmlspecialchars_decode(isset($location['name']) ? strip_tags($location['name']) : strip_tags($account->name), ENT_QUOTES);
        $latlons[$ct] = array(
          $location['latitude'],
          $location['longitude'],
          $location['lid'],
          $name,
          $marker,
          $location['key'],
          '',
          '',
        );
        $sv_info = FALSE;
        if ($module == 'getlocations_fields' && count($locations) == 1) {
          if (getlocations_fields_streetview_settings_allow()) {
            $sv_info = getlocations_fields_svinfo($location);
          }
          if (getlocations_fields_map_settings_allow()) {
            $map_info = getlocations_fields_mapinfo($location);
          }
        }
        $ct++;
      }
    }
  }
  if ($ct < 2) {
    unset($minmaxes);
    $minmaxes = '';
  }
  drupal_set_title(t('View user !t locations', array(
    '!t' => $account->name,
  )));
  if ($sv_info) {
    $extra_info = array_merge($extra_info, $sv_info);
  }
  if ($map_info) {
    $extra_info = array_merge($extra_info, $map_info);
  }
  return getlocations_setlocations($latlons, $minmaxes, 'user', $account, $extra_info);
}