You are here

function device_geolocation_form_alter in Smart IP 7

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

Implements hook_form_alter()

File

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

Code

function device_geolocation_form_alter(&$form, &$form_state, $form_id) {

  // Add additional textarea form field for "Geolocate on specific pages"
  if ($form_id == 'smart_ip_admin_settings') {
    $form['smart_ip_preferences']['device_geolocation_allowed_pages'] = array(
      '#title' => t("Ask user's geolocation on specific Drupal native pages"),
      '#type' => 'textarea',
      '#rows' => 5,
      '#description' => t("Specify pages by using their paths (not the aliased path). Enter one path per line. The '*' character is a wildcard. Example paths are blog for the blog page and blog/* for every personal blog. <front> is the front page. Leave blank if all pages."),
      '#default_value' => variable_get('device_geolocation_allowed_pages', ''),
    );
    $form['smart_ip_preferences']['device_geolocation_ajax_check'] = array(
      '#type' => 'checkbox',
      '#title' => t("Use AJAX in user's geolocation checking (useful if the site or pages listed above are cached)"),
      '#default_value' => variable_get('device_geolocation_ajax_check', FALSE),
    );
    $form['smart_ip_preferences']['device_geolocation_check_frequency'] = array(
      '#title' => t("Frequency of user's geolocation checking"),
      '#type' => 'textfield',
      '#size' => 10,
      '#description' => t('Specify number of hours will prompt the user for geolocation.'),
      '#default_value' => variable_get('device_geolocation_check_frequency', 0) / 3600,
      '#field_suffix' => t('hours'),
    );

    //variable_get('device_geolocation_check_frequency', 0)
    $form['#validate'][] = '_device_geolocation_allowed_pages_validate';
  }
}