From bff191b649d7ade0298129353552c5eb6a8cbd2a Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 17 Feb 2015 16:49:07 -0600 Subject: [PATCH] filter: Fix filtering by list item properties --- include/class.dynamic_forms.php | 16 ++++++++++++++-- include/class.forms.php | 30 ------------------------------ include/class.list.php | 8 ++++++++ 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 173b09058..4a85ffabf 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1263,9 +1263,21 @@ class SelectionField extends FormField { } function getFilterData() { + // Start with the filter data for the list item as the [0] index $data = array(parent::getFilterData()); - if (($v = $this->getClean()) instanceof DynamicListItem) { - $data = array_merge($data, $v->getFilterData()); + if (($v = $this->getClean())) { + // Add in the properties for all selected list items in sub + // labeled by their field id + foreach ($v as $id=>$L) { + if (!($li = DynamicListItem::lookup($id))) + continue; + foreach ($li->getFilterData() as $prop=>$value) { + if (!isset($data[$prop])) + $data[$prop] = $value; + else + $data[$prop] .= " $value"; + } + } } return $data; } diff --git a/include/class.forms.php b/include/class.forms.php index e242a44ba..3f2b68db2 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -594,17 +594,6 @@ class FormField { return null; } - /** - * Indicates if the field provides for searching for something other - * than keywords. For instance, textbox fields can have hits by keyword - * searches alone, but selection fields should provide the option to - * match a specific value or set of values and therefore need to - * participate on any search builder. - */ - function hasSpecialSearch() { - return true; - } - function getConfigurationForm($source=null) { if (!$this->_cform) { $type = static::getFieldType($this->get('type')); @@ -699,10 +688,6 @@ class TextboxField extends FormField { ); } - function hasSpecialSearch() { - return false; - } - function validateEntry($value) { parent::validateEntry($value); $config = $this->getConfiguration(); @@ -773,10 +758,6 @@ class TextareaField extends FormField { ); } - function hasSpecialSearch() { - return false; - } - function display($value) { $config = $this->getConfiguration(); if ($config['html']) @@ -829,10 +810,6 @@ class PhoneField extends FormField { ); } - function hasSpecialSearch() { - return false; - } - function validateEntry($value) { parent::validateEntry($value); $config = $this->getConfiguration(); @@ -1131,9 +1108,6 @@ class ThreadEntryField extends FormField { function isPresentationOnly() { return true; } - function hasSpecialSearch() { - return false; - } function getConfigurationOptions() { global $cfg; @@ -1454,10 +1428,6 @@ class FileUploadField extends FormField { ); } - function hasSpecialSearch() { - return false; - } - /** * Called from the ajax handler for async uploads via web clients. */ diff --git a/include/class.list.php b/include/class.list.php index f5f9c4bd2..08451a298 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -587,6 +587,14 @@ class DynamicListItem extends VerySimpleModel implements CustomListItem { } } + function getFilterData() { + $data = array(); + foreach ($this->getConfigurationForm()->getFields() as $F) { + $data['.'.$F->get('id')] = $F->toString($F->value); + } + return $data; + } + function toString() { return $this->get('value'); } -- GitLab