From 5815f0e5158c0e3d251b456e5c6fd952c74c741a Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 11 Dec 2017 09:28:19 -0500 Subject: [PATCH] Custom Fields now working for event and event registrants. --- classes/customFieldPluginSupport.php | 166 --------- classes/customFieldSupport.php | 346 ++++++++++++++++++ classes/data/dataCustomFields.php | 43 ++- classes/data/dataCustomFieldsData.php | 8 +- defines.php | 2 +- index.php | 2 +- .../admin/OLD-import/fields.php | 0 models/admin/ajax/customFields.php | 3 - models/admin/customFields/index.php | 12 +- models/front/customFields/formDisplay.php | 152 ++++++++ setup/adminHooks.php | 14 +- setup/commonHooks.php | 107 ++++++ ..._V1.0.0.sql => create_database_V1.0.1.sql} | 21 +- setup/databaseScripts/dbVersions.php | 3 +- .../update_database_V1.0.1.sql | 46 +++ setup/frontHooks.php | 171 --------- setup/hooksHelp.html | 25 +- setup/shortcodes.php | 115 ++++-- setup/validActions.php | 5 +- views/admin/ajax/newField.html | 9 +- views/admin/customFields/index.html | 209 +++++------ views/front/customFields/displayForm.html | 56 +++ .../fields/{detail.html => OLDdetail.html} | 0 .../front/fields/{list.html => OLDlist.html} | 0 24 files changed, 975 insertions(+), 540 deletions(-) delete mode 100644 classes/customFieldPluginSupport.php create mode 100644 classes/customFieldSupport.php rename "models/admin/OL\357\200\242D-import/fields.php" => models/admin/OLD-import/fields.php (100%) create mode 100644 models/front/customFields/formDisplay.php rename setup/databaseScripts/{create_database_V1.0.0.sql => create_database_V1.0.1.sql} (52%) create mode 100644 setup/databaseScripts/update_database_V1.0.1.sql create mode 100644 views/front/customFields/displayForm.html rename views/front/fields/{detail.html => OLDdetail.html} (100%) rename views/front/fields/{list.html => OLDlist.html} (100%) diff --git a/classes/customFieldPluginSupport.php b/classes/customFieldPluginSupport.php deleted file mode 100644 index 3b55d02..0000000 --- a/classes/customFieldPluginSupport.php +++ /dev/null @@ -1,166 +0,0 @@ -get_results($sql); - - if(!empty($required)){ - foreach($required as $req){ - $requiredFields[] = $req->id; - } - - foreach($_REQUEST['glm_custom_field'] as $fieldID =>$fieldValue){ - $cfData[$fieldID] = $fieldValue; - if( in_array( $fieldID,$requiredFields )){ - if($fieldValue === ''){ - $fieldFail['fieldFail'][$fieldID] = true; - } - } - } - } - if(!empty($fieldFail)){ - $fieldFailData = $cfData + $fieldFail; - return $fieldFailData; - } - // Loop through the glm_custom_field array - foreach ( $_REQUEST['glm_custom_field'] as $fieldId => $fieldValue ) { - $fieldData =array( - 'entity_id' => $entityID, - 'field_id' => $fieldId, - 'field_data' => wp_kses_post(stripslashes($fieldValue)) - ); - if ( !isset($currentCustomFields[$fieldId]) ) { - // Insert Entries - $wpdb->insert( - GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data", - $fieldData, - $fieldDataFormat - ); - } else { - // Update Entries - $wpdb->update( - GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data", - $fieldData, - array( - 'entity_id' => $entityID, - 'field_id' => $fieldId - ), - $fieldDataFormat, - '%d' - ); - } - } - return true; -} - -function customFieldsCloneFields( $oldId, $newId ) -{ - global $wpdb; - $customFields = customFieldsGetFields( $oldId ); - $fieldDataFormat = array( - '%d', - '%d', - '%s' - ); - if ( isset( $customFields ) ) { - foreach ( $customFields as $fieldId => $fieldData ) { - $fieldData =array( - 'entity_id' => $newId, - 'field_id' => $fieldId, - 'field_data' => $fieldData - ); - $wpdb->insert( - GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data", - $fieldData, - $fieldDataFormat - ); - } - } -} - -/** - * customFieldsGetMemberInfoFields - * - * Pull the member info custom field data. - * This will be used more for admin side. - * - * @param mixed $entityID Id for the member info record - * - * @access public - * @return void - */ -function customFieldsGetFieldData( $entityID ) -{ - global $wpdb; - if ( !$entityID ) { - return false; - } - $data = array(); - $sql = " - SELECT * - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data - WHERE entity_id = %d"; - $fieldData = $wpdb->get_results( $wpdb->prepare( $sql, $entityID ), ARRAY_A ); - if ( $fieldData ) { - foreach ( $fieldData as $key => $val ) { - $data[$val['field_id']] = $val['field_data']; - } - return $data; - } else { - return false; - } -} -/** - * customFieldsGetFields - * Pull the member info custom field data. - * This will be used more for admin side. - * - * @param mixed $entityID Id for the member info record - * - * @access public - * @return void - */ -function customFieldsGetFields( $entityID, $where = ' AND true ', $uid ) -{ - global $wpdb; - if ( !$entityID) { - return false; - } - $data = array(); - $sql = " - SELECT * - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields - WHERE id IN (select field_id from ".GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data WHERE entity_id = %d)" . $where; - $fieldData = $wpdb->get_results( $wpdb->prepare( $sql, $uid ), ARRAY_A ); - echo '
',  print_r($fieldData), '
'; -} diff --git a/classes/customFieldSupport.php b/classes/customFieldSupport.php new file mode 100644 index 0000000..6f0918d --- /dev/null +++ b/classes/customFieldSupport.php @@ -0,0 +1,346 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release registratiosnSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFields.php'; +require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFieldsData.php'; + +class GlmCustomFieldSupport extends GlmDataFieldsCustomFields +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Registration Request Cart + * + * $var $cart + * @access public + */ + public $cart = false; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct(false, false); + + } + + } + + + /** + * Process submitted custom fields form + * + * Note: this function does not store the data. If this function returns good data with + * no submit problems, the calling code may simply call the storeForm() function with the + * data returned from this function along with a submission ID to have it stored. + * + * @param $fid string A form ID + * @param $recordId integer Record ID for this submission. + * Note that this should be false unless this is a re-submission - NOT YET SUPPORTED + * @param $store boolean Call storeForm() after processing form + * + * @return array See code below - False if unable to find the form or process input + * + * @access public + */ + public function submitForm($fid, $recordId, $store = false) + { + + $formId = false; + $haveForm = false; + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error('CustomFieldSupport Class: submitForm() called', E_USER_NOTICE); + } + + // Initialize result array + $result = array( + 'status' => true, + 'formFields' => false, + 'messages' => array(), + 'submitData' => array(), // For use in storing and displaying result of submission + 'required' => false + ); + + // Make sure we have a valid FID + $formId = filter_var($fid, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW); + + // Try to retrieve the form + $result['formFields'] = $this->getList("T.fid = '$fid'"); + + if ($result['formFields'] && count($result['formFields']) > 0) { + + $haveForm = true; + + // Also add default input values and fieldFail content + foreach ($result['formFields'] as $fieldKey => $fieldVal) { + $result['formFields'][$fieldKey]['submitted'] = false; + $result['formFields'][$fieldKey]['field_fail'] = false; + } + + } + + /* + * Process each input field + */ + + // If the form fields were found + if ($haveForm) { + + // For each of the fields + foreach ($result['formFields'] as $fieldKey => $fieldVal) { + + $fieldId = 'glmCustomFormField_'.$fieldKey; + + // Defaults for field data array + $fieldRes = array( + 'field_name' => $fieldVal['field_name'], + 'field_prompt' => $fieldVal['field_prompt'], + 'field_type' => $fieldVal['field_type']['name'], + 'field_data' => false + ); + + // Get field data + switch ($fieldVal['field_type']['name']) { + + case 'text': + case 'textarea': + + $formField[$fieldId] = ''; + + // If the expected form field exists + if (isset($_REQUEST) && isset($_REQUEST[$fieldId])) { + $in = filter_var($_REQUEST[$fieldId], FILTER_SANITIZE_STRING); + $result['formFields'][$fieldKey]['submitted'] = $in; + $fieldRes['field_data'] = $in; + } else { + $result['status'] = false; + trigger_error("customFieldSupport Class: submitForm() - Field '".$fieldVal['field_name']."' is missing from form submission.", E_USER_WARNING); + } + + // If we had a submission problem (missing required) + if ($fieldVal['required']['value'] && trim($result['formFields'][$fieldKey]['submitted']) == '') { + $result['formFields'][$fieldKey]['field_fail'] = true; + $result['status'] = false; + $result['required'] = true; + } + + break; + + case 'checkbox': + + $in = (isset($_REQUEST) && isset($_REQUEST[$fieldId]) && $_REQUEST[$fieldId] == 'on'); + + $result['formFields'][$fieldKey]['submitted'] = $in; + $fieldRes['field_data'] = ($in ? 'Yes' : 'No'); + + break; + + default: + break; + + + } + + // Add data to submitData array + $fieldRes['field_data'] = $result['formFields'][$fieldKey]['submitted']; + $result['submitData'][] = $fieldRes; + + } + + if($result['required']) { + $messages[] = 'Some required information was not submitted.'; + } + + } + + // if a store request was included - do that now + if ($store) { + $result = $this->storeForm($fid, $recordId, $result); + } + + return $result; + + } + + /** + * Store submitted custom fields data retured by submitForm() + * + * Note: this function does not process input data. That is performed by submitForm(). + * After collecting submitted data using submitForm() and checking that all submitted + * data is complete, the calling code should use this function to store the data. + * + * Note also that it is not necessary to store this data unless it's needed for searches later. + * + * @param $fid string A form ID + * @param $recordId integer Record ID for this submission. + * @param $submitResult array Array of data supplied by submitForm() + * + * @return array Array of result data (below) - False if not success. + * array ( + * 'stored_id' => array( + * 'field_name' => {short field name}, + * 'field_prompt' => {prompt issued for this field}, + * 'data' => {submitted data}) + * ) + * ) + * + * @access public + */ + public function storeForm($fid, $recordId, $submitResult) + { + + $formId = false; + $formUpdate = false; + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error('CustomFieldSupport Class: storeForm() called', E_USER_NOTICE); + } + + // Is the Form ID valid and current + // Make sure we have a valid FID + $formId = filter_var($fid, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW); + + // Try to retrieve the form + $fields = $this->getList("T.fid = '$fid'"); + if ($fields && count($fields) <= 0) { + return false; + } + + // Do we have proper submitted data with field results - (note that fields may have been added/deleted since user input) + if (!is_array($submitResult) || !isset($submitResult['formFields']) || count($submitResult['formFields']) <= 0) { + return false; + } + + // Build a list of form field IDs to use in checking for any existing submitted data for this fid and record ID combination + $fieldIds = ''; + $sep = ''; + foreach ($submitResult['formFields'] as $field) { + $fieldIds .= $sep.$field['id']; + $sep = ','; + } + + // Get any data already stored for these fid / record ID combination + $CustomFieldsData = new GlmDataFieldsCustomFieldsData($this->wpdb, $this->config); + $formUpdate = $CustomFieldsData->getList("field_id in ($fieldIds) AND record_id = $recordId"); + + $this->wpdb->query("START TRANSACTION"); + + // For each field + foreach ($submitResult['formFields'] as $field) { + + $fType = $field['field_type']['name']; + + // If this is an update of existing data + if ($formUpdate) { + + $text_data = ($fType=='text'||$fType=='textarea' ? $field['submitted'] : ''); + $checkbox_data = ($fType=='checkbox' ? $field['submitted'] : false); + $integer_data = ($fType=='integer' ? $field['submitted'] : false); + $float_data = ($fType=='float' ? $field['submitted'] : false); + + $res = $this->wpdb->update( + GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX.'custom_field_data', + array( + 'text_data' => $text_data, + 'checkbox_data' => $checkbox_data, + 'integer_data' => $integer_data, + 'float_data' => $float_data, + ), + array( + 'field_id' => $field['id'], + 'record_id' => $recordId + ), + array( + '%s', + '%d', + '%d', + '%f' + ), + array('%d', '%d') + ); + + } else { + + $res = $this->wpdb->insert( + GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX.'custom_field_data', + array( + 'field_id' => $field['id'], + 'record_id' => $recordId, + 'text_data' => ($fType=='text'||$fType=='textarea' ? $field['submitted'] : ''), + 'checkbox_data' => ($fType=='checkbox' ? $field['submitted'] : false), + 'integer_data' => ($fType=='integer' ? $field['submitted'] : false), + 'float_data' => ($fType=='float' ? $field['submitted'] : false), + ), + array( + '%d', + '%d', + '%s', + '%d', + '%d', + '%f' + ) + ); + + } + + // If there was a failure, roll back all changes + if ($res === false) { + $this->wpdb->query("ROLLBACK"); + return false; + } + + } + + $this->wpdb->query("COMMIT"); + + return $submitResult['submitData']; + + } +} \ No newline at end of file diff --git a/classes/data/dataCustomFields.php b/classes/data/dataCustomFields.php index e5ef93c..af8c507 100644 --- a/classes/data/dataCustomFields.php +++ b/classes/data/dataCustomFields.php @@ -122,21 +122,31 @@ class GlmDataFieldsCustomFields extends GlmDataAbstract 'use' => 'a' ), - // Event ID + // Form ID + 'fid' => array ( + 'field' => 'fid', + 'type' => 'text', + 'view_only' => false, + 'use' => 'a' + ), + + // Field Name 'field_name' => array( 'field' => 'field_name', 'type' => 'text', 'required' => true, 'use' => 'a' ), - // group id - 'uid' => array ( - 'field' => 'uid', - 'type' => 'text', - 'view_only' => false, - 'use' => 'a' + + // User Prompt + 'field_prompt' => array( + 'field' => 'field_prompt', + 'type' => 'text', + 'required' => true, + 'use' => 'a' ), - // Category ID + + // Field Type 'field_type' => array( 'field' => 'field_type', 'type' => 'list', @@ -144,18 +154,21 @@ class GlmDataFieldsCustomFields extends GlmDataAbstract 'required' => true, 'use' => 'a' ), + + // Field Order + 'field_order' => array( + 'field' => 'field_order', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + // required field 'required' => array( 'field' => 'required', 'type' => 'checkbox', 'use' => 'a' - ), - // admin_search flag - 'admin_search' => array ( - 'field' => 'admin_search', - 'type' => 'checkbox', - 'use' => 'a' - ), + ) ); diff --git a/classes/data/dataCustomFieldsData.php b/classes/data/dataCustomFieldsData.php index 76436ed..55691d4 100644 --- a/classes/data/dataCustomFieldsData.php +++ b/classes/data/dataCustomFieldsData.php @@ -122,8 +122,8 @@ class GlmDataFieldsCustomFieldsData extends GlmDataAbstract 'use' => 'a' ), // Entity ID (event, member, package) - 'entity_id' => array ( - 'field' => 'entity_id', + 'record_id' => array ( + 'field' => 'record_id', 'type' => 'integer', 'view_only' => false, 'use' => 'a' @@ -136,8 +136,8 @@ class GlmDataFieldsCustomFieldsData extends GlmDataAbstract 'use' => 'a' ), - 'field_data' => array( - 'field' => 'field_data', + 'text_data' => array( + 'field' => 'text_data', 'type' => 'text', 'required' => true, 'use' => 'a' diff --git a/defines.php b/defines.php index 1c56832..6625369 100644 --- a/defines.php +++ b/defines.php @@ -8,7 +8,7 @@ // NOTE: Plugin & Database versions are defined in "/glm-member-db.php". define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_NAME', 'GLM Members Database Custom Fields'); -define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SHORT_NAME', 'Fields'); +define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SHORT_NAME', 'Custom Fields'); define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SLUG', 'glm-member-db-customfields'); // Database table prefixes - change if using add-on tables diff --git a/index.php b/index.php index 74fb839..8b0d88e 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_VERSION', '1.0.0'); -define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_VERSION', '1.0.0'); +define('GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_VERSION', '1.0.1'); // 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'); diff --git "a/models/admin/OL\357\200\242D-import/fields.php" b/models/admin/OLD-import/fields.php similarity index 100% rename from "models/admin/OL\357\200\242D-import/fields.php" rename to models/admin/OLD-import/fields.php diff --git a/models/admin/ajax/customFields.php b/models/admin/ajax/customFields.php index c735748..e5279b0 100644 --- a/models/admin/ajax/customFields.php +++ b/models/admin/ajax/customFields.php @@ -99,12 +99,9 @@ class GlmMembersAdmin_ajax_customFields extends GlmDataFieldsCustomFields $customField = $this->insertEntry(); -trigger_error($_REQUEST['required'],E_USER_NOTICE); - if (!is_array($customField) || !$customField['status']) { echo "0"; } else { - $viewFile = 'admin/ajax/newField.html'; $newFieldHtml = $this->generateHTML($customField, $viewFile); echo $newFieldHtml; diff --git a/models/admin/customFields/index.php b/models/admin/customFields/index.php index 8bd56c1..926abbd 100644 --- a/models/admin/customFields/index.php +++ b/models/admin/customFields/index.php @@ -126,6 +126,7 @@ class GlmMembersAdmin_customFields_index extends GlmDataFieldsCustomFields $haveCustomFields = false; $where = ' TRUE '; + $option = 'list'; if (isset($_REQUEST['option2'])) { $option = $_REQUEST['option2']; } @@ -140,10 +141,11 @@ class GlmMembersAdmin_customFields_index extends GlmDataFieldsCustomFields $id = $_REQUEST['id']-0; } - $uid = 0; + $fid = false; - if (isset($actionData['uid'])) { - $uid = $actionData['uid']; + // Look for the form ID (fid) + if (isset($actionData['fid'])) { + $fid = $actionData['fid']; } switch ($option) { @@ -179,7 +181,7 @@ class GlmMembersAdmin_customFields_index extends GlmDataFieldsCustomFields } - $where .= " AND uid = '$uid' "; + $where .= " AND fid = '$fid' "; // Get list of Custom Fields $custom_fields = $this->getList( $where ); @@ -196,7 +198,7 @@ class GlmMembersAdmin_customFields_index extends GlmDataFieldsCustomFields 'custom_fields' => $custom_fields, 'field_types' => $this->config['custom_field_types'], 'haveCustomFields' => $haveCustomFields, - 'uid' => $uid, + 'fid' => $fid, 'glm_action' => $glm_action ); diff --git a/models/front/customFields/formDisplay.php b/models/front/customFields/formDisplay.php new file mode 100644 index 0000000..3035dcf --- /dev/null +++ b/models/front/customFields/formDisplay.php @@ -0,0 +1,152 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release formDisplay,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFields.php'; +require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFieldsData.php'; + +/** + * GlmMembersFront_customFields_formDisplay + * + * @uses GlmDataFields + * @package GlmMemberFields + * @version 0.0.1 + * @copyright Copyright (c) 2010 All rights reserved. + * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt} + */ +class GlmMembersFront_customFields_formDisplay extends GlmDataFieldsCustomFields +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * 'view' + * + * A suggested view name that the contoller should use instead of the + * default view for this model or false to indicate that the default view + * should be used. + * + * 'data' + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + */ + public function modelAction( $actionData = false ) + { + + $formId = false; + $formFields = false; + $haveForm = false; + $view = 'displayForm.html'; + $parentFormId = $actionData['request']['parent-form-id']; + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error('Shortcode Called: glm-members-customfields-form-display', E_USER_NOTICE); + } + + // Make sure we have a valid FID and that the form exists + if (isset($actionData['request']) && isset($actionData['request']['fid'])) { + + $formId = filter_var($actionData['request']['fid'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW); + + // Try to retrieve the form + $formFields = $this->getList("T.fid = '$formId'"); + if ($formFields && count($formFields) > 0) { + + $haveForm = true; + + // Also add default fieldFail flags + foreach ($formFields as $fieldKey => $fieldVal) { + $form[$fieldKey]['field_fail'] = ''; + } + + } + + } + + // Compile template data + $templateData = array( + 'formId' => $formId, + 'formFields' => $formFields, + 'haveForm' => $haveForm, + 'parentFormId' => $parentFormId + ); + + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'front/customFields/'.$view, + 'data' => $templateData + ); + } +} + diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 8a7ce61..ca1e229 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -51,9 +51,9 @@ add_filter('glm-member-db-admin-management-hooksHelp', function($content) { * {use} can be a description of the use or where it used (i.e. "reg-event-edit") * {id} should be an ID of the record these fields are associated with, for example a registration event ID */ -add_filter( 'glm-members-customfields-edit', function( $content, $uid ){ +add_filter( 'glm-members-customfields-edit', function( $content, $fid ){ unset( $_REQUEST['glm_action'] ); - $content .= $this->controller( 'customFields', 'index', array( 'uid' => $uid ), true ); + $content .= $this->controller( 'customFields', 'index', array( 'fid' => $fid ), true ); return $content; }, 10, 2 ); @@ -64,16 +64,6 @@ add_filter( 'glm-members-customfields-edit', function( $content, $uid ){ -/** - * Filter returns the html for the form segment - */ -add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id,$cfData = false ){ - unset( $_REQUEST['glm_action'] ); - // echo "CONTENT: " . $content . " UID: " . $uid . " ID: " . $id . '
'; - $content .= $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'entityID' => $id,'cfData'=>$cfData ), true); - return $content; -}, 10, 4 ); - /** * Filter Captured Data Success Status * diff --git a/setup/commonHooks.php b/setup/commonHooks.php index 009a0ca..518c422 100644 --- a/setup/commonHooks.php +++ b/setup/commonHooks.php @@ -34,3 +34,110 @@ add_filter( 'glm-members-customfields-active', function( $active ){ return true; }, 10, 1 ); + +/** + * Does the specified Form ID have any input fields + * + * @param $content string Default state (supply false). This will be overridden if result is true. + * @param $fid string Unique ID of form + * + * returns an array with status and HTML for editing the form. + */ +add_filter( 'glm-members-customfields-have-fields', function( $haveFields, $fid){ + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error('Custom Fields Filter Called: glm-members-customfields-have-fields', E_USER_NOTICE); + } + + // Get the number of custom fields for this Form ID + require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFields.php'; + $CustomFields = new GlmDataFieldsCustomFields($this->wpdb, $this->config); + $fieldStats = $CustomFields->getStats("T.fid = '$fid'"); + + if ($fieldStats) { + $haveFields = true; + } + + return $haveFields; + +}, 10, 4 ); + +/** + * Return HTML for a custom fields form segment + * + * @param $content string Any supplied content. Form will be appended to this + * @param $fid string Unique ID of form + * @param $recordId integer Optional ID for instance of this form (generally the ID of the associated record) + * If this is 0 then it's assumed this is a new form with no existing data. + * @param $submitId string Optional ID of the submit button for the form this will be part of. + * @param $formData array Optional array of data used to populate form (Not sure we're going to keep this) + * + * returns an array with status and HTML for editing the form. + */ +add_filter( 'glm-members-customfields-form-display', function( $content, $fid, $recordId = 0, $parentFormId = false, $formData = false ){ + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error('Custom Fields Filter Called: glm-members-customfields-form-display', 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.']'); + + return $content; + +}, 10, 4 ); + +/** + * Submit a specific custom fields form segment + * + * @param $content string Any supplied content. Form will be appended to this + * @param $fid string Unique ID of form + * @param $recordId integer Optional ID for instance of this form (generally the ID of the associated record) + * If this is 0 then it's assumed this is a new form with no existing data. + * @param $store boolean Flag to request that submitted data also be stored + * + * returns an array with status and HTML for editing the form. + */ +add_filter( 'glm-members-customfields-form-submit', function( $content, $fid, $recordId = 0, $store = false ){ + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error('Custom Fields Filter Called: glm-members-customfields-form-submit', E_USER_NOTICE); + } + + require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/customFieldSupport.php'; + $CustomFieldSupport = new GlmCustomFieldSupport($this->wpdb, $this->config); + + $content = $CustomFieldSupport->submitForm($fid, $recordId, $store); + + return $content; + +}, 10, 4 ); + +/** + * Store data from a call to the "glm-members-customfields-form-submit" filter + * + * @param $content string Any supplied content. Form will be appended to this + * @param $fid string Unique ID of form + * @param $recordId integer ID for instance of this form (generally the ID of the associated record) - Required + * @param $formData array Copy of the array returned by the "glm-members-customfields-form-submit" filter. + * + * returns an array with status and HTML for editing the form. + */ +add_filter( 'glm-members-customfields-form-store', function( $content, $fid, $recordId = 0, $submitData = false ){ + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error('Custom Fields Filter Called: glm-members-customfields-form-store', E_USER_NOTICE); + } + + require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/customFieldSupport.php'; + $CustomFieldSupport = new GlmCustomFieldSupport($this->wpdb, $this->config); + + $content .= $CustomFieldSupport->storeForm($fid, $recordId, $submitData); + + return $content; + +}, 10, 4 ); + + + + diff --git a/setup/databaseScripts/create_database_V1.0.0.sql b/setup/databaseScripts/create_database_V1.0.1.sql similarity index 52% rename from setup/databaseScripts/create_database_V1.0.0.sql rename to setup/databaseScripts/create_database_V1.0.1.sql index cd0e4e7..d43f6b6 100644 --- a/setup/databaseScripts/create_database_V1.0.0.sql +++ b/setup/databaseScripts/create_database_V1.0.1.sql @@ -15,14 +15,14 @@ -- Field Setup Table CREATE TABLE {prefix}custom_fields ( id INT NOT NULL AUTO_INCREMENT, - field_name TINYTEXT NOT NULL DEFAULT '', -- Field Name + 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 - admin_search BOOLEAN NOT NULL DEFAULT '0', -- If the field is added to member list filters. required BOOLEAN NOT NULL DEFAULT '0', -- If the field is required. - uid varchar(255) NOT NULL DEFAULT '', -- id for the series of custom fields associated with an entity PRIMARY KEY (id), - INDEX(field_name(20)) + INDEX (field_name(40)) ); ---- @@ -30,10 +30,13 @@ CREATE TABLE {prefix}custom_fields ( -- Data Table CREATE TABLE {prefix}custom_field_data ( id INT NOT NULL AUTO_INCREMENT, - field_id INT NOT NULL DEFAULT 0, -- Field Id -- Member Info Id - field_data TEXT NOT NULL DEFAULT '', -- Data for the field - entity_id INT NOT NULL DEFAULT 0, -- id for the specific field associated with an entity + field_id INT NOT NULL DEFAULT 0, -- Pointer to ID of custom_fields table for this field + 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 '', -- Data for a boolean field + integer_data INTEGER NOT NULL DEFAULT '', -- Data for an integer field + float_data FLOAT NOT NULL DEFAULT '', -- Data for a float field PRIMARY KEY (id), - INDEX(field_id), - INDEX(entity_id) + INDEX (field_id), + INDEX (record_id) ); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index d6cf825..aa2c14e 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -14,6 +14,7 @@ */ $glmMembersCustomFieldsDbVersions = array( - '1.0.0' => array('version' => '1.0.0', 'tables' => 2, 'date' => '12/01/2017') + '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') ); diff --git a/setup/databaseScripts/update_database_V1.0.1.sql b/setup/databaseScripts/update_database_V1.0.1.sql new file mode 100644 index 0000000..fecd86a --- /dev/null +++ b/setup/databaseScripts/update_database_V1.0.1.sql @@ -0,0 +1,46 @@ +-- Gaslight Media Members Database - Registratiuons Add-On +-- File Created: 08/30/16 09:47:15 +-- Database Version: 0.0.7 +-- 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_fields CHANGE uid fid TEXT; + +---- + +ALTER TABLE {prefix}custom_fields DROP COLUMN admin_search; + +---- + +DROP INDEX entity_id ON {prefix}custom_field_data; + +---- + +ALTER TABLE {prefix}custom_field_data CHANGE entity_id record_id INTEGER; + +---- + +CREATE INDEX record_id ON {prefix}custom_field_data (record_id); + +---- + +ALTER TABLE {prefix}custom_field_data CHANGE field_data text_data TEXT; + +---- + +ALTER TABLE {prefix}custom_field_data ADD COLUMN checkbox_data BOOLEAN; + +---- + +ALTER TABLE {prefix}custom_field_data ADD COLUMN integer_data INTEGER; + +---- + +ALTER TABLE {prefix}custom_field_data ADD COLUMN float_data FLOAT; + +---- + +ALTER TABLE {prefix}custom_fields ADD COLUMN field_prompt TINYTEXT; diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 2fcd3e1..bc450d5 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -25,175 +25,4 @@ * * *** Also note that parameters will be in the context of the main front controller constructor. *** */ -add_filter('glm-member-db-front-members-detail-sidebar', function($content, $id) { - $fieldData = do_shortcode('[glm-members-fields-detail member='.$id.', template="detail-sidemenu" order="title"]'); - $content .= $fieldData; - return $content; - }, - 10, - 2 -); -add_filter('glm-member-db-front-members-list-info', function($content, $id) { - $fieldData = do_shortcode('[glm-members-fields-list member='.$id.', template="detail-sidemenu" order="title"]'); - $content .= $fieldData; - return $content; - }, - 10, - 2 -); -add_filter( 'glm-member-db-front-search-query', function( $queryParts ) { - // Get all custom fields - $customFields = $this->wpdb->get_results( - "SELECT * - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields", - ARRAY_A - ); - if ( isset( $customFields ) && count( $customFields ) > 0 ) { - foreach ( $customFields as $key => $field ) { - switch ( $field['field_type'] ) { - case 'text': - case 'textarea': - $field_name = preg_replace( '/[ -]/', '_', strtolower( $field['field_name'] ) ); - if ( isset( $_REQUEST[$field_name] ) && filter_var( $_REQUEST[$field_name], FILTER_SANITIZE_STRING ) ) { - $textSearch = $this->wpdb->esc_like( $_REQUEST[$field_name] ); - $queryParts[] = " T.id IN ( - SELECT entity_id - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data - WHERE field_data like '%" . $textSearch . "%' - AND field_id = (SELECT id - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields - WHERE field_name = '" . esc_sql( $field['field_name'] ) . "') - ) "; - } - - break; - case 'checkbox': - // convert name to lower case and replace spaces with _ - $field_name = preg_replace( '/[ -]/', '_', strtolower( $field['field_name'] ) ); - if ( isset( $_REQUEST[$field_name] ) && filter_var( $_REQUEST[$field_name], FILTER_VALIDATE_BOOLEAN ) ) { - $queryParts[] = " T.id IN ( - SELECT entity_id - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data - WHERE field_data = 'Yes' - AND field_id = (SELECT id - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields - WHERE field_name = '" . esc_sql( $field['field_name'] ) . "') - ) "; - } - break; - } - } - } - return $queryParts; -}); -add_filter( 'glm-member-db-front-search-request', function( $actionData ) { - global $wpdb; - // Get all custom fields - $customFields = $wpdb->get_results( - "SELECT * - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields", - ARRAY_A - ); - if ( isset( $customFields ) && count( $customFields ) > 0 ) { - foreach ( $customFields as $key => $field ) { - // convert name to lower case and replace spaces with _ - $field_name = preg_replace( '/[ -]/', '_', strtolower( $field['field_name'] ) ); - if ( isset( $actionData['request'][$field_name] ) && $actionData['request'][$field_name]) { - $_REQUEST[$field_name] = $actionData['request'][$field_name]; - } - } - } - return $actionData; -}, 10, 1); -add_filter( 'glm-member-db-customfields-front-list-query-params', function( $query ){ - $queryParams = array(); - // Get all custom fields - $customFields = $this->wpdb->get_results( - "SELECT field_name,field_type - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields", - ARRAY_A - ); - foreach ( $customFields as $field ) { - switch ( $field['field_type'] ) { - case 'checkbox': - $fieldName = preg_replace( '/[ -]/', '_', strtolower( $field['field_name'] ) ); - if ( isset( $_REQUEST[$fieldName] ) ) { - $queryParams[] = "$fieldName={$_REQUEST[$fieldName]}"; - } - break; - } - } - return ( !empty( $queryParams ) ? $query . '&'.implode( '&', $queryParams): $query); -},10, 1); - -add_filter('get_glm_custom_fields', function($uid,$entity_id) { - global $wpdb; - $fieldsTable = GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields"; - $dataTable = GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data"; - - $query = "SELECT $dataTable.field_data, $fieldsTable.field_type, $fieldsTable.field_name " - . "FROM $dataTable " - . "LEFT JOIN $fieldsTable " - . "ON $dataTable.field_id = $fieldsTable.id WHERE $dataTable.entity_id = $entity_id;"; - - $result = $this->wpdb->get_results( $query, ARRAY_A ); - foreach($result as $key=>$value){ - if ($result[$key]['field_type'] == 'textarea') { - $result[$key]['field_data'] = wpautop($result[$key]['field_data']); - } - } - -// echo "
AA" . print_r($result) . "ZZ";
-    return $result;
-    },
-    10,
-    2
-);
-add_filter('glm_custom_fields', function($attribute, $id = 0) {
-
-    global $wpdb;
-    $query = "SELECT D.field_data, F.field_type FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data D, ".GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX."custom_fields F "
-        . "WHERE D.entity_id = $id "
-        . "AND D.field_id IN (SELECT id FROM ".GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX."custom_fields WHERE field_name LIKE '$attribute' ) "
-        . "AND F.field_name LIKE '$attribute'";
-
-    $result = $this->wpdb->get_row( $query, ARRAY_A );
-    if ($result['field_type'] == 'textarea') {
-        $result['field_data'] = wpautop($result['field_data']);
-    }
-//    echo "
AA" . print_r($result) . "ZZ";
-    return $result['field_data'];
-    },
-    10,
-    2
-);
-add_filter('glm_custom_fields_member_types', function() {
-
-    $query = "SELECT name FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_type";
-    $result = $this->wpdb->get_results( $query, ARRAY_A );
-    return $result;
-    },
-    10,
-    2
-);
-
-/**
- * Filter: glm-get-custom-field-count
- * Usage: apply_filters( 'glm-get-custom-field-count','reviewed','Yes' )
- */
-add_filter( 'glm-get-custom-field-count', function( $field_name, $field_value = '' ){
-    if ( $field_name ) {
-        global $wpdb;
-        $sql = "SELECT count(field_data) FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data WHERE field_data LIKE '$field_value'"
-        . " AND field_id IN (SELECT id FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields WHERE field_name LIKE '$field_name')";
-        $count = $wpdb->get_var(
-            $sql
-        );
-        return $count;
-    }
-    return false;
-},
-10,
-2
-);
diff --git a/setup/hooksHelp.html b/setup/hooksHelp.html
index 41937f5..332f20e 100644
--- a/setup/hooksHelp.html
+++ b/setup/hooksHelp.html
@@ -44,9 +44,9 @@
 
     glm-members-customfields-edit
     FILTER
