From a4a129e919c6e3ab1ddf3186e31ca9d9a15db586 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 8 Dec 2014 15:21:43 -0600 Subject: [PATCH] upgrade: Add new flags field to %form_field This will be used for greater flexibility in visibility and requirement settings. --- include/class.dynamic_forms.php | 2 +- include/class.forms.php | 2 +- include/upgrader/streams/core.sig | 2 +- ...anup.sql => b26f29a6-1ee831c8.cleanup.sql} | 4 +- ....patch.sql => b26f29a6-1ee831c8.patch.sql} | 38 ++++++++++++++++++- ...81.task.php => b26f29a6-1ee831c8.task.php} | 0 6 files changed, 41 insertions(+), 7 deletions(-) rename include/upgrader/streams/core/{b26f29a6-7c218d81.cleanup.sql => b26f29a6-1ee831c8.cleanup.sql} (86%) rename include/upgrader/streams/core/{b26f29a6-7c218d81.patch.sql => b26f29a6-1ee831c8.patch.sql} (78%) rename include/upgrader/streams/core/{b26f29a6-7c218d81.task.php => b26f29a6-1ee831c8.task.php} (100%) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index d2cee5573..b582110b0 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -424,7 +424,7 @@ class DynamicFormField extends VerySimpleModel { var $_field; const FLAG_ENABLED = 0x0001; - const FLAG_STORABLE = 0x0002; + const FLAG_EXT_STORED = 0x0002; // Value stored outside of form_entry_value const FLAG_CLOSE_REQUIRED = 0x0004; const FLAG_MASK_CHANGE = 0x0010; diff --git a/include/class.forms.php b/include/class.forms.php index 3410477d7..c3d61ea25 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -407,7 +407,7 @@ class FormField { */ function isStorable() { - return (($this->get('flags') & 2) == 0); + return (($this->get('flags') & DynamicFormField::FLAG_EXT_STORED) == 0); } /** diff --git a/include/upgrader/streams/core.sig b/include/upgrader/streams/core.sig index 595363a70..776ffc839 100644 --- a/include/upgrader/streams/core.sig +++ b/include/upgrader/streams/core.sig @@ -1 +1 @@ -7c218d81e84b304c1436326c26ace09d +1ee831c854fe9f35115a3e672916bb91 diff --git a/include/upgrader/streams/core/b26f29a6-7c218d81.cleanup.sql b/include/upgrader/streams/core/b26f29a6-1ee831c8.cleanup.sql similarity index 86% rename from include/upgrader/streams/core/b26f29a6-7c218d81.cleanup.sql rename to include/upgrader/streams/core/b26f29a6-1ee831c8.cleanup.sql index 38a11ec1a..f56a5cb2c 100644 --- a/include/upgrader/streams/core/b26f29a6-7c218d81.cleanup.sql +++ b/include/upgrader/streams/core/b26f29a6-1ee831c8.cleanup.sql @@ -1,6 +1,6 @@ /** - * @signature d7480e1c31a1f20d6954ecbb342722d3 - * @version v1.9.5 + * @signature 1ee831c854fe9f35115a3e672916bb91 + * @version v1.9.6 * @title Make editable content translatable * * This patch adds support for translatable administratively editable diff --git a/include/upgrader/streams/core/b26f29a6-7c218d81.patch.sql b/include/upgrader/streams/core/b26f29a6-1ee831c8.patch.sql similarity index 78% rename from include/upgrader/streams/core/b26f29a6-7c218d81.patch.sql rename to include/upgrader/streams/core/b26f29a6-1ee831c8.patch.sql index 4d98136aa..52d6856b7 100644 --- a/include/upgrader/streams/core/b26f29a6-7c218d81.patch.sql +++ b/include/upgrader/streams/core/b26f29a6-1ee831c8.patch.sql @@ -1,5 +1,5 @@ /** - * @signature 7c218d81e84b304c1436326c26ace09d + * @signature 1ee831c854fe9f35115a3e672916bb91 * @version v1.9.6 * @title Make editable content translatable and add queues * @@ -172,7 +172,41 @@ CREATE TABLE `%TABLE_PREFIX%queue` ( primary key (`id`) ) DEFAULT CHARSET=utf8; +-- Add flags field to form field +ALTER TABLE `%TABLE_PREFIX%form_field` + ADD `flags` INT UNSIGNED NOT NULL DEFAULT '1' AFTER `form_id`; + +-- Flag field stored in the system elsewhere as nonstorable locally. +UPDATE `%TABLE_PREFIX%form_field` A1 JOIN `%TABLE_PREFIX%form` A2 ON(A2.id=A1.form_id) + SET A1.`flags` = 3 + WHERE A2.`type` = 'U' AND A1.`name` IN('name','email'); + +UPDATE `%TABLE_PREFIX%form_field` A1 JOIN `%TABLE_PREFIX%form` A2 ON(A2.id=A1.form_id) + SET A1.`flags`=3 + WHERE A2.`type`='O' AND A1.`name` IN('name'); + +set @client_edit = ( + select value from `%TABLE_PREFIX%config` where `key` = 'allow_client_updates'); + +-- Transfer previous visibility and requirement settings to new flag field +UPDATE `%TABLE_PREFIX%form_field` SET `flags` = `flags` | + CASE WHEN `private` = 0 and @client_edit = 1 THEN CONV(3300, 16, 10) + WHEN `private` = 0 and @client_edit = 0 THEN CONV(3100, 16, 10) + WHEN `private` = 1 THEN CONV(3000, 16, 10) + WHEN `private` = 2 and @client_edit = 1 THEN CONV(300, 16, 10) END + WHEN `private` = 2 and @client_edit = 0 THEN CONV(100, 16, 10) END + | CASE WHEN `required` = 0 THEN 0 + WHEN `required` = 1 THEN CONV(4400, 16, 10) + WHEN `required` = 2 THEN CONV(400, 16, 10) + WHEN `required` = 3 THEN CONV(4000, 16, 10) END + | IF(`edit_mask` & 1, CONV(20, 16, 10), 0) + | IF(`edit_mask` & 2, CONV(40000, 16, 10), 0) + | IF(`edit_mask` & 4, CONV(10000, 16, 10), 0) + | IF(`edit_mask` & 8, CONV(20000, 16, 10), 0) + | IF(`edit_mask` & 16, CONV(10, 16, 10), 0) + | IF(`edit_mask` & 32, CONV(40, 16, 10), 0); + -- Finished with patch UPDATE `%TABLE_PREFIX%config` - SET `value` = '7c218d81e84b304c1436326c26ace09d' + SET `value` = '1ee831c854fe9f35115a3e672916bb91' WHERE `key` = 'schema_signature' AND `namespace` = 'core'; diff --git a/include/upgrader/streams/core/b26f29a6-7c218d81.task.php b/include/upgrader/streams/core/b26f29a6-1ee831c8.task.php similarity index 100% rename from include/upgrader/streams/core/b26f29a6-7c218d81.task.php rename to include/upgrader/streams/core/b26f29a6-1ee831c8.task.php -- GitLab