From: Anthony Talarico Date: Thu, 19 Oct 2017 19:18:20 +0000 (-0400) Subject: rolling back database changes, changing the model action names X-Git-Tag: v1.0.4^2~32 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=d91dbb02037b91cd0bbb70d4311eef79d0f498f2;p=WP-Plugins%2Fglm-member-db-fields.git rolling back database changes, changing the model action names changing the fields action to entity, adjusting database table column names and datatypes --- diff --git a/classes/data/dataCustomFields.php b/classes/data/dataCustomFields.php index d6cc38b..f70c2b8 100644 --- a/classes/data/dataCustomFields.php +++ b/classes/data/dataCustomFields.php @@ -139,7 +139,7 @@ class GlmDataFieldsCustomFields extends GlmDataAbstract // group id 'uid' => array ( 'field' => 'uid', - 'type' => 'integer', + 'type' => 'text', 'view_only' => false, 'use' => 'a' ), diff --git a/models/admin/entity/fields.php b/models/admin/entity/fields.php new file mode 100644 index 0000000..545f19a --- /dev/null +++ b/models/admin/entity/fields.php @@ -0,0 +1,179 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release fields.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Management Fields data abstract +require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFields.php'; + +/** + * GlmMembersAdmin_management_fields + * + * PHP version 5 + * + * @category Model + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmMembersAdmin_entity_fields extends GlmDataFieldsCustomFields +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * dbh Postgres database connection + * + * @var mixed + * @access public + */ + public $dbh; + /** + * settings used for the schema and tablenames + * + * @var mixed + * @access public + */ + public $settings = array(); + /** + * categories + * + * @var bool + * @access public + */ + public $categories = array(); + public $oldCatMap = array(); + /** + * fields + * + * @var bool + * @access public + */ + public $fields = array(); + public $image_owner; + + /** + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * '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. + * + * @wpdb object WordPress database object + * + * @return array Array containing status, suggested view, and any data + */ + 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); + + } + + /** + * modelAction + * + * @param bool $actionData + * @access public + * @return void + */ + public function modelAction($actionData = false) + { + $option = false; + $customFields = false; + $haveCustomFields = false; + $customFieldData = false; + + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + // Check if a field ID is supplied + $id = 0; + if (isset($_REQUEST['id'])) { + $id = $_REQUEST['id']-0; + } + $memberId = 0; + if (isset($actionData)) { + $memberId = $actionData; + print_r($actionData); + } + + switch ($option) { + + default: + // Make sure option is set if default + $option = 'list'; + + break; + + } + + // Get list of Custom Fields + $customFields = $this->getList( null, 'field_order,id' ); + if ( isset($customFields) && $customFields && count( $customFields ) > 0 ) { + $haveCustomFields = true; + } + + require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php'; + $customFieldsData = customFieldsGetFields( $memberId ); + + // Compile template data + $template_data = array( + 'prefix' => 'glm_custom_field', + 'customFields' => $customFields, + 'customFieldsData' => $customFieldsData, + 'fieldTypes' => $this->config['custom_field_types'], + 'haveCustomFields' => $haveCustomFields, + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/entity/fields.html', + 'data' => $template_data + ); + + + } + +} diff --git a/models/admin/fields/fields.php b/models/admin/fields/fields.php deleted file mode 100644 index df98639..0000000 --- a/models/admin/fields/fields.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release fields.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -// Load Management Fields data abstract -require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFields.php'; - -/** - * GlmMembersAdmin_management_fields - * - * PHP version 5 - * - * @category Model - * @package GLM Member DB - * @author Chuck Scott - * @license http://www.gaslightmedia.com Gaslightmedia - * @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott - * Exp $ - */ -class GlmMembersAdmin_fields_fields extends GlmDataFieldsCustomFields -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * dbh Postgres database connection - * - * @var mixed - * @access public - */ - public $dbh; - /** - * settings used for the schema and tablenames - * - * @var mixed - * @access public - */ - public $settings = array(); - /** - * categories - * - * @var bool - * @access public - */ - public $categories = array(); - public $oldCatMap = array(); - /** - * fields - * - * @var bool - * @access public - */ - public $fields = array(); - public $image_owner; - - /** - * Constructor - * - * This contructor performs the work for this model. This model returns - * an array containing the following. - * - * 'status' - * - * True if successfull and false if there was a fatal failure. - * - * '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. - * - * @wpdb object WordPress database object - * - * @return array Array containing status, suggested view, and any data - */ - 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); - - } - - /** - * modelAction - * - * @param bool $actionData - * @access public - * @return void - */ - public function modelAction($actionData = false) - { - $option = false; - $customFields = false; - $haveCustomFields = false; - $customFieldData = false; - - if (isset($_REQUEST['option'])) { - $option = $_REQUEST['option']; - } - - // Check if a field ID is supplied - $id = 0; - if (isset($_REQUEST['id'])) { - $id = $_REQUEST['id']-0; - } - $memberId = 0; - if (isset($actionData)) { - $memberId = $actionData-0; - } - - switch ($option) { - - default: - // Make sure option is set if default - $option = 'list'; - - break; - - } - - // Get list of Custom Fields - $customFields = $this->getList( null, 'field_order,id' ); - if ( isset($customFields) && $customFields && count( $customFields ) > 0 ) { - $haveCustomFields = true; - } - - require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/customFieldPluginSupport.php'; - $customFieldsData = customFieldsGetFields( $memberId ); - - // Compile template data - $template_data = array( - 'prefix' => 'glm_custom_field', - 'customFields' => $customFields, - 'customFieldsData' => $customFieldsData, - 'fieldTypes' => $this->config['custom_field_types'], - 'haveCustomFields' => $haveCustomFields, - ); - - // Return status, suggested view, and data to controller - return array( - 'status' => true, - 'menuItemRedirect' => false, - 'modelRedirect' => false, - 'view' => 'admin/fields/fields.html', - 'data' => $template_data - ); - - - } - -} diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 2cd50b8..dda3f48 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -42,9 +42,10 @@ add_filter( 'glm-members-customfields-edit', function( $content, $uid ){ /** * Filter returns the html for the form segment */ -add_filter( 'glm-members-customfields-form', function( $content, $uid, $id ){ +add_filter( 'glm-members-custom-fields-form', function( $content, $uid, $id ){ unset( $_REQUEST['glm_action'] ); - $content = $this->controller( 'fields', 'fields', array( 'uid' => $uid, 'memberId' => $id ), true ); + // $content = $this->controller( 'entity', 'fields', array( 'uid' => false, 'memberId' => false ), true ); + $content = $this->controller( 'entity', 'fields', array('uid'=>$uid, "memberId"=>$id), true ); return $content; }, 10, 3 ); /** diff --git a/setup/databaseScripts/create_database_V0.0.4.sql b/setup/databaseScripts/create_database_V0.0.4.sql index 75a0f58..c98235f 100644 --- a/setup/databaseScripts/create_database_V0.0.4.sql +++ b/setup/databaseScripts/create_database_V0.0.4.sql @@ -20,8 +20,8 @@ CREATE TABLE {prefix}custom_fields ( 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 INT NOT NULL, -- id for the series of custom fields associated with an entity - entity_id INT NOT NULL DEFAULT '0', -- id for the specific field associated with an entity + uid TINYTEXT NOT NULL, -- id for the series of custom fields associated with an entity + entity_id INT NOT NULL DEFAULT 0, -- id for the specific field associated with an entity PRIMARY KEY (id), INDEX(field_name(20)) ); @@ -34,7 +34,7 @@ CREATE TABLE {prefix}custom_field_data ( field_id INT NOT NULL DEFAULT 0, -- Field Id ref_dest INT NOT NULL DEFAULT 0, -- Member Info Id field_data TEXT NOT NULL DEFAULT '', -- Data for the field - entity_id INT NOT NULL, -- id for the specific field associated with an entity + entity_id INT NOT NULL DEFAULT 0, -- id for the specific field associated with an entity PRIMARY KEY (id), INDEX(field_id), INDEX(ref_dest) diff --git a/setup/databaseScripts/update_database_V0.0.4.sql b/setup/databaseScripts/update_database_V0.0.4.sql index 122845d..d32183d 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 INT NOT NULL; +ALTER TABLE {prefix}custom_fields ADD COLUMN uid TINYTEXT NOT NULL DEFAULT ''; ---- @@ -18,4 +18,4 @@ ALTER TABLE {prefix}custom_field_data ADD COLUMN entity_id INT NOT NULL; ---- -ALTER TABLE {prefix}custom_fields ADD COLUMN entity_id INT NOT NULL DEFAULT '0'; +ALTER TABLE {prefix}custom_fields ADD COLUMN entity_id INT NOT NULL DEFAULT 0; diff --git a/setup/validActions.php b/setup/validActions.php index ee086cf..db6208d 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -62,7 +62,7 @@ $glmMembersFieldsAddOnValidActions = array( 'ajax' => array( 'filterSearch' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, ), - 'fields' => array( + 'entity' => array( 'fields' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, ), 'management' => array( diff --git a/views/admin/entity/fields.html b/views/admin/entity/fields.html new file mode 100644 index 0000000..72fb72d --- /dev/null +++ b/views/admin/entity/fields.html @@ -0,0 +1,26 @@ + + {foreach $customFields as $field} + + + + + {/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} +
diff --git a/views/admin/fields/fields.html b/views/admin/fields/fields.html deleted file mode 100644 index 72fb72d..0000000 --- a/views/admin/fields/fields.html +++ /dev/null @@ -1,26 +0,0 @@ - - {foreach $customFields as $field} - - - - - {/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} -