Skip to content
Snippets Groups Projects
Commit 7f744012 authored by Jared Hancock's avatar Jared Hancock Committed by Peter Rotich
Browse files

queue: Fix search for assigned team or staff

Fixes the SQL generated for scans by staff_id and team_id on the ticket
table. The fields are not nullable. Instead, the value `0` represents not
having a value.
parent cddaa4bd
No related branches found
No related tags found
No related merge requests found
......@@ -832,7 +832,29 @@ class AssigneeChoiceField extends ChoiceField {
}
}
/**
* Simple trait which changes the SQL for "has a value" and "does not have a
* value" to check for zero or non-zero. Useful for not nullable fields.
*/
trait ZeroMeansUnset {
function getSearchQ($method, $value, $name=false) {
$name = $name ?: $this->get('name');
switch ($method) {
// osTicket commonly uses `0` to represent an unset state, so
// the set and unset checks need to check for both not null and
// nonzero
case 'nset':
return new Q([$name => 0]);
case 'set':
return Q::not([$name => 0]);
}
return parent::getSearchQ($method, $value, $name);
}
}
class AgentSelectionField extends ChoiceField {
use ZeroMeansUnset;
function getChoices($verbose=false) {
return Staff::getStaffMembers();
}
......@@ -858,6 +880,8 @@ class AgentSelectionField extends ChoiceField {
}
class TeamSelectionField extends ChoiceField {
use ZeroMeansUnset;
function getChoices($verbose=false) {
return Team::getTeams();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment