From 81ab37ca81f6ea1f3ed4822104227317720af4ac Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 26 Aug 2014 10:00:49 -0500 Subject: [PATCH] forms: Add all forms to the filter subsystem --- include/class.dynamic_forms.php | 18 ++++++++++++++++++ include/class.ticket.php | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index fcbeeb897..2503d6bd5 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -368,6 +368,24 @@ Signal::connect('model.updated', function($o, $d) { return isset($d['dirty']) && (isset($d['dirty']['name']) || isset($d['dirty']['type'])); }); +Filter::addSupportedMatches(/* trans */ 'Custom Forms', function() { + $matches = array(); + foreach (DynamicForm::objects()->filter(array('type'=>'G')) as $form) { + foreach ($form->getFields() as $f) { + if (!$f->hasData()) + continue; + $matches['field.'.$f->get('id')] = $form->getTitle().' / '.$f->getLabel(); + if (($fi = $f->getImpl()) instanceof SelectionField) { + foreach ($fi->getList()->getProperties() as $p) { + $matches['field.'.$f->get('id').'.'.$p->get('id')] + = $form->getTitle().' / '.$f->getLabel().' / '.$p->getLabel(); + } + } + } + } + return $matches; +}, 9900); + require_once(INCLUDE_DIR . "class.json.php"); class DynamicFormField extends VerySimpleModel { diff --git a/include/class.ticket.php b/include/class.ticket.php index d180fc262..82b5527b0 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2299,6 +2299,16 @@ class Ticket { } } + if ($vars['topicId']) { + if (($__topic=Topic::lookup($vars['topicId'])) + && $__form = $__topic->getForm() + ) { + $__form = $__form->instanciate(); + $__form->setSource($vars); + $vars += $__form->getFilterData(); + } + } + //Init ticket filters... $ticket_filter = new TicketFilter($origin, $vars); // Make sure email contents should not be rejected -- GitLab