$res = $this->wpdb->insert(
GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX.'custom_field_data',
array(
+ 'fid' => $formId,
'field_id' => $field['id'],
'record_id' => $recordId,
'text_data' => ($fType=='text'||$fType=='textarea'||$fType=='picklist' ? $field['submitted'] : ''),
'float_data' => ($fType=='float' ? $field['submitted'] : false),
),
array(
+ '%s',
'%d',
'%d',
'%s',
'view_only' => true,
'use' => 'a'
),
+
+ // Form ID
+ 'fid' => array(
+ 'field' => 'fid',
+ 'type' => 'text',
+ 'required' => true,
+ 'use' => 'a'
+ ),
+
// Entity ID (event, member, package)
'record_id' => array (
'field' => 'record_id',
'view_only' => false,
'use' => 'a'
),
+
// Event ID
'field_id' => array(
'field' => 'field_id',
'type' => 'text',
'required' => true,
'use' => 'a'
- ),
+ )
);
* version from this plugin.
*/
define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_VERSION', '1.0.0');
-define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_VERSION', '1.0.2');
+define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_VERSION', '1.0.3');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0');
// Delete this custom field
$this->deleteEntry($fieldId, true);
+
+ // Delete any field options
+ $this->wpdb->query(
+ $this->wpdb->prepare(
+ "
+ DELETE FROM ".GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX."custom_field_options
+ WHERE field_id = %d
+ ",
+ $fieldId
+ )
+ );
+
echo true;
break;
$view = 'displayForm.html';
$parentFormId = $actionData['request']['parent-form-id'];
+trigger_error('Form Display Submit Data '.print_r($actionData,1),E_USER_NOTICE);
if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
trigger_error('Shortcode Called: glm-members-customfields-form-display', E_USER_NOTICE);
}
foreach ($formFields as $fieldKey => $fieldVal) {
$formFields[$fieldKey]['field_fail'] = '';
}
+
+ // If there's a record ID
+ $recordId = ($actionData['request']['record-id'] - 0);
+ if ($recordId > 0) {
+trigger_error('recordId = '.$recordId,E_USER_NOTICE);
+ // Try to get any stored data
+ $CustomFieldData = new GlmDataFieldsCustomFieldsData($this->wpdb, $this->config);
+ $customFieldData = $CustomFieldData->getList("fid = '$formId' AND field_id = $recordId");
+trigger_error('Field Data = '.print_r($customFieldData,1), E_USER_NOTICE);
+
+
+ }
}
}
// Call form display shortcode to do this work
- $content .= do_shortcode('[glm-members-customfields-form-display fid='.$fid.' record-id='.$recordId.' parent-form-id='.$parentFormId.' form-data='.$formData.']');
+ $content .= do_shortcode('[glm-members-customfields-form-display fid="'.$fid.'" record-id="'.$recordId.'" parent-form-id="'.$parentFormId.'" form-data="'.$formData.'"]');
return $content;
+++ /dev/null
--- Gaslight Media Members Database - Custom Fields Add-On
--- File Created: 2017-03-27
--- Database Version: 1.0.2
--- Database Creation Script
---
--- This file is called to create a new set of tables for this
--- add-on for the most recent database version for this add-on.
---
--- There should only be one such file in this directory
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
-
--- Field Setup Table
-CREATE TABLE {prefix}custom_fields (
- id INT NOT NULL AUTO_INCREMENT,
- fid TEXT NOT NULL DEFAULT '', -- Unique ID for this form (group of these fields)
- field_name TINYTEXT NOT NULL DEFAULT '', -- Field reference name
- field_prompt TINYTEXT NOT NULL DEFAULT '', -- Prompt to display on form to user
- field_type TINYTEXT NOT NULL DEFAULT '', -- Field Type
- field_order SMALLINT NOT NULL DEFAULT 0, -- Order for Field
- required BOOLEAN NOT NULL DEFAULT '0', -- If the field is required.
- PRIMARY KEY (id),
- INDEX (field_name(40))
-);
-
-----
-
--- Data Table
-CREATE TABLE {prefix}custom_field_data (
- id INT NOT NULL AUTO_INCREMENT,
- field_id INT NOT NULL DEFAULT 0, -- Pointer to ID of field in custom_fields table
- record_id INT NOT NULL DEFAULT 0, -- id for this submission of this form
- text_data TEXT NOT NULL DEFAULT '', -- Data for a text field
- checkbox_data BOOLEAN NOT NULL DEFAULT false, -- Data for a boolean field
- integer_data INTEGER NOT NULL DEFAULT 0, -- Data for an integer field
- float_data FLOAT NOT NULL DEFAULT '0.00', -- Data for a float field
- PRIMARY KEY (id),
- INDEX (field_id),
- INDEX (record_id)
-);
-
-----
-
--- Picklist Field Options
-CREATE TABLE {prefix}custom_field_options (
- id INT NOT NULL AUTO_INCREMENT,
- field_id INT NOT NULL DEFAULT 0, -- Pointer to ID of fields in custom_fields table
- option_text TINYTEXT NOT NULL DEFAULT '', -- Option's Displayed text
- option_value TINYTEXT NOT NULL DEFAULT '', -- Option's value
- option_cost FLOAT NOT NULL DEFAULT '0.00', -- A cost added when this option is selected
- option_default BOOLEAN NOT NULL DEFAULT false, -- Flag indicating that this option is the default
- PRIMARY KEY (id),
- INDEX (field_id)
-);
--- /dev/null
+-- Gaslight Media Members Database - Custom Fields Add-On
+-- File Created: 2017-03-27
+-- Database Version: 1.0.2
+-- Database Creation Script
+--
+-- This file is called to create a new set of tables for this
+-- add-on for the most recent database version for this add-on.
+--
+-- There should only be one such file in this directory
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+
+-- Field Setup Table
+CREATE TABLE {prefix}custom_fields (
+ id INT NOT NULL AUTO_INCREMENT,
+ fid TEXT NOT NULL DEFAULT '', -- Unique ID for this form (group of these fields)
+ field_name TINYTEXT NOT NULL DEFAULT '', -- Field reference name
+ field_prompt TINYTEXT NOT NULL DEFAULT '', -- Prompt to display on form to user
+ field_type TINYTEXT NOT NULL DEFAULT '', -- Field Type
+ field_order SMALLINT NOT NULL DEFAULT 0, -- Order for Field
+ required BOOLEAN NOT NULL DEFAULT '0', -- If the field is required.
+ PRIMARY KEY (id),
+ INDEX (field_name(40))
+);
+
+----
+
+-- Data Table
+CREATE TABLE {prefix}custom_field_data (
+ id INT NOT NULL AUTO_INCREMENT,
+ fid TEXT NOT NULL DEFAULT '', -- Form ID
+ field_id INT NOT NULL DEFAULT 0, -- Pointer to ID of field in custom_fields table
+ record_id INT NOT NULL DEFAULT 0, -- id for this submission of this form
+ text_data TEXT NOT NULL DEFAULT '', -- Data for a text field
+ checkbox_data BOOLEAN NOT NULL DEFAULT false, -- Data for a boolean field
+ integer_data INTEGER NOT NULL DEFAULT 0, -- Data for an integer field
+ float_data FLOAT NOT NULL DEFAULT '0.00', -- Data for a float field
+ PRIMARY KEY (id),
+ INDEX (fid(30)),
+ INDEX (field_id),
+ INDEX (record_id)
+);
+
+----
+
+-- Picklist Field Options
+CREATE TABLE {prefix}custom_field_options (
+ id INT NOT NULL AUTO_INCREMENT,
+ field_id INT NOT NULL DEFAULT 0, -- Pointer to ID of fields in custom_fields table
+ option_text TINYTEXT NOT NULL DEFAULT '', -- Option's Displayed text
+ option_value TINYTEXT NOT NULL DEFAULT '', -- Option's value
+ option_cost FLOAT NOT NULL DEFAULT '0.00', -- A cost added when this option is selected
+ option_default BOOLEAN NOT NULL DEFAULT false, -- Flag indicating that this option is the default
+ PRIMARY KEY (id),
+ INDEX (field_id)
+);
$glmMembersCustomFieldsDbVersions = array(
'1.0.0' => array('version' => '1.0.0', 'tables' => 2, 'date' => '12/01/2017'),
'1.0.1' => array('version' => '1.0.1', 'tables' => 2, 'date' => '12/05/2017'),
- '1.0.2' => array('version' => '1.0.2', 'tables' => 3, 'date' => '12/15/2017')
+ '1.0.2' => array('version' => '1.0.2', 'tables' => 3, 'date' => '12/15/2017'),
+ '1.0.3' => array('version' => '1.0.3', 'tables' => 3, 'date' => '12/18/2017')
);
--- /dev/null
+-- Gaslight Media Members Database - Custom Fields Add-On
+-- File Created: 08/30/16 09:47:15
+-- Database Version: 1.0.1
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+ALTER TABLE {prefix}custom_field_data ADD COLUMN fid TINYTEXT;
+
+----
+
+CREATE INDEX fid ON {prefix}custom_field_data (record_id(30)));
\ No newline at end of file