You are here

function getlocations_usersmap in Get Locations 6

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

Menu callback

Return value

Returns a map of locations of all the users

1 call to getlocations_usersmap()
getlocations_box in ./getlocations.module
1 string reference to 'getlocations_usersmap'
getlocations_menu in ./getlocations.module
Implementation of hook_menu().

File

./getlocations.module, line 323
Displays locations on a map. for Drupal 6 using version 3 googlemaps API

Code

function getlocations_usersmap() {
  if (module_exists('location_user')) {
    $getlocations_defaults = getlocations_defaults();
    $marker = $getlocations_defaults['user_map_marker'];
    $latlons = array();
    $minmaxes = array(
      'minlat' => 0,
      'minlon' => 0,
      'maxlat' => 0,
      'maxlon' => 0,
    );
    $result = db_query("SELECT uid, name FROM {users} WHERE status=1");
    $ct = 0;
    while ($row = db_fetch_object($result)) {
      $uid = $row->uid;
      $locations = getlocations_load_locations($uid, 'uid');
      if (count($locations)) {

        // we should loop over them and dump bummers with no lat/lon
        foreach ($locations as $key => $location) {
          if (getlocations_latlon_check($location['latitude'] . ',' . $location['longitude'])) {
            $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'];
            }
            $ct++;
            $name = htmlspecialchars_decode($location['name'] ? strip_tags($location['name']) : strip_tags($row->name), ENT_QUOTES);
            $latlons[] = array(
              $location['latitude'],
              $location['longitude'],
              $location['lid'],
              $name,
              $marker,
              $location['key'],
            );
          }
        }
      }
    }
    if ($ct < 2) {
      unset($minmaxes);
      $minmaxes = '';
    }
    return getlocations_setlocations($latlons, $minmaxes, 'users');
  }
}