diff --git a/include/class.list.php b/include/class.list.php index 274009de9e1a2f82ae458143f0b405aa78363aa4..009f88921e538e8e9a0c48e94bcc5b6f0d475f4b 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -766,7 +766,6 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { var $_list; var $_form; - var $_config; var $_settings; var $_properties; @@ -777,7 +776,6 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { function __construct() { call_user_func_array(array('parent', '__construct'), func_get_args()); - $this->_config = new Config('TS.'.$this->getId()); } protected function hasFlag($field, $flag) { @@ -793,7 +791,7 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { } protected function hasProperties() { - return ($this->_config->get('properties')); + return ($this->get('properties')); } function getForm() { @@ -900,7 +898,7 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { private function getProperties() { if (!isset($this->_properties)) { - $this->_properties = $this->_config->get('properties'); + $this->_properties = $this->get('properties'); if (is_string($this->_properties)) $this->_properties = JsonDataParser::parse($this->_properties); elseif (!$this->_properties) @@ -980,20 +978,16 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { } if (count($errors) === 0) { + if ($properties && is_array($properties)) + $properties = JsonDataEncoder::encode($properties); + + $this->set('properties', $properties); $this->save(true); - $this->setProperties($properties); } return count($errors) === 0; } - function setProperties($properties) { - if ($properties && is_array($properties)) - $properties = JsonDataEncoder::encode($properties); - - $this->_config->set('properties', $properties); - } - function update($vars, &$errors) { $fields = array('value' => 'name', 'sort' => 'sort'); @@ -1042,13 +1036,9 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { static function __create($ht, &$error=false) { global $ost; - $properties = JsonDataEncoder::encode($ht['properties']); - unset($ht['properties']); - if ($status = TicketStatus::create($ht)) { + $ht['properties'] = JsonDataEncoder::encode($ht['properties']); + if (($status = TicketStatus::create($ht))) $status->save(true); - $status->_config = new Config('TS.'.$status->getId()); - $status->_config->set('properties', $properties); - } return $status; } diff --git a/include/upgrader/streams/core.sig b/include/upgrader/streams/core.sig index 30a5aca33dc5932c1e09ede64d418368d54367cb..d1c341c6834e60a548cca0fc50e0e31196328df5 100644 --- a/include/upgrader/streams/core.sig +++ b/include/upgrader/streams/core.sig @@ -1 +1 @@ -03ff59bf35a58a102e9b32ad33c2839f +519d98cd885f060e220da7b30a6f78ae diff --git a/include/upgrader/streams/core/03ff59bf-519d98cd.cleanup.sql b/include/upgrader/streams/core/03ff59bf-519d98cd.cleanup.sql new file mode 100644 index 0000000000000000000000000000000000000000..2f39fa0f280d2115eaf47988711ba235b9e20d1f --- /dev/null +++ b/include/upgrader/streams/core/03ff59bf-519d98cd.cleanup.sql @@ -0,0 +1,2 @@ +DELETE FROM `%TABLE_PREFIX%config` + WHERE `key` = 'properties' AND `namespace` LIKE 'TS.%'; diff --git a/include/upgrader/streams/core/03ff59bf-519d98cd.patch.sql b/include/upgrader/streams/core/03ff59bf-519d98cd.patch.sql new file mode 100644 index 0000000000000000000000000000000000000000..57e823f6d72cecc5ba2e4b3547d5a1d8b58f9b22 --- /dev/null +++ b/include/upgrader/streams/core/03ff59bf-519d98cd.patch.sql @@ -0,0 +1,24 @@ +/** + * @version v1.9.4 + * @signature 519d98cd885f060e220da7b30a6f78ae + * @title Add properties filed and drop 'resolved' state + * + * This patch drops resolved state and any associated statuses + * + */ + +-- add properties field +ALTER TABLE `%TABLE_PREFIX%ticket_status` + ADD `properties` TEXT NOT NULL AFTER `sort`, + DROP `notes`; + +UPDATE `%TABLE_PREFIX%ticket_status` s + INNER JOIN `ost_config` c + ON(c.namespace = CONCAT('TS.', s.id) AND c.key='properties') + SET s.properties = c.value; + + +-- Set new schema signature +UPDATE `%TABLE_PREFIX%config` + SET `value` = '519d98cd885f060e220da7b30a6f78ae' + WHERE `key` = 'schema_signature' AND `namespace` = 'core'; diff --git a/setup/inc/streams/core/install-mysql.sql b/setup/inc/streams/core/install-mysql.sql index 4879e53ce514f2aa1f4ba813b1fd967b3ae3f2cb..c130bcf2cef1b1aa124848c0d80bce44da0ac45b 100644 --- a/setup/inc/streams/core/install-mysql.sql +++ b/setup/inc/streams/core/install-mysql.sql @@ -681,7 +681,7 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%ticket_status` ( `mode` int(11) unsigned NOT NULL DEFAULT '0', `flags` int(11) unsigned NOT NULL DEFAULT '0', `sort` int(11) unsigned NOT NULL DEFAULT '0', - `notes` text NOT NULL, + `properties` text NOT NULL, `created` datetime NOT NULL, `updated` datetime NOT NULL, PRIMARY KEY (`id`),