Skip to content
Snippets Groups Projects
Commit f32f9a11 authored by jaapjansma's avatar jaapjansma
Browse files

Merge branch 'isemptyfilter' into 'master'

Add an 'Is Empty' filter

See merge request !23
parents 62110bff 82bb4c43
No related branches found
No related tags found
1 merge request!23Add an 'Is Empty' filter
......@@ -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;
......
......@@ -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'),
);
}
......
......@@ -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'),
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment