From 08785f92422a7b047fed6ccb929e2c9b14252699 Mon Sep 17 00:00:00 2001 From: JediKev Date: Fri, 24 Sep 2021 16:34:44 +0000 Subject: [PATCH] search: Child Thread Relation This addresses issue 5959 where `TicketThread / Last Message` and `TicketThread / Last Response` appear twice in the Advanced Search available Fields. This is due to the joins/relationships automatically being added to searchable fields. In this case, searching TicketThread will search the Parent and Child Threads so there is no need for two separate options. This adds a new property called `searchable` (set to false) to the `child_thread` relation in the Ticket class. In addition, this adds a check when generating the searchable fields that skips the relation if the `searchable` property is `false`. --- include/class.queue.php | 3 ++- include/class.ticket.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/class.queue.php b/include/class.queue.php index a8e4e583d5..c8805663a3 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -381,7 +381,8 @@ static function getSearchableFields($base, $recurse=2, $exclude[$base] = 1; foreach ($base::getMeta('joins') as $path=>$j) { $fc = $j['fkey'][0]; - if (isset($exclude[$fc]) || $j['list']) + if (isset($exclude[$fc]) || $j['list'] + || (isset($j['searchable']) && !$j['searchable'])) continue; foreach (static::getSearchableFields($fc, $recurse-1, true, $exclude) diff --git a/include/class.ticket.php b/include/class.ticket.php index dc0a52929a..93d812b385 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -88,6 +88,7 @@ class Ticket extends VerySimpleModel 'ticket_id' => 'TicketThread.object_id', "'C'" => 'TicketThread.object_type', ), + 'searchable' => false, 'null' => true, ), 'cdata' => array(