From 215ca76a17c34afa0f7a07ba5b40abb7b67ae32d Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 27 May 2015 11:44:09 -0500
Subject: [PATCH] config: Split out name configuration option

* Rename config var enable_html_thread to enable_richtext
* Copy config var name_format to agent_name_format and client_name_format
  and delete it
---
 include/class.config.php                             |  6 +++---
 .../streams/core/9143a511-00000000.cleanup.sql       |  3 +++
 .../streams/core/9143a511-00000000.patch.sql         | 12 ++++++++++++
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/class.config.php b/include/class.config.php
index cb1f15d5c..522c93c5d 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -154,7 +154,7 @@ class OsticketConfig extends Config {
     var $defaults = array(
         'allow_pw_reset' =>     true,
         'pw_reset_window' =>    30,
-        'enable_html_thread' => true,
+        'enable_richtext' => true,
         'allow_attachments' =>  true,
         'name_format' =>        'full', # First Last
         'auto_claim_tickets'=>  true,
@@ -361,7 +361,7 @@ class OsticketConfig extends Config {
     }
 
     function isHtmlThreadEnabled() {
-        return $this->get('enable_html_thread');
+        return $this->get('enable_richtext');
     }
 
     function getClientTimeout() {
@@ -1132,7 +1132,7 @@ class OsticketConfig extends Config {
             'show_answered_tickets'=>isset($vars['show_answered_tickets'])?0:1,
             'show_related_tickets'=>isset($vars['show_related_tickets'])?1:0,
             'hide_staff_name'=>isset($vars['hide_staff_name'])?1:0,
-            'enable_html_thread'=>isset($vars['enable_html_thread'])?1:0,
+            'enable_richtext'=>isset($vars['enable_html_thread'])?1:0,
             'allow_client_updates'=>isset($vars['allow_client_updates'])?1:0,
             'max_file_size'=>$vars['max_file_size'],
         ));
diff --git a/include/upgrader/streams/core/9143a511-00000000.cleanup.sql b/include/upgrader/streams/core/9143a511-00000000.cleanup.sql
index 3095f761b..9597462e1 100644
--- a/include/upgrader/streams/core/9143a511-00000000.cleanup.sql
+++ b/include/upgrader/streams/core/9143a511-00000000.cleanup.sql
@@ -62,6 +62,9 @@ WHERE `key`='transient' AND `namespace` LIKE 'sla.%';
 DELETE FROM `%TABLE_PREFIX%config`
 WHERE `key`='configuration' AND `namespace` LIKE 'list.%';
 
+DELETE FROM `%TABLE_PREFIX%config`
+WHERE `key`='name_format' AND `namespace` = 'core';
+
 -- Orphan users who don't know they're orphans
 UPDATE `%TABLE_PREFIX%user` A1
   LEFT JOIN `%TABLE_PREFIX%organization` A2 ON (A1.`org_id` = A2.`id`)
diff --git a/include/upgrader/streams/core/9143a511-00000000.patch.sql b/include/upgrader/streams/core/9143a511-00000000.patch.sql
index 5bd52c8f5..78f0d11eb 100644
--- a/include/upgrader/streams/core/9143a511-00000000.patch.sql
+++ b/include/upgrader/streams/core/9143a511-00000000.patch.sql
@@ -91,6 +91,18 @@ UPDATE `%TABLE_PREFIX%list` A1
 -- Rebuild %ticket__cdata as UTF8
 DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket__cdata`;
 
+-- Move `enable_html_thread` to `enable_richtext`
+UPDATE `%TABLE_PREFIX%config`
+  SET `key` = 'enable_richtext'
+  WHERE `namespace` = 'core' AND `key` = 'enable_html_thread';
+
+SET @name_format = (SELECT `value` FROM `%TABLE_PREFIX%config` A1
+    WHERE A1.`namespace` = 'core' AND A1.`key` = 'name_format');
+INSERT INTO `%TABLE_PREFIX%config`
+    (`namespace`, `key`, `value`) VALUES
+    ('core', 'agent_name_format', @name_format),
+    ('core', 'client_name_format', @name_format);
+
 -- Finished with patch
 UPDATE `%TABLE_PREFIX%config`
     SET `value` = '00000000000000000000000000000000'
-- 
GitLab