From 6441166f2da2be28c3df59e1df60b3f16be61f4e Mon Sep 17 00:00:00 2001 From: Lukas Schauer Date: Sun, 20 Aug 2023 00:22:30 +0200 Subject: [PATCH] xmlrpc assignNextUnassignedForState: filter on set propertyFilters --- src/Application/Controller/XMLRPC/Handler.php | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Application/Controller/XMLRPC/Handler.php b/src/Application/Controller/XMLRPC/Handler.php index 49404ed..cda10df 100644 --- a/src/Application/Controller/XMLRPC/Handler.php +++ b/src/Application/Controller/XMLRPC/Handler.php @@ -673,7 +673,34 @@ public function assignNextUnassignedForState($ticketType = '', $ticketState = '' $this->_assignedProjects, $tickets ); - + + if($propertyFilters) { + $tickets->filter(function(array $entry) use ($tickets, $propertyFilters) { + $ticket = new Ticket(); + $ticket->init($entry); + + $valid = false; + $unmatchedFilters = []; + $properties = $ticket->MergedProperties->toArray(); + foreach ($propertyFilters as $filter_key => $filter_value) { + if ( + isset($properties[$filter_key]) and + (string) $properties[$filter_key]['value'] === $filter_value + or + !isset($properties[$filter_key]) and $filter_value === '' + ) { + // TODO: for "NOT"/"NONE": set $filter here, break + $valid = true; + continue; + } + + $unmatchedFilters[] = $filter_key; + } + + if($valid) return true; else return false; + }); + } + $ticket = $tickets->first(); } catch(Exception $e) { Log::warning($e->getMessage());