function getlocations_fields_handler_filter_country::query in Get Locations 7
Same name and namespace in other branches
- 7.2 modules/getlocations_fields/handlers/getlocations_fields_handler_filter_country.inc \getlocations_fields_handler_filter_country::query()
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides views_handler_filter_in_operator::query
File
- modules/
getlocations_fields/ handlers/ getlocations_fields_handler_filter_country.inc, line 146 - getlocations_fields_handler_filter_country.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Class
- getlocations_fields_handler_filter_country
- @file getlocations_fields_handler_filter_country.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function query() {
if (empty($this->value)) {
return;
}
$this
->ensure_my_table();
$field = $this->table_alias . '.' . $this->real_field;
// Normalize values.
$value = $this->value;
if (is_array($value)) {
if (count($value) == 1) {
// If multiple is allowed but only one was chosen, use a string instead.
$value = reset($value);
}
}
if (is_array($value)) {
// Multiple values
$operator = $this->operator == 'in' ? 'IN' : 'NOT IN';
$this->query
->add_where($this->options['group'], $field, $value, $operator);
}
else {
// Single value
$operator = $this->operator == 'in' ? '=' : '!=';
$this->query
->add_where($this->options['group'], $field, $value, $operator);
}
}