diff --git a/include/class.queue.php b/include/class.queue.php index 920e73a80c8576828229b45c74c1468fb0ec54af..d4185fa978cd974ee8a1619ab96c1b634f422e7c 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -1301,7 +1301,7 @@ class CustomQueue extends VerySimpleModel { static function __create($vars) { $q = static::create($vars); $q->psave(); - foreach ($vars['columns'] as $info) { + foreach ($vars['columns'] ?: array() as $info) { $glue = new QueueColumnGlue($info); $glue->queue_id = $q->getId(); $glue->save(); diff --git a/include/class.search.php b/include/class.search.php index 6ad68f283dd04b2b835fde67935c464821ca8a89..a061cb58eecf3f153b3209c36cf377c7a2d7099c 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -1049,23 +1049,37 @@ class DepartmentChoiceField extends AdvancedSearchSelectionField { class AssigneeChoiceField extends ChoiceField { + + protected $_items; + + function getChoices($verbose=false) { global $thisstaff; - $items = array( - 'M' => __('Me'), - 'T' => __('One of my teams'), - ); - foreach (Staff::getStaffMembers() as $id=>$name) { - // Don't include $thisstaff (since that's 'Me') - if ($thisstaff && $thisstaff->getId() == $id) - continue; - $items['s' . $id] = $name; - } - foreach (Team::getTeams() as $id=>$name) { - $items['t' . $id] = $name; + if (!isset($this->_items)) { + $items = array( + 'M' => __('Me'), + 'T' => __('One of my teams'), + ); + foreach (Staff::getStaffMembers() as $id=>$name) { + // Don't include $thisstaff (since that's 'Me') + if ($thisstaff && $thisstaff->getId() == $id) + continue; + $items['s' . $id] = $name; + } + foreach (Team::getTeams() as $id=>$name) { + $items['t' . $id] = $name; + } + + $this->_items = $items; } - return $items; + + return $this->_items; + } + + function getChoice($k) { + $choices = $this->getChoices(); + return $choices[$k] ?: null; } function getSearchMethods() { @@ -1167,6 +1181,15 @@ class AssigneeChoiceField extends ChoiceField { function display($value) { return (string) $value; } + + function toString($value) { + if (!is_array($value)) + $value = array($value => $value); + $selection = array(); + foreach ($value as $k => $v) + $selection[] = $this->getChoice($k) ?: (string) $v; + return implode(', ', $selection); + } } class AssignedField extends AssigneeChoiceField { diff --git a/include/upgrader/streams/core/934b8db8-ad9d0a5f.task.php b/include/upgrader/streams/core/934b8db8-ad9d0a5f.task.php index 886bcf6ebb0a7f53102efc66672e18073a032e29..619dfa4e98cab1a4619e4737d4fbd708d1a8ea0e 100644 --- a/include/upgrader/streams/core/934b8db8-ad9d0a5f.task.php +++ b/include/upgrader/streams/core/934b8db8-ad9d0a5f.task.php @@ -24,12 +24,13 @@ class QueueSortCreator extends MigrationTask { // Only save entries with "valid" criteria if (!$row['title'] || !($config = JsonDataParser::parse($row['config'], true)) - || !($criteria = CustomQueue::isolateCriteria($criteria))) + || !($criteria = self::isolateCriteria($config))) continue; + $row['root'] = 'T'; // Ticket Queue + $row['flags'] = 0; // Saved Search $row['config'] = JsonDataEncoder::encode(array( 'criteria' => $criteria, 'conditions' => array())); - $row['root'] = 'T'; CustomQueue::__create(array_intersect_key($row, array_flip( array('staff_id', 'title', 'config', 'flags', 'root', 'created', 'updated')))); @@ -53,7 +54,27 @@ class QueueSortCreator extends MigrationTask { // Set default queue to 'open' global $cfg; - $cfg->set('default_ticket_queue', 1); + if ($cfg) + $cfg->set('default_ticket_queue', 1); + } + + static function isolateCriteria($config) { + + if (is_string($config)) + $config = JsonDataParser::parse($config, true); + + foreach ($config as $k => $v) { + if (substr($k, -7) != '+search') + continue; + + // Fix up some entries + list($name,) = explode('+', $k, 2); + if (!isset($config["{$name}+method"])) + $config["{$name}+method"] = isset($config["{$name}+includes"]) + ? 'includes' : 'set'; + } + + return CustomQueue::isolateCriteria($config); } } return 'QueueSortCreator';