From: Anthony Talarico Date: Tue, 6 Mar 2018 21:44:45 +0000 (-0500) Subject: adding settings tab for asset types X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=8d659915587b7d5c0cd67e937ec3ce5fbd4464b1;p=WP-Plugins%2Fglm-member-db-assets.git adding settings tab for asset types fixing data class field name bug and adding the setting tab in the admin, roughed in, for the asset types, still need to style and structure the input fields in the pop up modal --- diff --git a/classes/data/dataAssetTypes.php b/classes/data/dataAssetTypes.php index 1d253b3..54b6ce5 100644 --- a/classes/data/dataAssetTypes.php +++ b/classes/data/dataAssetTypes.php @@ -133,7 +133,7 @@ class GlmDataAssetsAssetTypes extends GlmDataAbstract // Use Type 'use_type' => array ( - 'field' => 'state', + 'field' => 'use_type', 'type' => 'list', 'list' => $this->config['use_type'], 'force_list' => true, diff --git a/models/admin/settings/assetTypes.php b/models/admin/settings/assetTypes.php new file mode 100644 index 0000000..ab3f565 --- /dev/null +++ b/models/admin/settings/assetTypes.php @@ -0,0 +1,146 @@ + + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Asset Types data abstract +require_once GLM_MEMBERS_ASSETS_PLUGIN_CLASS_PATH.'/data/dataAssetTypes.php'; + +class GlmMembersAdmin_settings_assetTypes extends GlmDataAssetsAssetTypes +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Obit ID + * + * @var $assetTypetID + * @access public + */ + public $obitID = false; + + /** + * 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 the Asset Type data class + * + * Note, the third parameter is a flag that indicates to the Contacts + * data class that it should flag a group of fields as 'view_only'. + */ + parent::__construct(false, false, true); + + } + + public function modelAction($actionData = false) + { + + + // Check if an ID is supplied + $id = 0; + if ( isset( $_REQUEST['id'] ) ) { + $id = $_REQUEST['id'] - 0; + } + // If there's an action option + if ( isset( $_REQUEST['option'] ) ) { + switch( $_REQUEST['option'] ) { + + case 'addNew': + $return = $this->insertEntry(); +// $id = $return['fieldData']['id']; + echo '
', print_r($return), '
'; + break; + + case 'update': + if ( $id > 0 ) { + $this->updateEntry( $id ); + } + break; + + case 'delete': + if ( $id > 0 ) { + $this->deleteEntry( $id, true ); + } + break; + + default: + $option2 = false; + break; + + } + } + + // Get number of obits + + $assetTypes = $this->getList(); + + // Compile template data + $templateData = array( + 'assetTypes' => $assetTypes, + ); + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/settings/assetTypes.html', + 'data' => $templateData + ); + + } + + +} diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 26be7b2..68ff62f 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -32,4 +32,23 @@ * ); * */ +if (current_user_can('glm_members_members')) { + if (apply_filters('glm_members_permit_admin_members_assetTypes_tab', true)) { + + add_filter('glm-member-db-add-tab-for-settings', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Asset Types', + 'menu' => 'settings', + 'action' => 'assetTypes' + ), + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } + ); + + } +} diff --git a/setup/validActions.php b/setup/validActions.php index d473d8e..cecc3c9 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -61,7 +61,10 @@ $glmMembersAssetsAddOnValidActions = array( 'adminActions' => array( 'assets' => array( 'index' => GLM_MEMBERS_ASSETS_PLUGIN_SLUG - ) + ), + 'settings' => array( + 'assetTypes' => GLM_MEMBERS_ASSETS_PLUGIN_SLUG, + ), ), 'frontActions' => array( ) diff --git a/views/admin/settings/assetTypes.html b/views/admin/settings/assetTypes.html new file mode 100644 index 0000000..6950061 --- /dev/null +++ b/views/admin/settings/assetTypes.html @@ -0,0 +1,181 @@ +{include file='admin/management/header.html'} + + + + +
+ +
Add Asset Type
+
+
+ + + + + + + + + +
Asset Type Name: + + + + + + + + +
+

* Required

+ Cancel + + +
+
+ + +
+
+

Are you sure you want to delete this Asset Type?

+

Yes, delete this AssetType

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + + +
AssetType Name: + + + + + + + + +
+

* Required

+ Cancel + + +
+
+ + + + + + + + + + {$assetTypes|@print_r} + {if $assetTypes} + + {assign var="i" value="0"} + {foreach $assetTypes as $n} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + {/foreach} + {else} + + {/if} + +
AssetType Name  
+
{$n.name}
+
Edit
+
Delete
+
(no asset types listed)
+
+ + +