*/
public function modelAction($actionData = false)
{
+ $glm_action = '';
$option = false;
$settings_updated = false;
$settings_update_error = false;
$custom_fields = false;
$haveCustomFields = false;
+ $where = ' TRUE ';
if (isset($_REQUEST['option2'])) {
$option = $_REQUEST['option2'];
}
+ if (isset($_GET['glm_action'])) {
+ $glm_action = $_GET['glm_action'];
+ }
+
// Check if a field ID is supplied
$id = 0;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id']-0;
}
+
$uid = 0;
if (isset($actionData['uid'])) {
}
+ $where .= " AND uid = '$uid' ";
+
// Get list of Custom Fields
- $custom_fields = $this->getList();
- // echo "<pre>" . print_r($custom_fields, true) . "</pre>";
+ $custom_fields = $this->getList( $where );
+ // echo "<pre>REQUEST " . print_r($_REQUEST, true) . "</pre>";
+ // echo "<pre>GET " . print_r($_GET, true) . "</pre>";
if ( isset($custom_fields) && $custom_fields && count( $custom_fields ) > 0 ) {
$haveCustomFields = true;
}
// Compile template data
$template_data = array(
- 'option2' => $option,
+ 'option2' => $option,
'settingsUpdated' => $settings_updated,
'settingsUpdateError' => $settings_update_error,
'custom_fields' => $custom_fields,
'field_types' => $this->config['custom_field_types'],
'haveCustomFields' => $haveCustomFields,
- 'uid' => $uid
+ 'uid' => $uid,
+ 'glm_action' => $glm_action
);
+ // echo "<pre>Template data:" . print_r($template_data, true) . "</pre>";
// Return status, suggested view, and data to controller
return array(
return true;
}, 10, 1 );
/**
- * Filter returns html from the management -> fields model.
+ * Filter returns html from the management -> fields model.
*/
add_filter( 'glm-members-customfields-edit', function( $content, $uid ){
unset( $_REQUEST['glm_action'] );
}
return $queryParts;
});
-add_filter('glm-member-db-save-custom-fields', function( $entityID ) {
+add_filter('glm-member-db-save-custom-fields', function( $entityID, $uid ) {
require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php';
// this will save the member data
//echo "uid = $uid";
- customFieldsSaveFields( $entityID );
+ customFieldsSaveFields( $entityID, $uid );
return true;
},
10,
<!-- Add Custom Field Button and Dialog Box -->
<div id="newFieldButton" class="button button-primary glm-right">Add a Custom Field</div>
<div id="newFieldDialog" class="glm-dialog-box" title="Enter a New Custom Field">
- <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
- <input type="hidden" name="glm_action" value="import">
+ <form action="{$thisUrl}?page={$thisPage}&glm_action={$glm_action}&option=customfields" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="{$glm_action}">
<input type="hidden" name="option" value="customfields">
<input type="hidden" name="option2" value="addNew">
<!-- Edit Field Dialog Box -->
<div id="editFieldDialog" class="glm-dialog-box" title="Edit this Field">
- <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
- <input type="hidden" name="glm_action" value="import">
+ <form action="{$thisUrl}?page={$thisPage}&glm_action={$glm_action}&option=customfields" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="{$glm_action}">
<input type="hidden" name="option" value="customfields">
<input type="hidden" name="option2" value="update">
<input id="editFieldID" type="hidden" name="id" value="">
(text or checkbox only)
</td>
</tr>
- <tr>
- <th>Required?</th>
- <td>
- <input type="hidden" name="required" value="0" />
- <input type="checkbox" id="editRequired" name="required" value="1" />
- </td>
- </tr>
+ <input type="hidden" name="uid" value="{$uid}">
</table>
<p><span class="glm-required">*</span> Required</p>
<a id="editFieldCancel" class="button button-primary glm-right">Cancel</a>
<td>{$t.id}</td>
<td>
<div>
- <a class="editField" data-fieldID="{$t.id}" data-fieldType="{$t.field_type.name|escape:'html'}" data-adminSearch="{$t.admin_search.value}" data-required="{$t.required.value}">{$t.field_name}</a>
+ <a class="editField" data-fieldID="{$t.id}" data-fieldType="{$t.field_type.name|escape:'html'}" data-adminSearch="{$t.admin_search.value}">{$t.field_name}</a>
</div>
</td>
<td id="editFieldType_{$t.id}">
var fieldName = $(this).text();
var fieldType = $(this).attr('data-fieldType');
var adminSearch = $(this).attr('data-adminSearch');
- var required = $(this).attr('data-required');
-
$('#editFieldID').val(fieldID);
$('#editFieldName').val(fieldName.trim());
$('#editFieldType').val(fieldType);
-
+ console.log(adminSearch);
if (adminSearch === '1') {
console.log('setting the checked to true');
$('#editAdminSearch').prop('checked', true);
console.log('setting the checked to false');
$('#editAdminSearch').prop('checked', false);
}
- // check required fields
- if (required === '1') {
- $('#editRequired').prop('checked', true);
- } else {
- console.log('setting the checked to false');
- $('#editRequired').prop('checked', false);
- }
$("#editFieldDialog").dialog("open");
});
$('#editFieldCancel').click( function() {
});
$('#deleteFieldConfirm').click( function() {
$("#deleteFieldDialog").dialog("close");
- window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=import&option=customfields&option2=delete&id=" + id;
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action={$glm_action}&option=customfields&option2=delete&id=" + id;
});
$('#deleteFieldCancel').click( function() {
$("#deleteFieldDialog").dialog("close");