From d4e151b1dd16d04decded7ec0261be79e8014b68 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 10 Jun 2014 17:11:28 -0500
Subject: [PATCH] lists: Allow filtering by custom list item properties

---
 include/class.dynamic_forms.php | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 46c8460ef..ce41baeac 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -328,6 +328,14 @@ Filter::addSupportedMatches('Ticket Data', function() {
         if (!$f->hasData())
             continue;
         $matches['field.'.$f->get('id')] = 'Ticket / '.$f->getLabel();
+        if (strpos($f->get('type'), 'list-') === 0) {
+            list(,$id) = explode('-', $f->get('type'));
+            foreach (DynamicList::lookup($id)->getProperties() as $p) {
+                if ($p->get('name'))
+                    $matches['field.'.$f->get('id').'.'.mb_strtolower($p->get('name'))]
+                        = 'Ticket / '.$f->getLabel().' / '.$p->getLabel();
+            }
+        }
     }
     return $matches;
 }, 30);
@@ -919,6 +927,12 @@ class DynamicList extends VerySimpleModel {
         return $this->_form;
     }
 
+    function getProperties() {
+        if ($f = $this->getForm())
+            return $f->getFields();
+        return array();
+    }
+
     function getForm() {
         return $this->getConfigurationForm();
     }
-- 
GitLab