diff --git a/Civi/DataProcessor/DataFlow/SqlDataFlow/SimpleWhereClause.php b/Civi/DataProcessor/DataFlow/SqlDataFlow/SimpleWhereClause.php index fa7bc95eed9c83c653c761e662e44a876282595e..1b4a518e136c5adc4e3d6785c547b18bf3970293 100644 --- a/Civi/DataProcessor/DataFlow/SqlDataFlow/SimpleWhereClause.php +++ b/Civi/DataProcessor/DataFlow/SqlDataFlow/SimpleWhereClause.php @@ -27,6 +27,11 @@ class SimpleWhereClause implements WhereClauseInterface { case '!=': $operator = 'NOT IN'; break; + + case 'IS NULL': + $operator = 'IS NULL'; + break; + } } @@ -34,6 +39,12 @@ class SimpleWhereClause implements WhereClauseInterface { $this->table_alias = $table_alias; $this->field = $field; $this->operator = $operator; + + if ($operator == 'IS NULL') { + $this->value = NULL; + return; + } + if (is_array($value)) { $esacpedValues = array(); foreach($value as $val) { @@ -61,6 +72,7 @@ class SimpleWhereClause implements WhereClauseInterface { case 'Memo': $this->value = "'" . \CRM_Utils_Type::escape($value, $valueType) . "'"; break; + default: $this->value = \CRM_Utils_Type::escape($value, $valueType); break; diff --git a/Civi/DataProcessor/FilterHandler/AbstractFilterHandler.php b/Civi/DataProcessor/FilterHandler/AbstractFilterHandler.php index 0c5c4feb66386ec4126a560cb1e8a095a52b5407..7f48920d58e7941fe51243c5cc5f27ed043312c1 100644 --- a/Civi/DataProcessor/FilterHandler/AbstractFilterHandler.php +++ b/Civi/DataProcessor/FilterHandler/AbstractFilterHandler.php @@ -319,6 +319,18 @@ abstract class AbstractFilterHandler { $isFilterSet = TRUE; } break; + + case 'null': + if (empty($submittedValues[$filterName . '_value'])) { + $filterParams = [ + 'op' => 'IS NULL', + 'value' => '', + ]; + $this->setFilter($filterParams); + $isFilterSet = TRUE; + } + break; + } } if ($this->isRequired() && !$isFilterSet) { @@ -483,6 +495,7 @@ abstract class AbstractFilterHandler { return array( 'IN' => E::ts('Is one of'), 'NOT IN' => E::ts('Is not one of'), + 'null' => E::ts('Is empty'), ); } $types = \CRM_Utils_Type::getValidTypes(); @@ -503,6 +516,7 @@ abstract class AbstractFilterHandler { '<' => E::ts('Is less than'), '>' => E::ts('Is greater than'), '!=' => E::ts('Is not equal to'), + 'null' => E::ts('Is empty'), ); break; } @@ -513,6 +527,7 @@ abstract class AbstractFilterHandler { 'sw' => E::ts('Starts with'), 'ew' => E::ts('Ends with'), 'nhas' => E::ts('Does not contain'), + 'null' => E::ts('Is empty'), ); } diff --git a/Civi/DataProcessor/FilterHandler/ContactFilter.php b/Civi/DataProcessor/FilterHandler/ContactFilter.php index 00b6a86c556d7b0553639cd7dfeb2d3964defc62..314e27a47f07293e2b79ef0c56ce5656b1ecc58c 100644 --- a/Civi/DataProcessor/FilterHandler/ContactFilter.php +++ b/Civi/DataProcessor/FilterHandler/ContactFilter.php @@ -162,6 +162,7 @@ class ContactFilter extends AbstractFieldFilterHandler { return array( 'IN' => E::ts('Is one of'), 'NOT IN' => E::ts('Is not one of'), + 'null' => E::ts('Is empty'), ); }