From: Anthony Talarico Date: Fri, 20 Oct 2017 18:09:16 +0000 (-0400) Subject: adding where clause to get custom fields by uid, fixing db changes in the update... X-Git-Tag: v1.0.4^2~28 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=d726cb73c4f777e46162dab58594aed99727c251;p=WP-Plugins%2Fglm-member-db-fields.git adding where clause to get custom fields by uid, fixing db changes in the update script setting default uid to custom fields that already exist, changing layout of the admin view for the custom fields to use glm grid instead of tables --- diff --git a/css/admin.css b/css/admin.css new file mode 100644 index 0000000..2614375 --- /dev/null +++ b/css/admin.css @@ -0,0 +1,18 @@ +.glm-admin-custom-fields .glm-columns{ + padding: 0 5px 10px 5px; +} +.glm-admin-custom-fields .glm-custom-field-label{ + font-weight: bold; + line-height: 1; +} + +@media(min-width: 1024px){ + .glm-admin-custom-fields input[type=text]{ + width: 50%; + } +} +@media(max-width: 1024px){ + .glm-admin-custom-fields input[type=text]{ + width: 100%; + } +} diff --git a/models/admin/entity/fields.php b/models/admin/entity/fields.php index 545f19a..5782124 100644 --- a/models/admin/entity/fields.php +++ b/models/admin/entity/fields.php @@ -120,7 +120,9 @@ class GlmMembersAdmin_entity_fields extends GlmDataFieldsCustomFields $customFields = false; $haveCustomFields = false; $customFieldData = false; - + $where = 'true'; + $uid = ''; + if (isset($_REQUEST['option'])) { $option = $_REQUEST['option']; } @@ -130,10 +132,10 @@ class GlmMembersAdmin_entity_fields extends GlmDataFieldsCustomFields if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']-0; } - $memberId = 0; + $memberId = 0; if (isset($actionData)) { - $memberId = $actionData; - print_r($actionData); + $memberId = $actionData['memberId']; + $uid = $actionData['uid']; } switch ($option) { @@ -145,9 +147,10 @@ class GlmMembersAdmin_entity_fields extends GlmDataFieldsCustomFields break; } - + // $where .= " AND field_id in (select id from " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX ."custom_fields where uid = 'glm-member-db')"; + $where .= " AND uid = '$uid'"; // Get list of Custom Fields - $customFields = $this->getList( null, 'field_order,id' ); + $customFields = $this->getList( $where, 'field_order,id' ); if ( isset($customFields) && $customFields && count( $customFields ) > 0 ) { $haveCustomFields = true; } @@ -162,6 +165,7 @@ class GlmMembersAdmin_entity_fields extends GlmDataFieldsCustomFields 'customFieldsData' => $customFieldsData, 'fieldTypes' => $this->config['custom_field_types'], 'haveCustomFields' => $haveCustomFields, + 'uid' => $uid ); // Return status, suggested view, and data to controller diff --git a/setup/adminHooks.php b/setup/adminHooks.php index cccf024..71adb91 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -44,7 +44,8 @@ add_filter( 'glm-members-customfields-edit', function( $content, $uid ){ */ add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id ){ unset( $_REQUEST['glm_action'] ); - $content = $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'memberId' => $id ), true ); + // echo "CONTENT: " . $content . " UID: " . $uid . " ID: " . $id . '
'; + $content = $this->controller( 'entity', 'fields', array( 'uid' => $uid, 'memberId' => $id ), true); return $content; }, 10, 3 ); /** diff --git a/setup/databaseScripts/update_database_V0.0.4.sql b/setup/databaseScripts/update_database_V0.0.4.sql index ce026b4..6ae7b29 100644 --- a/setup/databaseScripts/update_database_V0.0.4.sql +++ b/setup/databaseScripts/update_database_V0.0.4.sql @@ -10,7 +10,7 @@ ALTER TABLE {prefix}custom_fields ADD COLUMN required BOOLEAN DEFAULT '0'; ---- -ALTER TABLE {prefix}custom_fields ADD COLUMN uid TINYTEXT NOT NULL DEFAULT ''; +ALTER TABLE {prefix}custom_fields ADD COLUMN uid TINYTEXT NOT NULL DEFAULT 'glm-member-db'; ---- diff --git a/views/admin/entity/fields.html b/views/admin/entity/fields.html index 72fb72d..7c54bfc 100644 --- a/views/admin/entity/fields.html +++ b/views/admin/entity/fields.html @@ -1,26 +1,24 @@ - +
{foreach $customFields as $field} -
- - - +
{$field.field_name}
+
+ {if $field.field_type.name == 'text'} + + {elseif $field.field_type.name == 'textarea'} + {php} + wp_editor('{if isset($customFieldsData[$field.id])}{$customFieldsData[$field.id]|escape:quotes}{/if}', 'custom-field-{$field.id}', array( + 'media_buttons' => false, + // 'quicktags' => false, + // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. + 'textarea_name' => '{$prefix}[{$field.id}]', + 'editor_height' => 200, // Height in px, overrides editor_rows + // 'textarea_rows' => 8 + )); + {/php} + {elseif $field.field_type.name == 'checkbox'} + + + {/if} +
{/foreach} -
{$field.field_name} - {if $field.field_type.name == 'text'} - - {elseif $field.field_type.name == 'textarea'} - {php} - wp_editor('{if isset($customFieldsData[$field.id])}{$customFieldsData[$field.id]|escape:quotes}{/if}', 'custom-field-{$field.id}', array( - 'media_buttons' => false, - // 'quicktags' => false, - // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. - 'textarea_name' => '{$prefix}[{$field.id}]', - 'editor_height' => 200, // Height in px, overrides editor_rows - // 'textarea_rows' => 8 - )); - {/php} - {elseif $field.field_type.name == 'checkbox'} - - - {/if} -
+