PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.5
2.4.5 2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 All 69 releases
← All changes | app/Services/TicketQueryService.php +19 -16 1.10.0 → 2.4.5 View file →
@@ -41,20 +41,23 @@
41 41 $ticketsQuery = Ticket::with($this->args['with']);
42 42
43 43 if ($this->args['filter_type'] == 'advanced') {
44 44 $filtersGroups = $this->args['filters_groups'];
45 - foreach ($filtersGroups as $groupIndex => $group) {
46 - $method = 'orWhere';
47 - if ($groupIndex == 0) {
48 - $method = 'where';
45 + // One closure keeps the OR chain from swallowing the AND-ed agent scopes added later.
46 + $ticketsQuery->where(function ($groupsQuery) use ($filtersGroups) {
47 + foreach ($filtersGroups as $groupIndex => $group) {
48 + $method = 'orWhere';
49 + if ($groupIndex == 0) {
50 + $method = 'where';
51 + }
52 + $groupsQuery->{$method}(function ($q) use ($group) {
53 + foreach ($group as $providerName => $items) {
54 + //Call doSearchForAdvancedFilter/filterTicketByUser dynamically from pro
55 + do_action_ref_array('fluent_support\tickets_filter_' . $providerName, [&$q, $items]);
56 + }
57 + });
49 58 }
50 - $ticketsQuery->{$method}(function ($q) use ($group) {
51 - foreach ($group as $providerName => $items) {
52 - //Call doSearchForAdvancedFilter/filterTicketByUser dynamically from pro
53 - do_action_ref_array('fluent_support\tickets_filter_' . $providerName, [&$q, $items]);
54 - }
55 - });
56 - }
59 + });
57 60 } else {
58 61
59 62 if($simpleFilters = $this->args['simple_filters']) {
60 63 $ticketsQuery->applyFilters($simpleFilters);
@@ -68,10 +71,9 @@
68 71 $ticketsQuery->searchBy($search);
69 72 }
70 73 }
71 74
72 - $ticketsQuery->orderBy($this->args['sort_by'], $this->args['sort_type']);
73 -
75 + $ticketsQuery->orderBy(sanitize_sql_orderby($this->args['sort_by']), sanitize_sql_orderby($this->args['sort_type']));
74 76 do_action_ref_array('fluent_support\main_tickets_query', [&$ticketsQuery, $this->args]);
75 77 $this->model = $ticketsQuery;
76 78 }
77 79
@@ -111,19 +113,20 @@
111 113 foreach ($filters as $filterGroup) {
112 114 $group = [];
113 115 //$filterItem is individual item under a group(And/OR)
114 116 foreach ($filterGroup as $filterItem) {
115 - if (count($filterItem['source']) != 2 || empty($filterItem['source'][0]) || empty($filterItem['source'][1]) || empty($filterItem['operator'])) {
117 + $source = $filterItem['source'] ?? [];
118 + if (!is_array($source) || count($source) != 2 || empty($source[0]) || empty($source[1]) || empty($filterItem['operator'])) {
116 119 continue;
117 120 }
118 121
119 - $provider = $filterItem['source'][0];
122 + $provider = $source[0];
120 123
121 124 if (!isset($group[$provider])) {
122 125 $group[$provider] = [];
123 126 }
124 127
125 - $property = $filterItem['source'][1];
128 + $property = $source[1];
126 129
127 130 $group[$provider][] = [
128 131 'property' => $property,
129 132 'operator' => $filterItem['operator'],