You are here

function _device_geolocation_allowed_pages_validate in Smart IP 6

Same name and namespace in other branches
  1. 7 modules/device_geolocation/device_geolocation.module \_device_geolocation_allowed_pages_validate()

Validation handler to update the "Geolocate on specific pages".

1 string reference to '_device_geolocation_allowed_pages_validate'
device_geolocation_form_alter in modules/device_geolocation/device_geolocation.module
Implements hook_form_alter()

File

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

Code

function _device_geolocation_allowed_pages_validate($form, &$form_state) {
  $list = check_plain($form_state['values']['device_geolocation_allowed_pages']);

  // Remove carriage return (in Windows)
  $list = str_replace("\r", '', $list);
  $list = str_replace('&lt;front&gt;', '<front>', $list);
  if (!empty($list)) {
    $list = explode("\n", $list);
  }
  else {
    $list = array();
  }
  $form_state['values']['device_geolocation_allowed_pages'] = $list;
  $value = $form_state['values']['device_geolocation_check_frequency'];
  if ($value !== '' && (!is_numeric($value) || $value < 0)) {
    form_set_error('device_geolocation_check_frequency', t("Frequency of user's geolocation checking must be a positive number."));
  }
  else {

    // Convert from hours to seconds
    $form_state['values']['device_geolocation_check_frequency'] = $value * 3600;
  }
}