You are here

function device_geolocation_contents in Smart IP 7.2

Same name and namespace in other branches
  1. 6.2 modules/device_geolocation/device_geolocation.module \device_geolocation_contents()
  2. 6 modules/device_geolocation/device_geolocation.module \device_geolocation_contents()
  3. 7 modules/device_geolocation/device_geolocation.module \device_geolocation_contents()

Device geolocation block content function.

1 call to device_geolocation_contents()
device_geolocation_block_view in modules/device_geolocation/device_geolocation.module
Implements hook_block_view().

File

modules/device_geolocation/device_geolocation.module, line 91
Provides visitor's geographical location using client device location source that implements W3C Geolocation API and Google Geocoding service.

Code

function device_geolocation_contents() {
  $location = array();
  $smart_ip_session = smart_ip_session_get('smart_ip');

  // Smart IP user $_SESSION
  if (!is_null($smart_ip_session)) {
    $location = $smart_ip_session['location'];
  }
  else {
    global $user;
    if (isset($user->data['geoip_location'])) {
      $smart_ip_session['location'] = $user->data['geoip_location'];
      smart_ip_session_set('smart_ip', $smart_ip_session);
      $location = $smart_ip_session['location'];
    }
  }
  return theme('device_geolocation_visitor_info', array(
    'location' => $location,
  ));
}