diff --git a/includes/fivestar_views_handler_filter_in_operator.inc b/includes/fivestar_views_handler_filter_in_operator.inc index 3c969ac..cd1476a 100644 --- a/includes/fivestar_views_handler_filter_in_operator.inc +++ b/includes/fivestar_views_handler_filter_in_operator.inc @@ -55,8 +55,6 @@ class fivestar_views_handler_filter_in_operator extends views_handler_filter_in_ $or_statement->condition("$this->table_alias.$this->real_field", array_values($this->value), $this->operator); } - // Add zero condition if zero is in the values, or if it's not and the - // operator is 'not in' (to also show 0 stars when "not in (1, 2)"). $selected_val_count = count(array_values($this->value)); $first_element = reset($this->value); // 'IN' Condition. @@ -67,19 +65,19 @@ class fivestar_views_handler_filter_in_operator extends views_handler_filter_in_ $or_statement->condition("$this->table_alias.$this->real_field", NULL, $nul_operator); $this->query->add_where($this->options['group'], $or_statement); } - if ($first_element != 0) { + elseif ($first_element != 0) { $operator = 'IN'; $and_statement->condition("$this->table_alias.$this->real_field", array_values($this->value), $operator); $this->query->add_where($this->options['group'], $and_statement); } } - if ($selected_val_count > 1) { + elseif ($selected_val_count > 1) { if ($first_element == 0) { $nul_operator = ($has_nul == 0) ? 'IS NOT NULL' : 'IS NULL'; $or_statement->condition("$this->table_alias.$this->real_field", NULL, $nul_operator); $this->query->add_where($this->options['group'], $or_statement); } - if ($first_element != 0) { + elseif ($first_element != 0) { $operator = 'IN'; $and_statement->condition("$this->table_alias.$this->real_field", array_values($this->value), $operator); $this->query->add_where($this->options['group'], $and_statement); @@ -87,14 +85,14 @@ class fivestar_views_handler_filter_in_operator extends views_handler_filter_in_ } } // 'NOT IN' Condition. - if ($this->operator == 'not in') { - if ($has_nul == 1) { - if ($selected_val_count == 1 && $first_element == 0) { + elseif ($this->operator == 'not in') { + if ($has_nul == 1 && $first_element == 0) { + if ($selected_val_count == 1) { $nul_operator = 'IS NOT NULL'; $and_statement->condition("$this->table_alias.$this->real_field", array_values($this->value), $nul_operator); $this->query->add_where($this->options['group'], $and_statement); } - if ($selected_val_count > 1 && $first_element == 0) { + elseif ($selected_val_count > 1) { $operator = 'NOT IN'; $nul_operator = 'IS NOT NULL'; $and_statement->condition("$this->table_alias.$this->real_field", array_values($this->value), $operator); @@ -102,7 +100,7 @@ class fivestar_views_handler_filter_in_operator extends views_handler_filter_in_ $this->query->add_where($this->options['group'], $and_statement); } } - if ($has_nul == 0) { + elseif ($has_nul == 0) { $nul_operator = 'IS NULL'; $or_statement->condition("$this->table_alias.$this->real_field", NULL, $nul_operator); $this->query->add_where($this->options['group'], $or_statement);