*/
public $fields = false;
/**
- * MemberInfo DB object
+ * Get Stored Data Flag
*
- * @var $MemberInfo
+ * @var $getStoredData
* @access public
*/
- public $MemberInfo;
-
+ public $getStoredData = false;
+ /**
+ * Data Record ID
+ *
+ * @var $recordId
+ * @access public
+ */
+ public $recordId = false;
+
/**
* Constructor
*
default:
break;
}
+
+ // If get stored data flag is set and we have a stored data record ID
+ if ($this->getStoredData && $this->recordId) {
+
+ // If we don't have it yet, instatiate the custom field data class
+ if (!isset($CustomFieldData)) {
+ require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFieldsData.php';
+ $CustomFieldData = new GlmDataFieldsCustomFieldsData($this->wpdb, $this->config);
+ }
+
+ // Get stored data for the current field
+ $customFieldData = $CustomFieldData->getEntry($r['id'], 'field_id', "T.record_id = ".$this->recordId);
+
+ // Place the save field data into the current result
+ $r = array_merge($r, array(
+ 'text_data' => $customFieldData['text_data'],
+ 'checkbox_data' => $customFieldData['checkbox_data'],
+ 'integer_data' => $customFieldData['integer_data'],
+ 'float_data' => $customFieldData['float_data']
+ ));
+
+ $r['stored'] = '';
+
+ switch ($r['field_type']) {
+
+ case 'text':
+ case 'textarea':
+ $r['stored'] = $customFieldData['text_data'];
+ break;
+
+ case 'checkbox':
+ $r['stored'] = ($customFieldData['checkbox_data'] ? 'Yes' : 'No');
+ break;
+
+ case 'picklist':
+
+ // set default picklist option
+ if (isset($r['options']) && count($options) > 0) {
+ foreach($r['options'] as $optKey=>$optVal) {
+ $val = false;
+ $name = 'No';
+ if ($optVal['option_value'] == $customFieldData['text_data']) {
+ $val = true;
+ $name = 'Yes';
+ }
+ $r['options'][$optKey]['option_default']['value'] = $val;
+ $r['options'][$optKey]['option_default']['name'] = $name;
+ }
+ }
+
+ $r['stored'] = $optVal['stored'] = $csutomFieldData['text_data'];
+
+ break;
+
+ case 'integer':
+ $r['stored'] = $customFieldData['integer_data'];
+ break;
+
+ case 'float':
+ $r['stored'] = $customFieldData['float_data'];
+ break;
+
+ }
+
+
+trigger_error('Stored Data: '.print_r($customFieldData,1), E_USER_NOTICE);
+
+ }
}
return $r;
}
+
+ /*
+ * Get form fields along with any stored data
+ *
+ * @param
+ * @param string $a Action being performed (l, i, g, ...)
+ *
+ * @return object Class object
+ *
+ */
+ public function getFormWithData($fid, $recordId = false)
+ {
+ // Save current status of get stored data flag
+ $savedGetStoredDataState = $this->getStoredData;
+
+ // Set stored data flag and record ID
+ $this->getStoredData = true;
+ $this->recordId = $recordId;
+
+ // Try to get the form
+ $form = $this->getList("fid = '$fid'");
+
+ // Restore saved stored data flag
+ $this->getStoredData = $savedGetStoredDataState;
+
+ return $form;
+
+ }
}
*/
public function modelAction( $actionData = false )
{
-trigger_error('********* WORKING IN formDisplay.php **********',E_USER_NOTICE);
+
$formId = false;
$formFields = false;
$haveForm = false;
$view = 'displayForm.html';
$parentFormId = $actionData['request']['parent-form-id'];
+ $recordId = false;
-trigger_error('Form Display Submit Data '.print_r($actionData,1),E_USER_NOTICE);
if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
trigger_error('Shortcode Called: glm-members-customfields-form-display', E_USER_NOTICE);
}
$formId = filter_var($actionData['request']['fid'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW);
+ // Check for a sane record ID
+ $recordId = ($actionData['request']['record-id'] - 0);
+ if ($recordId <= 0) {
+ $recordId = false;
+ }
+
// Try to retrieve the form
- $formFields = $this->getList("T.fid = '$formId'");
+ $formFields = $this->getFormWithData($formId, $recordId);
+
+ // If we received good data
if ($formFields && count($formFields) > 0) {
+ // Have form fields
$haveForm = true;
// Also add default fieldFail flags
$formFields[$fieldKey]['field_fail'] = '';
}
- // If there's a record ID
- $recordId = ($actionData['request']['record-id'] - 0);
- if ($recordId > 0) {
-trigger_error("fid = '$formId' AND record_id = $recordId",E_USER_NOTICE);
-
- // Try to get any stored data
- $CustomFieldData = new GlmDataFieldsCustomFieldsData($this->wpdb, $this->config);
- $customFieldData = $CustomFieldData->getList("fid = '$formId' AND record_id = $recordId");
-trigger_error('Field Data = '.print_r($customFieldData,1), E_USER_NOTICE);
-
-
- }
-
}
}
-trigger_error('Field Data = '.print_r($formFields,1), E_USER_NOTICE);
// Compile template data
$templateData = array(