From: Chuck Scott Date: Mon, 11 Dec 2017 14:28:19 +0000 (-0500) Subject: Custom Fields now working for event and event registrants. X-Git-Tag: v1.0.0^2~40 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=5815f0e5158c0e3d251b456e5c6fd952c74c741a;p=WP-Plugins%2Fglm-member-db-customfields.git Custom Fields now working for event and event registrants. --- 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/OLD-import/fields.php b/models/admin/OLD-import/fields.php new file mode 100644 index 0000000..6736069 --- /dev/null +++ b/models/admin/OLD-import/fields.php @@ -0,0 +1,411 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ +require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFieldsData.php'; +require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'; +/* + * This class performs the work for the default action of the "Import" menu + * option. + * + */ +class GlmMembersAdmin_import_fields extends GlmDataFieldsCustomFieldsData +{ + + const CSV_CHARS_PER_LINE = 6000; + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /** + * errors + * + * @var $errors + * @access public + */ + public $errors = array(); + + /** + * numberProcessed + * + * @var float + * @access public + */ + public $numberProcessed = 0; + + /** + * totalFields + * + * @var float + * @access public + */ + public $totalFields = 0; + + /** + * processingComplete + * + * @var bool + * @access public + */ + public $processingComplete = false; + + /** + * Constructor + * + * This contractor 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 successful 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 controller 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) + { + // Set the view file + $view = 'fields.html'; + $failure = false; + $option = 'fields'; + $clearData = false; + $importRet = false; + $haveMembers = false; + $fileExists = false; + $isValid = false; + // Check to see if they have members + $haveMembers = $this->wpdb->get_var( + "SELECT count(id) + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members" + ); + // $fileData - The main files needed for the member import + // - field: input field name + // - name: file name + // - exists: Does file exists. Set to false at first. + // - validate: Validation array. Header line must match this. + // - type: Type of file. Used in the processing function. + $fileData = array( + 'Fields' => array( + 'field' => 'fields_file', + 'name' => 'fieldsData.csv', + 'exists' => false, + 'validate' => array( 'member_id', 'field_name', 'field_value' ), + 'type' => 'fields', + ), + ); + // Setting readyToProcess to false (initialize) + $readyToProcess = false; + + // Set the $option if found in $_REQUEST array + if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') { + $option = $_REQUEST['option']; + } + + // Set the $option2 if found in $_REQUEST array + if (isset($_REQUEST['option2']) && $_REQUEST['option2'] != '') { + $option2 = $_REQUEST['option2']; + } + + // Set variable for the upload directory + $wpUploadDir = wp_get_upload_dir(); + + // Set the $uploadPath for import files + $uploadPath = $wpUploadDir['basedir'] . '/' . 'glm-member-import'; + + // If the folder for the upload import files doesn't exists create one. + if ( !is_dir( $uploadPath ) ) { + // Get old umask + $oldMask = umask(0); + // Set folder permission + mkdir( $uploadPath, 0770 ); + // reset old umask + umask( $oldMask ); + } + + switch( $option ) { + + case 'fieldsValidate'; + $validFiles = 0; + // Set the view file + $view = 'fieldsValidate.html'; + $fileCount = count( $fileData ); + // Move any files uploaded + if ( isset( $_FILES ) ) { + foreach ( $fileData as $fileHeader => $file ) { + if ( !$_FILES[$file['field']]['error'] ) { + move_uploaded_file( $_FILES[$file['field']]['tmp_name'], $uploadPath . '/'. $file['name'] ); + } + } + } + // Check that each file exists + foreach ( $fileData as $fileHeader => $file ) { + if ( is_file( $uploadPath . '/' . $file['name'] ) ) { + $fileData[$fileHeader]['exists'] = true; + $fData = $this->readCSVFileHeaders( $uploadPath . '/' . $file['name'] ); + $isValid = ( $file['validate'] == $fData ); + if ( $isValid ) { + $validFiles++; + } + $fileData[$fileHeader]['data'] = $fData; + $fileData[$fileHeader]['isValid'] = $isValid; + } + } + $readyToProcess = ( $validFiles == $fileCount ); + break; + + case 'fieldsProcess': + $memberInfoData = new GlmDataMemberInfo( $this->wpdb, $this->config ); + foreach ( $fileData as $fileHeader => $file ) { + if ( is_file( $uploadPath . '/' . $file['name'] ) ) { + $fields = $this->readCSVFields( $uploadPath . '/'. $file['name'] ); + //echo '
$fields: ' . print_r( $fields, true ) . '
'; + $this->totalFields = count( $fields ); + // Clear the custom field data table + $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data" ); + foreach ( $fields as $customRow ) { + // Need to first get the member id from the database + // It will match from the old_member_id field + $memberId = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + WHERE old_member_id = %d", + $customRow[0] + ) + ); + // get the active member info id + $memberInfoId = + $memberInfoData->getActiveInfoIdForMember( $memberId ); + $customFieldId = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields + WHERE field_name = %s", + $customRow[1] + ) + ); + if ( $customFieldId ) { + $newId = $this->wpdb->insert( + GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . 'custom_field_data', + array( + 'ref_dest' => $memberInfoId, + 'field_id' => $customFieldId, + 'field_data' => $customRow[2], + ), + array( + '%d', + '%d', + '%s' + ) + ); + $this->numberProcessed++; + } + } + $importRet = array(); + } + } + if ( count( $this->errors ) == 0 ) { + $readyToProcess = true; + } + // Here we need to check to see if we processed all members. + // Also the counter has to increment the total processed so far. + if ( $this->numberProcessed == $this->totalFields ) { + $this->processingComplete = true; + } + // Set the view file:< + $view = 'fieldsProcess.html'; + break; + + case 'fields': + default: + // Set the view file + $view = 'fields.html'; + // check upload dir to see if they have any files in yet + foreach ( $fileData as $fileHeader => $file ) { + if ( is_file( $uploadPath . '/' . $file['name'] ) ) { + $fileData[$fileHeader]['exists'] = true; + $fileData[$fileHeader]['mtime'] = filemtime( $uploadPath . '/' . $file['name'] ); + } + } + + break; + + } + + // Setup the template data array + $templateData = array( + 'fileExists' => $fileExists, + 'option' => $option, + 'errors' => $this->errors, + 'numberProcessed' => $this->numberProcessed, + 'totalFields' => $this->totalFields, + 'completed' => $this->processingComplete, + 'data' => false, + 'fileData' => $fileData, + 'clearData' => $clearData, + 'importRet' => $importRet, + 'csvData' => '
$fileData: ' . print_r( $fileData, true ) . '
', + 'readyToProcess' => $readyToProcess, + 'haveMembers' => $haveMembers, + 'isValid' => $isValid, + 'sampleFileUrl' => GLM_MEMBERS_PLUGIN_BASE_URL . '/sample-files/', + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/import/' . $view, + 'data' => $templateData, + ); + + } + + /** + * Read in fields from a csv file + * + * Header line as follows. Data follows immediately below this line. this + * line and all above it are ignored. + * + * 'member_id','member_name','member_login','member_passwd','contact_email' + * + * @param string $csv Temporary file name of csv file upload + * + * @return array Array of data from CSV file or an error message + * + */ + public function readCSVFields($csv) + { + + $fields = array(); + $startImport = false; + + // Try to open file + if (($handle = fopen($csv, "r")) !== false) { + + // For each line in the file + while (($c = fgetcsv($handle, 1000, ",")) !== false) { + + // If we're past the header, the first item is numeric, and we have at least 5 fields + if($startImport && ($c[0]-0) > 0 && count($c) >= 3) { + + // Add this line of data to Contacts + $fields[] = $c; + + } + + // If we find the header, assume all data is below that + if ($c[0] == 'member_id') { + $startImport = true; + } + + } + + fclose($handle); + + } else { + return "No file submitted."; + } + + // If we never found the header + if (!$startImport) { + return "Required header not found in file."; + } + + // If we found no data below the header + if (count($fields) == 0) { + return "Header found but no data followed"; + } + + return $fields; + + } + + /** + * readCSVFileHeaders + * + * Read the cvs file. Just the first line is read. + * + * @param mixed $fileName Name of the file (path) + + * @access public + * @return void + */ + public function readCSVFileHeaders( $fileName ) + { + $fileHeaders = array(); + if ( ( $fp = fopen( $fileName, 'r' ) ) !== false ) { + // get first line to use as headers + $fileHeaders = fgetcsv( $fp, SELF::CSV_CHARS_PER_LINE, ',' ); + fclose( $fp ); + } + + return $fileHeaders; + } +} diff --git "a/models/admin/OL\357\200\242D-import/fields.php" "b/models/admin/OL\357\200\242D-import/fields.php" deleted file mode 100644 index 6736069..0000000 --- "a/models/admin/OL\357\200\242D-import/fields.php" +++ /dev/null @@ -1,411 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 0.1 - */ -require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFieldsData.php'; -require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'; -/* - * This class performs the work for the default action of the "Import" menu - * option. - * - */ -class GlmMembersAdmin_import_fields extends GlmDataFieldsCustomFieldsData -{ - - const CSV_CHARS_PER_LINE = 6000; - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - - /** - * errors - * - * @var $errors - * @access public - */ - public $errors = array(); - - /** - * numberProcessed - * - * @var float - * @access public - */ - public $numberProcessed = 0; - - /** - * totalFields - * - * @var float - * @access public - */ - public $totalFields = 0; - - /** - * processingComplete - * - * @var bool - * @access public - */ - public $processingComplete = false; - - /** - * Constructor - * - * This contractor 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 successful 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 controller 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) - { - // Set the view file - $view = 'fields.html'; - $failure = false; - $option = 'fields'; - $clearData = false; - $importRet = false; - $haveMembers = false; - $fileExists = false; - $isValid = false; - // Check to see if they have members - $haveMembers = $this->wpdb->get_var( - "SELECT count(id) - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members" - ); - // $fileData - The main files needed for the member import - // - field: input field name - // - name: file name - // - exists: Does file exists. Set to false at first. - // - validate: Validation array. Header line must match this. - // - type: Type of file. Used in the processing function. - $fileData = array( - 'Fields' => array( - 'field' => 'fields_file', - 'name' => 'fieldsData.csv', - 'exists' => false, - 'validate' => array( 'member_id', 'field_name', 'field_value' ), - 'type' => 'fields', - ), - ); - // Setting readyToProcess to false (initialize) - $readyToProcess = false; - - // Set the $option if found in $_REQUEST array - if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') { - $option = $_REQUEST['option']; - } - - // Set the $option2 if found in $_REQUEST array - if (isset($_REQUEST['option2']) && $_REQUEST['option2'] != '') { - $option2 = $_REQUEST['option2']; - } - - // Set variable for the upload directory - $wpUploadDir = wp_get_upload_dir(); - - // Set the $uploadPath for import files - $uploadPath = $wpUploadDir['basedir'] . '/' . 'glm-member-import'; - - // If the folder for the upload import files doesn't exists create one. - if ( !is_dir( $uploadPath ) ) { - // Get old umask - $oldMask = umask(0); - // Set folder permission - mkdir( $uploadPath, 0770 ); - // reset old umask - umask( $oldMask ); - } - - switch( $option ) { - - case 'fieldsValidate'; - $validFiles = 0; - // Set the view file - $view = 'fieldsValidate.html'; - $fileCount = count( $fileData ); - // Move any files uploaded - if ( isset( $_FILES ) ) { - foreach ( $fileData as $fileHeader => $file ) { - if ( !$_FILES[$file['field']]['error'] ) { - move_uploaded_file( $_FILES[$file['field']]['tmp_name'], $uploadPath . '/'. $file['name'] ); - } - } - } - // Check that each file exists - foreach ( $fileData as $fileHeader => $file ) { - if ( is_file( $uploadPath . '/' . $file['name'] ) ) { - $fileData[$fileHeader]['exists'] = true; - $fData = $this->readCSVFileHeaders( $uploadPath . '/' . $file['name'] ); - $isValid = ( $file['validate'] == $fData ); - if ( $isValid ) { - $validFiles++; - } - $fileData[$fileHeader]['data'] = $fData; - $fileData[$fileHeader]['isValid'] = $isValid; - } - } - $readyToProcess = ( $validFiles == $fileCount ); - break; - - case 'fieldsProcess': - $memberInfoData = new GlmDataMemberInfo( $this->wpdb, $this->config ); - foreach ( $fileData as $fileHeader => $file ) { - if ( is_file( $uploadPath . '/' . $file['name'] ) ) { - $fields = $this->readCSVFields( $uploadPath . '/'. $file['name'] ); - //echo '
$fields: ' . print_r( $fields, true ) . '
'; - $this->totalFields = count( $fields ); - // Clear the custom field data table - $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_field_data" ); - foreach ( $fields as $customRow ) { - // Need to first get the member id from the database - // It will match from the old_member_id field - $memberId = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT id - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - WHERE old_member_id = %d", - $customRow[0] - ) - ); - // get the active member info id - $memberInfoId = - $memberInfoData->getActiveInfoIdForMember( $memberId ); - $customFieldId = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT id - FROM " . GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . "custom_fields - WHERE field_name = %s", - $customRow[1] - ) - ); - if ( $customFieldId ) { - $newId = $this->wpdb->insert( - GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_DB_PREFIX . 'custom_field_data', - array( - 'ref_dest' => $memberInfoId, - 'field_id' => $customFieldId, - 'field_data' => $customRow[2], - ), - array( - '%d', - '%d', - '%s' - ) - ); - $this->numberProcessed++; - } - } - $importRet = array(); - } - } - if ( count( $this->errors ) == 0 ) { - $readyToProcess = true; - } - // Here we need to check to see if we processed all members. - // Also the counter has to increment the total processed so far. - if ( $this->numberProcessed == $this->totalFields ) { - $this->processingComplete = true; - } - // Set the view file:< - $view = 'fieldsProcess.html'; - break; - - case 'fields': - default: - // Set the view file - $view = 'fields.html'; - // check upload dir to see if they have any files in yet - foreach ( $fileData as $fileHeader => $file ) { - if ( is_file( $uploadPath . '/' . $file['name'] ) ) { - $fileData[$fileHeader]['exists'] = true; - $fileData[$fileHeader]['mtime'] = filemtime( $uploadPath . '/' . $file['name'] ); - } - } - - break; - - } - - // Setup the template data array - $templateData = array( - 'fileExists' => $fileExists, - 'option' => $option, - 'errors' => $this->errors, - 'numberProcessed' => $this->numberProcessed, - 'totalFields' => $this->totalFields, - 'completed' => $this->processingComplete, - 'data' => false, - 'fileData' => $fileData, - 'clearData' => $clearData, - 'importRet' => $importRet, - 'csvData' => '
$fileData: ' . print_r( $fileData, true ) . '
', - 'readyToProcess' => $readyToProcess, - 'haveMembers' => $haveMembers, - 'isValid' => $isValid, - 'sampleFileUrl' => GLM_MEMBERS_PLUGIN_BASE_URL . '/sample-files/', - ); - - // Return status, suggested view, and data to controller - return array( - 'status' => true, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/import/' . $view, - 'data' => $templateData, - ); - - } - - /** - * Read in fields from a csv file - * - * Header line as follows. Data follows immediately below this line. this - * line and all above it are ignored. - * - * 'member_id','member_name','member_login','member_passwd','contact_email' - * - * @param string $csv Temporary file name of csv file upload - * - * @return array Array of data from CSV file or an error message - * - */ - public function readCSVFields($csv) - { - - $fields = array(); - $startImport = false; - - // Try to open file - if (($handle = fopen($csv, "r")) !== false) { - - // For each line in the file - while (($c = fgetcsv($handle, 1000, ",")) !== false) { - - // If we're past the header, the first item is numeric, and we have at least 5 fields - if($startImport && ($c[0]-0) > 0 && count($c) >= 3) { - - // Add this line of data to Contacts - $fields[] = $c; - - } - - // If we find the header, assume all data is below that - if ($c[0] == 'member_id') { - $startImport = true; - } - - } - - fclose($handle); - - } else { - return "No file submitted."; - } - - // If we never found the header - if (!$startImport) { - return "Required header not found in file."; - } - - // If we found no data below the header - if (count($fields) == 0) { - return "Header found but no data followed"; - } - - return $fields; - - } - - /** - * readCSVFileHeaders - * - * Read the cvs file. Just the first line is read. - * - * @param mixed $fileName Name of the file (path) - - * @access public - * @return void - */ - public function readCSVFileHeaders( $fileName ) - { - $fileHeaders = array(); - if ( ( $fp = fopen( $fileName, 'r' ) ) !== false ) { - // get first line to use as headers - $fileHeaders = fgetcsv( $fp, SELF::CSV_CHARS_PER_LINE, ',' ); - fclose( $fp ); - } - - return $fileHeaders; - } -} 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.0.sql deleted file mode 100644 index cd0e4e7..0000000 --- a/setup/databaseScripts/create_database_V1.0.0.sql +++ /dev/null @@ -1,39 +0,0 @@ --- Gaslight Media Members Database - Fields Add-On --- File Created: 2017-03-27 --- Database Version: 1.0.0 --- 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, - field_name TINYTEXT NOT NULL DEFAULT '', -- Field Name - 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)) -); - ----- - --- 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 - PRIMARY KEY (id), - INDEX(field_id), - INDEX(entity_id) -); diff --git a/setup/databaseScripts/create_database_V1.0.1.sql b/setup/databaseScripts/create_database_V1.0.1.sql new file mode 100644 index 0000000..d43f6b6 --- /dev/null +++ b/setup/databaseScripts/create_database_V1.0.1.sql @@ -0,0 +1,42 @@ +-- Gaslight Media Members Database - Fields Add-On +-- File Created: 2017-03-27 +-- Database Version: 1.0.0 +-- 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 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 (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/OLDdetail.html b/views/front/fields/OLDdetail.html new file mode 100644 index 0000000..25b417d --- /dev/null +++ b/views/front/fields/OLDdetail.html @@ -0,0 +1,19 @@ +
Specifications
+{foreach $field_values as $key=>$value} + {if $value.slash === true } +
+
{$value.nice}
+
{$value.data}
+
+ {elseif $value.data !== 'Yes' && $value.data !== 'No'} +
+
{$value.nice}
+
{$value.data}
+
+ {/if} +{/foreach} +{$stock = $field_values.stock.data} +{$msrp = $field_values.msrp.data} +{$sale = $field_values['sale-price'].data} +{$prod = $member_name} + Contact Sales \ No newline at end of file diff --git a/views/front/fields/OLDlist.html b/views/front/fields/OLDlist.html new file mode 100644 index 0000000..1851b53 --- /dev/null +++ b/views/front/fields/OLDlist.html @@ -0,0 +1,20 @@ +{foreach $field_values as $key=>$value} + {if $value.slash === true} +
+ {else} +
+ {/if} + {if $value.type == 'Home'} +
{$value.nice}
+
{$value.data}
+ {else} +
{$value.nice}
+
{$value.data}
+ {/if} + {if $key === 'red-hot-deal' && $value.data === 'Yes'} +
+ +
+ {/if} +
+{/foreach} diff --git a/views/front/fields/detail.html b/views/front/fields/detail.html deleted file mode 100644 index 25b417d..0000000 --- a/views/front/fields/detail.html +++ /dev/null @@ -1,19 +0,0 @@ -
Specifications
-{foreach $field_values as $key=>$value} - {if $value.slash === true } -
-
{$value.nice}
-
{$value.data}
-
- {elseif $value.data !== 'Yes' && $value.data !== 'No'} -
-
{$value.nice}
-
{$value.data}
-
- {/if} -{/foreach} -{$stock = $field_values.stock.data} -{$msrp = $field_values.msrp.data} -{$sale = $field_values['sale-price'].data} -{$prod = $member_name} - Contact Sales \ No newline at end of file diff --git a/views/front/fields/list.html b/views/front/fields/list.html deleted file mode 100644 index 1851b53..0000000 --- a/views/front/fields/list.html +++ /dev/null @@ -1,20 +0,0 @@ -{foreach $field_values as $key=>$value} - {if $value.slash === true} -
- {else} -
- {/if} - {if $value.type == 'Home'} -
{$value.nice}
-
{$value.data}
- {else} -
{$value.nice}
-
{$value.data}
- {/if} - {if $key === 'red-hot-deal' && $value.data === 'Yes'} -
- -
- {/if} -
-{/foreach}