-    $content, $uid
+    $content, $fid
     
-        Return HTML for field add/delete/edit for the specified form ($uid).
+        Return HTML for field add/delete/edit for the specified form ($fid).
         

The $content parameter should be an empty string when this filter is applied. Any HTML returned from this filter will be appended to the supplied text. @@ -54,7 +54,7 @@ resulting string that's returned.

- The $uid parameter is a text string that is a unique identifier for the the form that is to + The $fid parameter is a text string that is a unique identifier for the the form that is to be edited. This should include the slug of the plugin that is calling for this form and a name or other identifier for the specific form. This might typically be specified in the form of a slug with hyphens between the words. @@ -63,11 +63,11 @@ Fields Use - glm-members-custom-fields-form + glm-members-customfields-form-display FILTER - $content, $uid, $id, $cfData + $content, $fid, $id, ,$parentFormId, $cfData - Displays a specific custom fields from to request user input. + Displays a specific custom fields form to request user input.

The $content parameter should be an empty string when this filter is applied. Any HTML returned from this filter will be appended to the supplied text. @@ -75,20 +75,27 @@ resulting string that's returned.

- The $uid parameter is a text string that is a unique identifier for the the form that is to + The $fid parameter is a text string that is a unique identifier for the the form that is to be edited. This should include the slug of the plugin that is calling for this form and a name or other identifier for the specific form. This might typically be specified in the form of a slug with hyphens between the words.

