diff --git a/include/ajax.search.php b/include/ajax.search.php index cc6f1fbd6dd2fb3f2c09328d557c67e1adbbdf4b..70c0a71acbc574e8ed4183f653bd0aace6731d3a 100644 --- a/include/ajax.search.php +++ b/include/ajax.search.php @@ -177,7 +177,7 @@ class SearchAjaxAPI extends AjaxController { $form = $search->getForm($_POST); $errors = array(); if (!$search->update($_POST, $errors) - || !$search->save() + || !$search->save(true) ) { $this->_tryAgain($search, $form, $errors); return false; diff --git a/include/class.forms.php b/include/class.forms.php index c7e20d3627a45a4ff8551d2aaf20d8c3e67ef27b..1aec98b1f91cd36d1a58beab59fca33f7301b998 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1890,7 +1890,9 @@ class ChoiceField extends FormField { function getSearchQ($method, $value, $name=false) { $name = $name ?: $this->get('name'); - $val = '"?'.implode('("|,|$)|"?', array_keys($value)).'("|,|$)'; + $val = $value; + if ($value && is_array($value)) + $val = '"?'.implode('("|,|$)|"?', array_keys($value)).'("|,|$)'; switch ($method) { case '!includes': return Q::not(array("{$name}__regex" => $val)); @@ -1905,7 +1907,7 @@ class ChoiceField extends FormField { switch ($method) { case 'includes': return __('%s includes %s' /* includes -> if a list includes a selection */); - case 'includes': + case '!includes': return __('%s does not include %s' /* includes -> if a list includes a selection */); default: return parent::describeSearchMethod($method); @@ -2013,7 +2015,9 @@ class DatetimeField extends FormField { } function from_query($row, $name=false) { - return strtotime(parent::from_query($row, $name)); + $value = parent::from_query($row, $name); + $timestamp = is_int($value) ? $value : (int) strtotime($value); + return ($timestamp > 0) ? $timestamp : ''; } function format($timestamp, $timezone=false) { diff --git a/include/class.queue.php b/include/class.queue.php index 502e3fbb3e4266136dbc6922b87fef365270f724..a6521bc10afc14d8f4ee67b8a8b923231a33f2dd 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -1001,7 +1001,9 @@ class CustomQueue extends VerySimpleModel { elseif (($q=CustomQueue::lookup(array( 'title' => $vars['name'], 'parent_id' => $vars['parent_id'] ?: 0, - 'staff_id' => $this->staff_id)))) + 'staff_id' => $this->staff_id))) + && $q->getId() != $this->id + ) $errors['name'] = __('Saved queue with same name exists'); $this->title = $vars['name']; @@ -1155,6 +1157,8 @@ class CustomQueue extends VerySimpleModel { 'criteria' => $this->isolateCriteria($form->getClean()), 'conditions' => $conditions, ]); + // Clear currently set criteria.and conditions. + $this->criteria = $this->_conditions = null; } return 0 === count($errors); @@ -1943,6 +1947,8 @@ extends VerySimpleModel { ) { return new LazyDisplayWrapper($field, $T); } + + return new LazyDisplayWrapper($field, ''); } function applyTruncate($text, $row) { diff --git a/include/class.search.php b/include/class.search.php index e454da06adb0ad90319e41a5c9187ac70ea44586..d305ab16fee05a17d2de4c0c808d9f37230582f1 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -909,6 +909,17 @@ class AgentSelectionField extends ChoiceField { return Staff::getStaffMembers(); } + function toString($value) { + $choices = $this->getChoices(); + $selection = array(); + foreach ($value as $k => $v) + if (isset($choices[$k])) + $selection[] = $choices[$k]; + + return $selection ? implode(',', $selection) : + parent::toString($value); + } + function applyOrderBy($query, $reverse=false, $name=false) { global $cfg;