From: Anthony Talarico Date: Wed, 18 Oct 2017 18:55:52 +0000 (-0400) Subject: changing the member info actions to a generic fields action X-Git-Tag: v1.0.4^2~38 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=1f17ffb747e202c2d42cb45bad0ca8b0698bdd20;p=WP-Plugins%2Fglm-member-db-fields.git changing the member info actions to a generic fields action using fields for actions instead of member_info and changing the model view structure --- diff --git a/models/admin/fields/fields.php b/models/admin/fields/fields.php new file mode 100644 index 0000000..b815863 --- /dev/null +++ b/models/admin/fields/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_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 = customFieldsGetMemberInfoFields( $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/models/admin/memberinfo/fields.php b/models/admin/memberinfo/fields.php deleted file mode 100644 index 372cc4b..0000000 --- a/models/admin/memberinfo/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_memberinfo_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 = customFieldsGetMemberInfoFields( $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/memberinfo/fields.html', - 'data' => $template_data - ); - - - } - -} diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 1b83e06..7423add 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -44,7 +44,7 @@ add_filter( 'glm-members-customfields-edit', function( $content, $uid ){ */ add_filter( 'glm-members-customfields-form', function( $content, $uid, $id ){ unset( $_REQUEST['glm_action'] ); - $content = $this->controller( 'memberinfo', 'fields', array( 'uid' => $uid, 'memberId' => $id ), true ); + $content = $this->controller( 'fields', 'fields', array( 'uid' => $uid, 'memberId' => $id ), true ); return $content; }, 10, 3 ); /** @@ -68,7 +68,7 @@ add_filter( 'glm-member-db-member-info-custom-nav', function( $content ){ add_filter( 'glm-member-db-member-info-custom-tab', function( $content, $memberId = '' ){ unset( $_REQUEST['glm_action'] ); - $content = $this->controller( 'memberinfo', 'fields', $memberId ); + $content = $this->controller( 'fields', 'fields', $memberId ); return $content; },1,2); add_filter( 'glm-member-db-custom-filter-search', function ( $content ) { diff --git a/setup/validActions.php b/setup/validActions.php index 3c2be84..ee086cf 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -59,9 +59,6 @@ $glmMembersFieldsAddOnValidActions = array( 'adminActions' => array( - 'memberinfo' => array( - 'fields' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, - ), 'ajax' => array( 'filterSearch' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, ), diff --git a/views/admin/fields/fields.html b/views/admin/fields/fields.html new file mode 100644 index 0000000..11e2cc9 --- /dev/null +++ b/views/admin/fields/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/memberinfo/fields.html b/views/admin/memberinfo/fields.html deleted file mode 100644 index 11e2cc9..0000000 --- a/views/admin/memberinfo/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} -