diff --git a/handlers/views_handler_filter_string.inc b/handlers/views_handler_filter_string.inc index c50eff4..e371f94 100644 --- a/handlers/views_handler_filter_string.inc +++ b/handlers/views_handler_filter_string.inc @@ -19,6 +19,10 @@ class views_handler_filter_string extends views_handler_filter { $options = parent::option_definition(); $options['expose']['contains']['required'] = array('default' => FALSE, 'bool' => TRUE); + $options['op_location'] = array( + 'default' => 'WHERE', + 'export' => 'export_plugin', + ); return $options; } @@ -134,6 +138,21 @@ class views_handler_filter_string extends views_handler_filter { return $operators; } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $form['op_location'] = array( + '#type' => 'select', + '#required' => FALSE, + '#title' => t('Condition Location'), + '#description' => t('Advanced: Apply condition in WHERE clause, or in JOIN ON clause of RIGHT field table.'), + '#options' => array( + 'where' => 'WHERE', + 'on' => 'ON', + ), + '#default_value' => $this->options['op_location'], + ); + } /** * Build strings from the operators() for 'select' options @@ -250,7 +269,21 @@ class views_handler_filter_string extends views_handler_filter { } function op_equal($field) { - $this->query->add_where($this->options['group'], $field, $this->value, $this->operator()); + switch ($this->options['op_location']) { + case 'on': + $this->query->table_queue[$this->table_alias]['join']->extra[] = array( + 'field' => $this->real_field, + 'operator' => $this->options['operator'], + 'value' => $this->value, + ); + break; + case 'where': + default: + // Build piece of SQL. + $this->query->add_where($this->options['group'], $field, $this->value, $this->operator()); + break; + //dpm($this->query->table_queue[$right_handler->table]['join'], "Final table join conditions"); + } } function op_contains($field) { @@ -331,8 +364,22 @@ class views_handler_filter_string extends views_handler_filter { else { $operator = "IS NOT NULL"; } + switch ($this->options['op_location']) { + case 'on': + $this->query->table_queue[$this->table_alias]['join']->extra[] = array( + 'field' => $this->real_field, + 'operator' => $operator, + 'value' => NULL, + ); + break; + case 'where': + default: + // Build piece of SQL. + $this->query->add_where($this->options['group'], $field, NULL, $operator); + break; + } - $this->query->add_where($this->options['group'], $field, NULL, $operator); + } }