# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. --- W:\drupal-6.17\sites\all\modules\location\handlers\location_views_handler_filter_proximity.inc +++ W:\usdir\sites\all\modules\location\handlers\location_views_handler_filter_proximity.inc @@ -25,6 +25,7 @@ 'country' => '', 'search_distance' => 100, 'search_units' => 'mile', + 'geoip' => FALSE, ), ); @@ -149,7 +150,14 @@ ), '#default_value' => $this->value['search_units'], ); + if (module_exists('geoip')) { + $form['value']['geoip'] = array( + '#type' => 'checkbox', + '#title' => t('Default to IP location'), + '#default_value' => $this->value['geoip'], + ); } + } function exposed_form(&$form, &$form_state) { parent::exposed_form($form, $form_state); @@ -177,6 +185,7 @@ if ($type != 'postal') { unset($form[$key]['country']); } + unset($form[$key]['geoip']); } // Used from the distance field. @@ -187,6 +196,14 @@ } // @@@ Switch to mock location object and rely on location more? + if ($this->value['geoip'] && module_exists('geoip')) { + if ($geoip_location = geoip_city()) { + $this->value['latitude'] = $geoip_location->latitude; + $this->value['longitude'] = $geoip_location->longitude; + $return = $this->value['latitude'] && $this->value['longitude']; + } + } + if ($this->options['type'] == 'postal' || $this->options['type'] == 'postal_default') { // Force default for country. if ($this->options['type'] == 'postal_default') { @@ -201,12 +218,12 @@ $this->value['longitude'] = $coord['lon']; } else { - return false; + return $return; } } else { // @@@ Implement full address lookup? - return false; + return $return; } } if (empty($this->value['latitude']) || empty($this->value['longitude'])) {