function device_geolocation_check_geolocation_attempt in Smart IP 6.2
Same name and namespace in other branches
- 6 modules/device_geolocation/device_geolocation.module \device_geolocation_check_geolocation_attempt()
- 7.2 modules/device_geolocation/device_geolocation.module \device_geolocation_check_geolocation_attempt()
- 7 modules/device_geolocation/device_geolocation.module \device_geolocation_check_geolocation_attempt()
Check for Geolocation attempt.
2 calls to device_geolocation_check_geolocation_attempt()
- device_geolocation_check_geolocation_attempt_ajax in modules/
device_geolocation/ device_geolocation.module - Check for Geolocation attempt ajax callback.
- device_geolocation_init in modules/
device_geolocation/ device_geolocation.module - Implements hook_init().
File
- modules/
device_geolocation/ device_geolocation.module, line 343 - Provides visitor's geographical location using client device location source that implements W3C Geolocation API and Google Geocoding service.
Code
function device_geolocation_check_geolocation_attempt() {
$device_geolocation_check_frequency = variable_get('device_geolocation_check_frequency', NULL);
$timestamp = smart_ip_session_get('device_geolocation_attempt');
$request_time = (int) $_SERVER['REQUEST_TIME'];
if ($device_geolocation_check_frequency === NULL) {
// User's device geolocation checking is set disabled
return FALSE;
}
elseif (is_null(smart_ip_session_get('device_geolocation')) && empty($timestamp)) {
// The user has not allowed to share his/her location yet then return that user's location needs
// update and start the timer.
smart_ip_session_set('device_geolocation_attempt', $request_time);
return TRUE;
}
elseif (!empty($timestamp) && $device_geolocation_check_frequency < $request_time - $timestamp) {
// Return that user's location needs update and reset the timer.
smart_ip_session_set('device_geolocation_attempt', $request_time);
return TRUE;
}
return FALSE;
}