Skip to content
Snippets Groups Projects
Commit a35d0fb4 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add status properties to the status table.

parent 438f35c0
No related branches found
No related tags found
No related merge requests found
...@@ -766,7 +766,6 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { ...@@ -766,7 +766,6 @@ class TicketStatus extends VerySimpleModel implements CustomListItem {
var $_list; var $_list;
var $_form; var $_form;
var $_config;
var $_settings; var $_settings;
var $_properties; var $_properties;
...@@ -777,7 +776,6 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { ...@@ -777,7 +776,6 @@ class TicketStatus extends VerySimpleModel implements CustomListItem {
function __construct() { function __construct() {
call_user_func_array(array('parent', '__construct'), func_get_args()); call_user_func_array(array('parent', '__construct'), func_get_args());
$this->_config = new Config('TS.'.$this->getId());
} }
protected function hasFlag($field, $flag) { protected function hasFlag($field, $flag) {
...@@ -793,7 +791,7 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { ...@@ -793,7 +791,7 @@ class TicketStatus extends VerySimpleModel implements CustomListItem {
} }
protected function hasProperties() { protected function hasProperties() {
return ($this->_config->get('properties')); return ($this->get('properties'));
} }
function getForm() { function getForm() {
...@@ -900,7 +898,7 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { ...@@ -900,7 +898,7 @@ class TicketStatus extends VerySimpleModel implements CustomListItem {
private function getProperties() { private function getProperties() {
if (!isset($this->_properties)) { if (!isset($this->_properties)) {
$this->_properties = $this->_config->get('properties'); $this->_properties = $this->get('properties');
if (is_string($this->_properties)) if (is_string($this->_properties))
$this->_properties = JsonDataParser::parse($this->_properties); $this->_properties = JsonDataParser::parse($this->_properties);
elseif (!$this->_properties) elseif (!$this->_properties)
...@@ -980,20 +978,16 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { ...@@ -980,20 +978,16 @@ class TicketStatus extends VerySimpleModel implements CustomListItem {
} }
if (count($errors) === 0) { if (count($errors) === 0) {
if ($properties && is_array($properties))
$properties = JsonDataEncoder::encode($properties);
$this->set('properties', $properties);
$this->save(true); $this->save(true);
$this->setProperties($properties);
} }
return count($errors) === 0; 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) { function update($vars, &$errors) {
$fields = array('value' => 'name', 'sort' => 'sort'); $fields = array('value' => 'name', 'sort' => 'sort');
...@@ -1042,13 +1036,9 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { ...@@ -1042,13 +1036,9 @@ class TicketStatus extends VerySimpleModel implements CustomListItem {
static function __create($ht, &$error=false) { static function __create($ht, &$error=false) {
global $ost; global $ost;
$properties = JsonDataEncoder::encode($ht['properties']); $ht['properties'] = JsonDataEncoder::encode($ht['properties']);
unset($ht['properties']); if (($status = TicketStatus::create($ht)))
if ($status = TicketStatus::create($ht)) {
$status->save(true); $status->save(true);
$status->_config = new Config('TS.'.$status->getId());
$status->_config->set('properties', $properties);
}
return $status; return $status;
} }
......
03ff59bf35a58a102e9b32ad33c2839f 519d98cd885f060e220da7b30a6f78ae
DELETE FROM `%TABLE_PREFIX%config`
WHERE `key` = 'properties' AND `namespace` LIKE 'TS.%';
/**
* @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';
...@@ -681,7 +681,7 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%ticket_status` ( ...@@ -681,7 +681,7 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%ticket_status` (
`mode` int(11) unsigned NOT NULL DEFAULT '0', `mode` int(11) unsigned NOT NULL DEFAULT '0',
`flags` int(11) unsigned NOT NULL DEFAULT '0', `flags` int(11) unsigned NOT NULL DEFAULT '0',
`sort` 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, `created` datetime NOT NULL,
`updated` datetime NOT NULL, `updated` datetime NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment