You are here

function smart_ip_views_bridge_form_alter in Smart IP 6

Same name and namespace in other branches
  1. 6.2 modules/smart_ip_views_bridge/smart_ip_views_bridge.module \smart_ip_views_bridge_form_alter()
  2. 7.2 modules/smart_ip_views_bridge/smart_ip_views_bridge.module \smart_ip_views_bridge_form_alter()

Implements hook_form_alter().

File

modules/smart_ip_views_bridge/smart_ip_views_bridge.module, line 122
Smart IP Views Bridge exposes Smart IP visitor's location details to Views field (coordinates, country, ISO 3166 2-character country code, region, region code (FIPS), city and zip) and filter (country, ISO 3166 2-character country code,…

Code

function smart_ip_views_bridge_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_ui_config_item_form' && $form_state['section'] == 'filters') {
    $description = smart_ip_views_bridge_form_fields_description();

    /* // Openlayers location field
       if (isset($form['options']['value']['location'])) {
         $form['options']['value']['location']['#description'] .= $description;
       } */
    if (is_array($form['options']['operator']['#options']) && (array_key_exists('=', $form['options']['operator']['#options']) || array_key_exists('is', $form['options']['operator']['#options']) || array_key_exists('in', $form['options']['operator']['#options']) || array_key_exists('or', $form['options']['operator']['#options']))) {
      if ($form['options']['value']['#type'] == 'textfield') {
        $form['options']['value']['#description'] = $description;
      }
      if ($form['options']['value']['#type'] == 'select' || $form['options']['value']['#type'] == 'checkboxes') {
        $form['options']['value']['#options']['smart_ip.location.country'] = t("Smart IP: visitor's country");
        $form['options']['value']['#options']['smart_ip.location.country_code'] = t("Smart IP: visitor's country code");
        $form['options']['value']['#options']['smart_ip.location.region'] = t("Smart IP: visitor's region");
        $form['options']['value']['#options']['smart_ip.location.region_code'] = t("Smart IP: visitor's region code");
        $form['options']['value']['#options']['smart_ip.location.city'] = t("Smart IP: visitor's city");
        $form['options']['value']['#options']['smart_ip.location.zip'] = t("Smart IP: visitor's zip");
      }
    }
  }
}