function device_geolocation_init in Smart IP 6
Same name and namespace in other branches
- 6.2 modules/device_geolocation/device_geolocation.module \device_geolocation_init()
- 7.2 modules/device_geolocation/device_geolocation.module \device_geolocation_init()
- 7 modules/device_geolocation/device_geolocation.module \device_geolocation_init()
Implements hook_init().
File
- modules/
device_geolocation/ device_geolocation.module, line 15 - Provides visitor's geographical location using client device location source that implements W3C Geolocation API and Google Geocoding service.
Code
function device_geolocation_init() {
$user_allowed = !is_null(smart_ip_session_get('device_geolocation'));
// if true, the user has allowed to share his/her location
$ajax_check = variable_get('device_geolocation_ajax_check', FALSE) & !$user_allowed;
if ($ajax_check || device_geolocation_check_geolocation_attempt()) {
device_geolocation_get_coordinates();
if (!$ajax_check) {
drupal_add_js(array(
'device_geolocation' => array(
'ask_geolocate' => TRUE,
),
), 'setting');
}
drupal_set_html_head('<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>');
drupal_add_js(drupal_get_path('module', 'device_geolocation') . '/js/device_geolocation.js', 'module', 'footer');
}
if ($ajax_check) {
drupal_add_js(array(
'device_geolocation' => array(
'ask_geolocate' => FALSE,
),
), 'setting');
drupal_add_js(drupal_get_path('module', 'device_geolocation') . '/js/device_geolocation_check.js', 'module', 'footer');
}
}