diff --git a/include/class.queue.php b/include/class.queue.php index 47e0f1041de68f0eb3c08d9af01d2bba37b63461..7690a90239e8218790b858f4f4990be1a0063185 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -58,12 +58,23 @@ class CustomQueue extends SavedSearch { function getColumns() { if (!count($this->columns)) { + if ($this->columns_id + && ($q = CustomQueue::lookup($this->columns_id)) + ) { + // Use columns from cited queue + return $q->getColumns(); + } + + // Last resort — use standard columns foreach (array( new QueueColumn(array( "id" => 1, "heading" => "Number", "primary" => 'number', "width" => 100, + "filter" => "link:ticket", + "annotations" => '[{"c":"TicketSourceDecoration","p":"b"}]', + "conditions" => '[{"crit":["isanswered","set",null],"prop":{"font-weight":"bold"}}]', )), new QueueColumn(array( "id" => 2, @@ -76,6 +87,9 @@ class CustomQueue extends SavedSearch { "heading" => "Subject", "primary" => 'cdata__subject', "width" => 250, + "filter" => "link:ticket", + "annotations" => '[{"c":"TicketThreadCount","p":">"},{"c":"ThreadAttachmentCount","p":"a"},{"c":"OverdueFlagDecoration","p":"<"}]', + "truncate" => 'ellipsis', )), new QueueColumn(array( "id" => 4, @@ -685,24 +699,10 @@ extends VerySimpleModel { ), ); - var $_annotations = array(); - var $_conditions = array(); + var $_annotations; + var $_conditions; function __onload() { - if ($this->annotations - && ($anns = JsonDataParser::decode($this->annotations)) - ) { - foreach ($anns as $D) - if ($T = QueueColumnAnnotation::fromJson($D)) - $this->_annotations[] = $T; - } - if ($this->conditions - && ($conds = JsonDataParser::decode($this->conditions)) - ) { - foreach ($conds as $C) - if ($T = QueueColumnCondition::fromJson($C)) - $this->_conditions[] = $T; - } } function getId() { @@ -740,10 +740,10 @@ extends VerySimpleModel { } // annotations and conditions - foreach ($this->_annotations as $D) { + foreach ($this->getAnnotations() as $D) { $text = $D->render($row, $text); } - foreach ($this->_conditions as $C) { + foreach ($this->getConditions() as $C) { $text = $C->render($row, $text); } return $text; @@ -814,12 +814,12 @@ extends VerySimpleModel { $query = $filter->mangleQuery($query, $this); // annotations - foreach ($this->_annotations as $D) { + foreach ($this->getAnnotations() as $D) { $query = $D->annotate($query); } // Conditions - foreach ($this->_conditions as $C) { + foreach ($this->getConditions() as $C) { $query = $C->annotate($query); } @@ -860,10 +860,30 @@ extends VerySimpleModel { } function getAnnotations() { + if (!isset($this->_annotations)) { + $this->_annotations = array(); + if ($this->annotations + && ($anns = JsonDataParser::decode($this->annotations)) + ) { + foreach ($anns as $D) + if ($T = QueueColumnAnnotation::fromJson($D)) + $this->_annotations[] = $T; + } + } return $this->_annotations; } function getConditions() { + if (!isset($this->_conditions)) { + $this->_conditions = array(); + if ($this->conditions + && ($conds = JsonDataParser::decode($this->conditions)) + ) { + foreach ($conds as $C) + if ($T = QueueColumnCondition::fromJson($C)) + $this->_conditions[] = $T; + } + } return $this->_conditions; } diff --git a/include/upgrader/streams/core/98ad7d55-00000000.patch.sql b/include/upgrader/streams/core/98ad7d55-00000000.patch.sql index 7f31dacf1f10fdba8ae559b62c3575cd46079789..22530ecb586381a1bd5ae630b71c205e57a12b61 100644 --- a/include/upgrader/streams/core/98ad7d55-00000000.patch.sql +++ b/include/upgrader/streams/core/98ad7d55-00000000.patch.sql @@ -7,6 +7,7 @@ */ ALTER TABLE `%TABLE_PREFIX%queue` + ADD `columns_id` int(11) unsigned AFTER `parent_id`, ADD `filter` varchar(64) AFTER `config`, ADD `root` varchar(32) DEFAULT NULL AFTER `filter`, ADD `path` varchar(80) NOT NULL DEFAULT '/' AFTER `root`; diff --git a/setup/inc/streams/core/install-mysql.sql b/setup/inc/streams/core/install-mysql.sql index 0bae1a0b8666b1205b5673effae54b0a3a03f09a..643fe925ece4fbe6e4d87139f00b0fd058f138d4 100644 --- a/setup/inc/streams/core/install-mysql.sql +++ b/setup/inc/streams/core/install-mysql.sql @@ -827,6 +827,7 @@ DROP TABLE IF EXISTS `%TABLE_PREFIX%queue`; CREATE TABLE `%TABLE_PREFIX%queue` ( `id` int(11) unsigned not null auto_increment, `parent_id` int(11) unsigned not null default 0, + `columns_id` int(11) unsigned, `flags` int(11) unsigned not null default 0, `staff_id` int(11) unsigned not null default 0, `sort` int(11) unsigned not null default 0,