function device_geolocation_init in Smart IP 7
Same name and namespace in other branches
- 6.2 modules/device_geolocation/device_geolocation.module \device_geolocation_init()
- 6 modules/device_geolocation/device_geolocation.module \device_geolocation_init()
- 7.2 modules/device_geolocation/device_geolocation.module \device_geolocation_init()
Implements hook_init().
File
- modules/
device_geolocation/ device_geolocation.module, line 16 - 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_add_js('http://maps.google.com/maps/api/js?sensor=true', array(
'scope' => 'footer',
'weight' => 0,
));
drupal_add_js(drupal_get_path('module', 'device_geolocation') . '/js/device_geolocation.js', array(
'scope' => 'footer',
'weight' => 1,
));
}
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', array(
'scope' => 'footer',
'weight' => 0,
));
}
}