function getlocations_usersmap in Get Locations 7
Same name and namespace in other branches
- 6.2 getlocations.module \getlocations_usersmap()
- 6 getlocations.module \getlocations_usersmap()
- 7.2 getlocations.module \getlocations_usersmap()
Page callback: Displays a map.
Return value
Returns a map of locations of all the users
1 call to getlocations_usersmap()
- getlocations_box in ./
getlocations.module - Function for colorbox and suchlike
1 string reference to 'getlocations_usersmap'
- getlocations_menu in ./
getlocations.module - Implements hook_menu().
File
- ./
getlocations.module, line 484 - getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_usersmap() {
$getlocations_defaults = getlocations_defaults();
$marker = $getlocations_defaults['user_map_marker'];
$latlons = array();
$minmaxes = array(
'minlat' => 0,
'minlon' => 0,
'maxlat' => 0,
'maxlon' => 0,
);
$query = db_select('users', 'u')
->fields('u', array(
'uid',
'name',
))
->condition('u.status', 1);
$rows = $query
->execute();
$ct = 0;
foreach ($rows as $row) {
$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 ($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($row->name), ENT_QUOTES);
$latlons[$ct] = array(
$location['latitude'],
$location['longitude'],
$location['lid'],
$name,
$marker,
$location['key'],
'',
'',
);
$ct++;
}
}
}
}
if ($ct < 2) {
unset($minmaxes);
$minmaxes = '';
}
return getlocations_setlocations($latlons, $minmaxes, 'users');
}