From 4dccaf3f1bff71b495ff9d7552bba21efd546053 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 1 Sep 2014 22:34:51 -0500 Subject: [PATCH] forms: Allow for more flexible advanced search integration --- include/class.forms.php | 30 ++++++++++++++++++++++++++++++ include/staff/tickets.inc.php | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index 3b55aa353..018c5b765 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -550,6 +550,17 @@ 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')); @@ -621,6 +632,10 @@ class TextboxField extends FormField { ); } + function hasSpecialSearch() { + return false; + } + function validateEntry($value) { parent::validateEntry($value); $config = $this->getConfiguration(); @@ -685,6 +700,10 @@ class TextareaField extends FormField { ); } + function hasSpecialSearch() { + return false; + } + function display($value) { $config = $this->getConfiguration(); if ($config['html']) @@ -729,6 +748,10 @@ class PhoneField extends FormField { ); } + function hasSpecialSearch() { + return false; + } + function validateEntry($value) { parent::validateEntry($value); $config = $this->getConfiguration(); @@ -1014,6 +1037,9 @@ class ThreadEntryField extends FormField { function isPresentationOnly() { return true; } + function hasSpecialSearch() { + return false; + } function getConfigurationOptions() { global $cfg; @@ -1326,6 +1352,10 @@ class FileUploadField extends FormField { ); } + function hasSpecialSearch() { + return false; + } + /** * Called from the ajax handler for async uploads via web clients. */ diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index 3f828d210..ee55d4152 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -648,9 +648,9 @@ if ($results) { $tform = TicketForm::objects()->one(); echo $tform->getForm()->getMedia(); foreach ($tform->getInstance()->getFields() as $f) { - if (in_array($f->get('type'), array('text', 'memo', 'phone', 'thread'))) + if (!$f->hasData()) continue; - elseif (!$f->hasData()) + elseif (!$f->getImpl()->hasSpecialSearch()) continue; ?><fieldset class="span6"> <label><?php echo $f->getLabel(); ?>:</label><div><?php -- GitLab