function gmap_location_user_page in GMap Module 7
Same name and namespace in other branches
- 5 gmap_location.module \gmap_location_user_page()
- 6.2 gmap_location.module \gmap_location_user_page()
- 6 gmap_location.module \gmap_location_user_page()
- 7.2 gmap_location.module \gmap_location_user_page()
Draws a page with a google map that has all of the site users.
1 string reference to 'gmap_location_user_page'
- gmap_location_menu in ./
gmap_location.module - Implementation of hook_menu().
File
- ./
gmap_location.module, line 111 - GMap Location module is a module to add some gmap funcationality based on location.modules information.
Code
function gmap_location_user_page() {
$markertypes = variable_get('gmap_role_markers', array(
DRUPAL_AUTHENTICATED_RID => 'drupal',
));
$usermap = variable_get('gmap_user_map', _gmap_location_user_map_defaults());
$map = array_merge(gmap_defaults(), gmap_parse_macro($usermap['macro']));
$mode = $usermap['markermode'];
$map['rmtcallback'] = url('map/user/load');
$map['markermode'] = $usermap['markermode'];
// Find the highest rid, if available, for each user with a location.
$result = db_query("\n SELECT\n u.name, MAX(r.rid) as role, i.uid, i.lid, l.latitude, l.longitude\n FROM\n {users} u\n INNER JOIN\n {location_instance} i\n ON\n u.uid = i.uid\n INNER JOIN\n {location} l\n ON\n i.lid = l.lid\n LEFT JOIN\n {users_roles} r\n ON\n i.uid = r.uid\n WHERE\n u.status = 1\n AND\n u.access != 0\n AND\n (l.latitude != 0 OR l.longitude != 0)\n GROUP BY\n i.uid, i.lid, u.name, l.latitude, l.longitude");
// The u.name, l.latitude, and l.longitude in the GROUP BY are needed for
// PostgreSQL.
foreach ($result as $row) {
// Determine marker type to show.
$marker = $markertypes[DRUPAL_AUTHENTICATED_RID];
if ($row->role && isset($markertypes[$row->role])) {
$marker = $markertypes[$row->role];
}
// Users with the 'view user location details' permission are allowed to see who
// each marker represents.
if (user_access('view user location details')) {
if ($mode == 1) {
$newmarker['rmt'] = $row->uid;
}
elseif ($mode == 2) {
$newmarker['link'] = url('user/' . $row->uid);
}
$newmarker['latitude'] = $row->latitude;
$newmarker['longitude'] = $row->longitude;
$newmarker['markername'] = $marker;
$newmarker['opts']['title'] = check_plain($row->name);
}
else {
$newmarker['latitude'] = $row->latitude;
$newmarker['longitude'] = $row->longitude;
$newmarker['markername'] = $marker;
}
$map['markers'][] = $newmarker;
}
// @@@ Move to gmap_addons.
/*
if (user_access('view user location details') && function_exists('buddylist_get_buddies') && count($locationbyuser)>0) {
//create lines for buddies
if (!isset($thismap['shapes'])) {
$thismap['shapes']=array();
}
ksort($locationbyuser);
foreach ($locationbyuser as $key => $value) {
$buddies= buddylist_get_buddies($key);
foreach ($buddies as $bkey => $bvalue) {
if ($bkey > $key && isset($locationbyuser[$bkey])) {
$thismap['shape'][] = array(
'points' => array($locationbyuser[$key], $locationbyuser[$bkey]),
'type' => 'line'
);
}
}
}
}
*/
$element = array(
'#type' => 'gmap',
'#gmap_settings' => $map,
);
return theme('gmap_location_user_page', array(
'header' => $usermap['header'],
'map' => drupal_render($element),
'footer' => $usermap['footer'],
));
}