From b50916e02a4caf4a0f37e305d6116146fb38b5e8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 12 Mar 2021 10:52:10 -0500 Subject: [PATCH] Allow unknown columns in filters. Allow specifying the table name in FilterTerm. --- web/includes/Filter.php | 2 +- web/includes/FilterTerm.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/web/includes/Filter.php b/web/includes/Filter.php index b8e2d4088..3578a1d62 100644 --- a/web/includes/Filter.php +++ b/web/includes/Filter.php @@ -635,7 +635,7 @@ class Filter extends ZM_Object { if ( !FilterTerm::is_valid_attr($term['attr']) ) { Error('Unsupported filter attribute ' . $term['attr']); - return $this; + //return $this; } $terms = $this->terms(); diff --git a/web/includes/FilterTerm.php b/web/includes/FilterTerm.php index c6c3cf312..40937b943 100644 --- a/web/includes/FilterTerm.php +++ b/web/includes/FilterTerm.php @@ -41,6 +41,11 @@ class FilterTerm { Warning('Invalid cnj ' . $term['cnj'].' in '.print_r($term, true)); } } + if ( isset($term['tablename']) ) { + $this->tablename = $term['tablename']; + } else { + $this->tablename = 'E'; + } if ( isset($term['obr']) ) { if ( (string)(int)$term['obr'] == $term['obr'] ) { @@ -288,7 +293,10 @@ class FilterTerm { case 'Notes': case 'StateId': case 'Archived': - $sql .= 'E.'.$this->attr; + $sql .= $this->tablename.'.'.$this->attr; + break; + default : + $sql .= $this->tablename.'.'.$this->attr; } $sql .= $this->sql_operator(); $values = $this->sql_values();