The $id parameter is an INTEGER that is unique to this specific use of the form - specified by $uid. For example, if $uid points to a form with added fields to + specified by $fid. For example, if $fid points to a form with added fields to be used along with the usual fields in a contact information form, the $id parameter might be the 'id' field from the record containing the contact that's being edited. Any results submitted will be stored along with this $id. If - this $uid and $id pair are used anywhere else, data submitted there will replace + this $fid and $id pair are used anywhere else, data submitted there will replace the other uses of the same form and id.

+

+ If the $parentFormId parameter is supplied, additional JAVAScript code will be included + in the form segment output to link into the submit process and check for all required + data in the form segment. If that segment has any required fields that are not + completed, it will display a notice and block submission of the form. Note that + this requires jQuery to be loaded and available. +

The $cfData field is an array that contains field data to use as the default when the form is displayed. This will usually come from a previous submission diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 9e6a1e6..5510a26 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -87,37 +87,108 @@ */ $glmMembersCustomFieldsShortcodes = array( - 'glm-members-fields-detail' => array( + 'glm-members-customfields-form-display' => array( 'plugin' => GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SLUG, - 'menu' => 'fields', - 'action' => 'detail', + 'menu' => 'customFields', + 'action' => 'formDisplay', 'table' => false, 'attributes' => array( - 'type' => 'all', - 'order' => 'title', - 'member' => false, - 'template' => false, - 'limit' => null, - 'featured' => null, - 'current' => null, + 'fid' => false, + 'record-id' => false, + 'parent-form-id' => false, + 'form-data' => false ) ), - 'glm-members-fields-list' => array( + 'glm-members-customfields-form-submit' => array( 'plugin' => GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SLUG, - 'menu' => 'fields', - 'action' => 'list', + 'menu' => 'customFields', + 'action' => 'formDisplay', 'table' => false, 'attributes' => array( - 'type' => 'all', - 'order' => 'title', - 'member' => false, - 'template' => false, - 'limit' => null, - 'featured' => null, - 'current' => null, + 'fid' => false, + 'record-id' => false, + 'parent-form-id' => false, + 'form-data' => false ) - ), + ) ); -$glmMembersCustomFieldsShortcodesDescription = ''; +$glmMembersCustomFieldsShortcodesDescription = ' + + [glm-members-customfields-form-display] +   + + Displays a specific custom form for a specific record. + + + +   + fid="{Form ID String}" + + The "fid" attribute is the Form ID string that is unique to the + custom form created using admin "glm-members-customfields-edit" filter. +

+ The standard for this for ID is "{add-on-slug}-customfields-{descr-slug}-{optional-id}.
+ where:
+   {add-on-slug} is the calling add-on\'s slug
+   {descr-slug} is a short slug describing the use of this form
+   {optional-id} is the optional ID of a record this form is always associated with
+

+

+ The {optional-id} would be required if there are multiple uses of this form. For example, if + the form is for added fields for a registrant to an event, the each event would have a form + of this type (which might be different). In that case the event ID could be use as the + {optional-id} to distinguish the form for one event from anohter event. Also in this case + there would be mulitple registrants for a specific event, so another specific ID will be used for each + registrant. This is the "record-id" specified when using the form for input or retrieving that + data later. +

+ + + +   + record-id="{Record ID Number}" + + The "record-id" attribute is a unique numberic id for a specific instance (use) of this custom form. + This is optional. If it\'s not supplied the default is 0. Using the default would be appropriate for + situations where there only be a single use of this form, which is probably unusual. + + + +   + parent-form-id="{ID of Parent Form}" + + If the "parent-form-id" attribute is supplied, the custom form segment will include jQuery scripting + that will hook into the checkout action of the form. If any of the custom fields that are required + are not completed, this code will display a notice to the user and block form submission.
+
+ If you have code on that page that intercepts the submit action, use the following code to determine + if submit has been blocked by a custom fields form before taking other action. +
+            if (e.isDefautPrevented()) {
+                return false;
+            }
+        
+ + + +   + form-data="{serialized data}" + + The "form-data" attribute is a serialized compilation of default data for this form. (might not use this here) + This attribute is optional. If not supplied, the default form values are used. + + + + [glm-members-customfields-form-submit] +   + + Processes submission of a specific form segment. + + + +   + NOT WRITTEN YET + +'; diff --git a/setup/validActions.php b/setup/validActions.php index f6a0815..35724b3 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -67,9 +67,8 @@ $glmMembersCustomFieldsAddOnValidActions = array( ) ), 'frontActions' => array( - 'fields' => array( -// 'list' => GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SLUG, -// 'detail' => GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SLUG, + 'customFields' => array( + 'formDisplay' => GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_SLUG ), ) ); diff --git a/views/admin/ajax/newField.html b/views/admin/ajax/newField.html index 6f9955a..39429fd 100644 --- a/views/admin/ajax/newField.html +++ b/views/admin/ajax/newField.html @@ -1,11 +1,12 @@ {* A single line for the custom fields edit table *} - -
{$fieldData.field_name}
+ + {$fieldData.field_name} {$fieldData.field_type.name} {$fieldData.required.name} - -
Delete
+
Delete
+ Prompt: {$fieldData.field_prompt} \ No newline at end of file diff --git a/views/admin/customFields/index.html b/views/admin/customFields/index.html index 20c52eb..93be731 100644 --- a/views/admin/customFields/index.html +++ b/views/admin/customFields/index.html @@ -1,19 +1,21 @@ -
Add a Custom Field
{* New field form *} -
- +
+
- + + + + + - + - - + + -
Field Name: - -
User Prompt:
Field Type:Field Type: - + {foreach $field_types as $val => $label} {/foreach} @@ -21,76 +23,55 @@
Required? - - Required?

* Required

-
Cancel
-
Add new Custom Field
- +
Cancel
+
Add new Custom Field
+
{* Delete field button confirmation dialog box *} -
+

Are you sure you want to delete this field?

-

Yes, delete this field

-

Cancel

+

Yes, delete this field

+

Cancel

{* Edit field dialog box *} -
-
- - - - - +
+
- - + + - + + + + + - - {if $uid == 'glm-member-db'} - - - - - {/if} - + -
Field Name: - - Field Name:
Field Type:User Prompt:
Field Type: - + {foreach $field_types as $val => $label} {/foreach}
Admin Searchable - - - (text or checkbox only) -
Required? - - -

* Required

- Cancel + Cancel -
{* Update and error messages *} @@ -105,75 +86,80 @@ {* Fields Table *} - +
- + - + {if $haveCustomFields} {foreach $custom_fields as $t} - - + + - + {/foreach} {else} - + {/if}
Field Name Type Required  +
Add a Custom Field
+ +   +
-
- {$t.field_name} -
-
{$t.field_name} {$t.field_type.name} {$t.required.name} - -
Delete
+
Delete
Prompt: {$t.field_prompt}
(no custom fields listed)
(no custom fields listed)
- +{/if} + \ No newline at end of file diff --git a/views/front/fields/detail.html b/views/front/fields/OLDdetail.html similarity index 100% rename from views/front/fields/detail.html rename to views/front/fields/OLDdetail.html diff --git a/views/front/fields/list.html b/views/front/fields/OLDlist.html similarity index 100% rename from views/front/fields/list.html rename to views/front/fields/OLDlist.html -- 2.17.1