From 69cf979ff5644bd8bd4f0380d202154c2f777575 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 20 Aug 2015 12:20:16 -0500 Subject: [PATCH] search: Add search for closed date --- include/class.forms.php | 16 +++++++++++++--- include/class.search.php | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index bc3ac862f..1ee044aa1 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -3764,6 +3764,9 @@ class FreeTextWidget extends Widget { } class VisibilityConstraint { + static $operators = array( + 'eq' => 1, + ); const HIDDEN = 0x0001; const VISIBLE = 0x0002; @@ -3821,6 +3824,13 @@ class VisibilityConstraint { return $this->compileQPhp($this->constraint, $field); } + static function splitFieldAndOp($field) { + $op = substr($field, strrpos($field, '__') + 2); + if (isset(static::$operators[$op])) + $field = substr($field, 0, strrpos($field, '__')); + return array($field, $op); + } + function compileQPhp(Q $Q, $field) { if (!($form = $field->getForm())) { return $this->initial == self::VISIBLE; @@ -3831,7 +3841,7 @@ class VisibilityConstraint { $expr[] = $this->compileQPhp($value, $field); } else { - @list($f, $op) = explode('__', $c, 2); + @list($f, $op) = self::splitFieldAndOp($c); $field = $form->getField($f); $wval = $field->getClean(); switch ($op) { @@ -3857,7 +3867,7 @@ class VisibilityConstraint { $this->getAllFields($c, $fields); } else { - list($f, $op) = explode('__', $c, 2); + @list($f) = self::splitFieldAndOp($c); $fields[$f] = true; } } @@ -3871,7 +3881,7 @@ class VisibilityConstraint { $expr[] = $this->compileQ($value, $form); } else { - list($f, $op) = explode('__', $c, 2); + list($f, $op) = self::splitFieldAndOp($c); $widget = $form->getField($f)->getWidget(); $id = $widget->id; switch ($op) { diff --git a/include/class.search.php b/include/class.search.php index a9ca11003..28a5633c1 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -737,6 +737,18 @@ class SavedSearch extends VerySimpleModel { # ':org' => new OrganizationChoiceField(array( # 'label' => __('Organization'), # )), + ':closed' => new DatetimeField(array( + 'id' => 3204, + 'label' => __('Closed Date'), + )), + ':thread__lastresponse' => new DatetimeField(array( + 'id' => 3205, + 'label' => __('Last Response'), + )), + ':thread__lastmessage' => new DatetimeField(array( + 'id' => 3206, + 'label' => __('Last Message'), + )), ':source' => new TicketSourceChoiceField(array( 'id' => 3201, 'label' => __('Source'), @@ -870,8 +882,10 @@ class SavedSearch extends VerySimpleModel { $filter->add(array('entries__answers__field_id' => $id)); break; } - $OP = $other_paths[$type]; - $name = $OP . $column; + if ($OP = $other_paths[$type]) + $name = $OP . $column; + else + $name = substr($name, 1); } } -- GitLab