From: Chuck Scott Date: Mon, 7 Dec 2015 01:10:01 +0000 (-0500) Subject: Preliminary Packaging Add-On less Front-End and such X-Git-Tag: v0.0.3^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=ae4f30dfc423687e5deac1f0a7616559f21dd8b8;p=WP-Plugins%2Fglm-member-db-packaging.git Preliminary Packaging Add-On less Front-End and such --- diff --git a/classes/data/dataPackageElements.php b/classes/data/dataPackageElements.php new file mode 100644 index 0000000..f5bccbd --- /dev/null +++ b/classes/data/dataPackageElements.php @@ -0,0 +1,206 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataPackageElements.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataPackageElements class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataPackageElements extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_PACKAGES_PLUGIN_DB_PREFIX . 'package_elements'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Package Pointer + 'package' => array ( + 'field' => 'package', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PACKAGES_PLUGIN_DB_PREFIX . 'packages', + 'p_field' => 'title', + 'p_orderby' => 'title', + 'required' => true, + 'use' => 'a' + ), + + // Title + 'title' => array ( + 'field' => 'title', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Description + 'descr' => array ( + 'field' => 'descr', + 'type' => 'text', + 'use' => 'a' + ), + + // Short Description + 'short_descr' => array ( + 'field' => 'short_descr', + 'type' => 'text', + 'use' => 'a' + ), + + // Image + 'image' => array( + 'field' => 'image', + 'type' => 'image', + 'use' => 'a' + ), + + // Position + 'position' => array( + 'field' => 'position', + 'type' => 'integer', + 'use' => 'a' + ), + + // Reference Type - Insert new record + 'ref_type_insert' => array ( + 'field' => 'ref_type', + 'type' => 'integer', + 'use' => 'i' + ), + + // Reference Type - Output only + 'ref_type' => array ( + 'field' => 'ref_type', + 'type' => 'list', + 'list' => $this->config['ref_type'], + 'use' => 'lged' + ), + + // Reference Target - Insert new record and for recall + 'ref_dest' => array ( + 'field' => 'ref_dest', + 'type' => 'integer', + 'use' => 'ilged' + ), + + // Reference Destination Name + 'ref_dest_name' => array ( + 'field' => 'ref_dest', + 'as' => 'ref_dest_name', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + 'use' => 'lged' + ) + + ); + + } + + +} + +?> \ No newline at end of file diff --git a/classes/data/dataPackages.php b/classes/data/dataPackages.php new file mode 100644 index 0000000..b57b355 --- /dev/null +++ b/classes/data/dataPackages.php @@ -0,0 +1,236 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataPackages.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataPackages class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataPackages extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX . 'packages'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Active flag + 'active' => array ( + 'field' => 'active', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'a' + ), + + // Title + 'title' => array ( + 'field' => 'title', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Description + 'descr' => array ( + 'field' => 'descr', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Short Description + 'short_descr' => array ( + 'field' => 'short_descr', + 'type' => 'text', + 'use' => 'a' + ), + + // Image + 'image' => array( + 'field' => 'image', + 'type' => 'image', + 'use' => 'a' + ), + + // Start Date + 'start_date' => array ( + 'field' => 'start_date', + 'type' => 'date', + 'use' => 'a' + ), + + // End Date + 'end_date' => array ( + 'field' => 'end_date', + 'type' => 'date', + 'use' => 'a' + ), + + // Expire Date + 'expire_date' => array ( + 'field' => 'expire_date', + 'type' => 'date', + 'use' => 'a' + ), + + // Position + 'position' => array( + 'field' => 'position', + 'type' => 'integer', + 'default' => 0, + 'use' => 'a' + ), + + // Pricing - Descriptive + 'pricing' => array ( + 'field' => 'pricing', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + + // Reference Type - Insert new record + 'ref_type_insert' => array ( + 'field' => 'ref_type', + 'type' => 'integer', + 'default' => 0, + 'use' => 'i' + ), + + // Reference Type - Output only + 'ref_type' => array ( + 'field' => 'ref_type', + 'type' => 'list', + 'list' => $this->config['ref_type'], + 'use' => 'lged' + ), + + // Reference Target - Insert new record and for recall + 'ref_dest' => array ( + 'field' => 'ref_dest', + 'type' => 'integer', + 'default' => 0, + 'use' => 'ilged' + ), + + // Reference Destination Name + 'ref_dest_name' => array ( + 'field' => 'ref_dest', + 'as' => 'ref_dest_name', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + 'required' => true, + 'use' => 'lged' + ) + + ); + + } + +} + +?> \ No newline at end of file diff --git a/defines.php b/defines.php index f6ee60e..02a2c76 100644 --- a/defines.php +++ b/defines.php @@ -11,6 +11,11 @@ define('GLM_MEMBERS_PACKAGING_PLUGIN_NAME', 'Gaslight Media Members Database Pac define('GLM_MEMBERS_PACKAGING_PLUGIN_SHORT_NAME', 'Packaging'); define('GLM_MEMBERS_PACKAGING_PLUGIN_SLUG', 'glm-member-db-packaging'); +// Database table prefixes - change if using add-on tables +global $wpdb; +define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_membersPackaging_'); +define('GLM_MEMBERS_PACKAGING_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersPackagingDbVersion'); + // Determine which system we're running on - If not provided, assume PRODUCTION $host = getenv('GLM_HOST_ID'); if (trim($host) == '') { @@ -41,15 +46,10 @@ define('GLM_MEMBERS_PACKAGING_PLUGIN_MEDIA_URL', $WPUploadDir['baseurl'].'/'.GLM // Directories define('GLM_MEMBERS_PACKAGING_PLUGIN_PATH', dirname(__FILE__)); -define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS', dirname(__FILE__).'/misc/databaseScripts'); +define('GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/setup'); +define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS', GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH.'/databaseScripts'); define('GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/classes'); define('GLM_MEMBERS_PACKAGING_PLUGIN_CONFIG_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/config'); -define('GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/setup'); - -// Database table prefixes -global $wpdb; -define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_'); - // Parameters related to the Main GLM Member DB plugin - Depending on what's going on these may already defined by the main plugin $pluginsPath = str_replace(GLM_MEMBERS_PACKAGING_PLUGIN_SLUG, '', GLM_MEMBERS_PACKAGING_PLUGIN_PATH); diff --git a/glm-member-db-packaging.php b/glm-member-db-packaging.php index 15d695a..fab4f5e 100644 --- a/glm-member-db-packaging.php +++ b/glm-member-db-packaging.php @@ -34,6 +34,7 @@ * version nunmber of that release for the DB version. */ define('GLM_MEMBERS_PACKAGING_PLUGIN_VERSION', '0.0.2'); +define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION', '0.0.2'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.43'); @@ -124,6 +125,7 @@ if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_PACKAGING_PLUG * Register this add-on with the main GLM Member DB plugin and get information on all add-ons loaded. */ require_once(GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH.'/validActions.php'); +require_once(GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS.'/dbVersions.php'); function glmMembersRegisterPackaging($addOns) { // Add this add-on to the add-ons array @@ -132,7 +134,14 @@ function glmMembersRegisterPackaging($addOns) { 'name' => GLM_MEMBERS_PACKAGING_PLUGIN_NAME, 'short_name' => GLM_MEMBERS_PACKAGING_PLUGIN_SHORT_NAME, 'slug' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG, - 'actions' => $GLOBALS['glmMembersAddOnValidActions'] + 'actions' => $GLOBALS['glmMembersPackagingAddOnValidActions'], + 'database' => array( + 'dbPrefix' => GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX, + 'dbCurrentVersion' => GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION, + 'dbActiveVersionOption' => GLM_MEMBERS_PACKAGING_PLUGIN_ACTIVE_DB_OPTION, + 'dbScriptPath' => GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS, + 'dbVersions' => $GLOBALS['glmMembersPackagingDbVersions'] + ) ); // Return the array with our data added diff --git a/models/admin/member/packaging.php b/models/admin/member/packaging.php new file mode 100644 index 0000000..8c4743a --- /dev/null +++ b/models/admin/member/packaging.php @@ -0,0 +1,280 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release packaging.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Member Types data abstract +require_once(GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH.'/data/dataPackages.php'); + +/** + * GlmMembersAdmin_members_packaging Package + * + * 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_member_packaging extends GlmDataPackages +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + + /* + * 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); + + } + + public function modelAction($actionData = false) + { + + $success = true; + $havePackages = false; + $packages = false; + $havePackage = false; + $packageUpdated = false; + $packageInfo = false; + $packageError = false; + $option = false; + $error = false; + + // If there's an action option + $option = 'list'; + if (isset($_REQUEST['option'])) { + $option = trim($_REQUEST['option']); + } + + // Get any package ID + $packageID = 0; + if (isset($_REQUEST['packageID']) && ($_REQUEST['packageID']-0) > 0) { + $packageID = $_REQUEST['packageID'] - 0; + } + + // Get the current Member ID + $memberID = 0; + if (isset($_REQUEST['member']) && ($_REQUEST['member']-0) > 0) { + $memberID = $_REQUEST['member'] - 0; + } + + if ($memberID == 0) { + + // There should have been a member ID - So failure + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + switch($option) { + + case 'add': + + // Geenerate new entry + $packageInfo = $this->newEntry(); + + break; + + case 'insert': + + // Try to insert the new entry + $packageInfo = $this->insertEntry(); + + // If the package inserted successfully + if ($packageInfo && $packageInfo['status']) { + + // Get the new package ID + $packageID = $packageInfo['fieldData']['id']; + + // Get the package data again prepared for editing + $packageInfo = $this->editEntry($packageID); + + // Say what we have + $havePackage = true; + $packageUpdated = true; + + // Tell the template we're going to be editing. + $option = 'edit'; + + // Otherwise, the package didn't successfully submit + } else { + + // Tell the template there were errors and let them try again + $packageError = true; + + } + break; + + case 'edit': + + // Get the package prepared for editing + $packageInfo = $this->editEntry($packageID); + + // If we have good package data, tell the template + if ($packageInfo) { + $havePackage = true; + } + + break; + + case 'update': + + // Try to update the package with the submitted data + $packageInfo = $this->updateEntry($packageID); + + // If it updated successfully + if ($packageInfo && $packageInfo['status']) { + + // Get the package data again prepared for editing + $packages = $this->editEntry($packageID); + + // Tell the template the package was updated + $packageUpdated = true; + + // Otherwise it didn't update, tell the template and let them try again + } else { + $packageError = true; + } + + // Tell the template we have a package and we're editing it + $havePackage = true; + $option = 'edit'; + + break; + + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); + } + break; + + case 'list': + default: + + // Get the list of packages + $packages = $this->getList("T.ref_type = ".$this->config['ref_type_numb']['Member']." AND T.ref_dest = ".$memberID); + + // If we have some, tell the template + if ($packages && count($packages) > 0) { + $havePackages = true; + } + + // Set the option to list in case we got here by default + $option = 'list'; + + break; + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($packages, 'DataBlock', 'Package Data'); + } + + // If we have list entries - even if it's an empty list + $success = true; + $havePackages = false; + if ($packages !== false) { + + $success = true; + + // If we have any entries + if (count($packages) > 0) { + $havePackages = true; + } + } + + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'option' => $option, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); + } + + // Compile template data + $templateData = array( + 'havePackages' => $havePackages, + 'packages' => $packages, + 'havePackage' => $havePackage, + 'packageUpdated' => $packageUpdated, + 'packageID' => $packageID, + 'packageInfo' => $packageInfo, + 'packageError' => $packageError, + 'memberID' => $memberID, + 'option' => $option + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/member/packaging.html', + 'data' => $templateData + ); + + } +} + +?> \ No newline at end of file diff --git a/models/admin/members/packaging.php b/models/admin/members/packaging.php new file mode 100644 index 0000000..4809410 --- /dev/null +++ b/models/admin/members/packaging.php @@ -0,0 +1,275 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release packaging.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Member Types data abstract +require_once(GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH.'/data/dataPackages.php'); + +/** + * GlmMembersAdmin_members_packaging Package + * + * 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_members_packaging extends GlmDataPackages +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + + /* + * 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); + + } + + public function modelAction($actionData = false) + { + + $success = true; + $havePackages = false; + $packages = false; + $havePackage = false; + $packageUpdated = false; + $packageInfo = false; + $packageError = false; + $membersList = false; + $havePackageMembers = false; + $packageMembers = false; + $option = false; + $error = false; + + // If there's an action option + $option = 'list'; + if (isset($_REQUEST['option'])) { + $option = trim($_REQUEST['option']); + } + + // Get any package ID + $packageID = 0; + if (isset($_REQUEST['packageID']) && ($_REQUEST['packageID']-0) > 0) { + $packageID = $_REQUEST['packageID'] - 0; + } + + if ($option == 'add' || $option == 'edit') { + // Get simple member list + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'); + $Members = new GlmDataMembers($this->wpdb, $this->config); + $membersList = $Members->getSimpleMembersList(); + } + + switch($option) { + + case 'add': + + // Geenerate new entry + $packageInfo = $this->newEntry(); + + break; + + case 'insert': + + // Try to insert the new entry + $packageInfo = $this->insertEntry(); + + // If the package inserted successfully + if ($packageInfo && $packageInfo['status']) { + + // Get the new package ID + $packageID = $packageInfo['fieldData']['id']; + + // Get the package data again prepared for editing + $packageInfo = $this->editEntry($packageID); + + // Say what we have + $havePackage = true; + $packageUpdated = true; + + // Tell the template we're going to be editing. + $option = 'edit'; + + // Otherwise, the package didn't successfully submit + } else { + + // Tell the template there were errors and let them try again + $option = 'add'; + $packageError = true; + + } + break; + + case 'edit': + + // Get the package prepared for editing + $packageInfo = $this->editEntry($packageID); + + // If we have good package data, tell the template + if ($packageInfo) { + $havePackage = true; + } + + break; + + case 'update': + + // Try to update the package with the submitted data + $packageInfo = $this->updateEntry($packageID); + + // If it updated successfully + if ($packageInfo && $packageInfo['status']) { + + // Get the package data again prepared for editing + $packages = $this->editEntry($packageID); + + // Tell the template the package was updated + $packageUpdated = true; + + // Otherwise it didn't update, tell the template and let them try again + } else { + $packageError = true; + } + + // Tell the template we have a package and we're editing it + $havePackage = true; + $option = 'edit'; + + break; + + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); + } + break; + + case 'list': + default: + + // Get the list of packages + $packages = $this->getList("T.ref_type = 0"); + + // If we have some, tell the template + if ($packages && count($packages) > 0) { + $havePackages = true; + } + + // Set the option to list in case we got here by default + $option = 'list'; + + break; + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($packages, 'DataBlock', 'Package Data'); + } + + // If we have list entries - even if it's an empty list + $success = true; + $havePackages = false; + if ($packages !== false) { + + $success = true; + + // If we have any entries + if (count($packages) > 0) { + $havePackages = true; + } + } + + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'option' => $option, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); + } + + // Compile template data + $templateData = array( + 'havePackages' => $havePackages, + 'packages' => $packages, + 'havePackage' => $havePackage, + 'packageUpdated' => $packageUpdated, + 'packageID' => $packageID, + 'packageInfo' => $packageInfo, + 'packageError' => $packageError, + 'havePackageMembers' => $havePackageMembers, + 'packageMembers' => $packageMembers, + 'membersList' => $membersList, + 'option' => $option + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/members/packaging.html', + 'data' => $templateData + ); + + } +} + +?> \ No newline at end of file diff --git a/models/admin/sample/index.php b/models/admin/sample/index.php deleted file mode 100644 index 4a64cd6..0000000 --- a/models/admin/sample/index.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -/* - * This model is called when the "Shortcodes" menu is selected - * - */ -class GlmMembersAdmin_sample_index -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - - /* - * 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; - - } - - public function modelAction($actionData = false) { - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'admin/sample/index.html', - 'data' => false - ); - - } -} - -?> \ No newline at end of file diff --git a/setup/adminTabs.php b/setup/adminTabs.php index a420b34..b0f6c3d 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -14,7 +14,7 @@ */ /* - * To add a new tab to an existing Member DB page use a blick + * To add a new tab to an existing Member DB page use a block * like this and replace the {} parameters. * * add_filter('glm-member-db-add-tab-for-{menu name}', @@ -33,4 +33,33 @@ * */ +add_filter('glm-member-db-add-tab-for-members', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Packaging', + 'menu' => 'members', + 'action' => 'packaging' + ) + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } +); + +add_filter('glm-member-db-add-tab-for-member', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Packaging', + 'menu' => 'member', + 'action' => 'packaging' + ) + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } +); + + ?> \ No newline at end of file diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql new file mode 100644 index 0000000..fa080fb --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.2.sql @@ -0,0 +1,51 @@ +-- Gaslight Media Members Database - Packaging +-- File Created: 12/02/15 15:27:15 +-- Database Version: 0.0.2 +-- Database Creation Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Packages +CREATE TABLE {prefix}packages ( + id INT NOT NULL AUTO_INCREMENT, + active BOOLEAN NULL, -- Package is active + title TINYTEXT NULL, -- Title of package + descr TEXT NULL, -- Description of package + short_descr TINYTEXT NULL, -- Short description of package + image TINYTEXT NULL, -- Package image + start_date TIMESTAMP NULL, -- Date display of this package starts + end_date TIMESTAMP NULL, -- Date display of this package ends (last date of display) + expire_date TIMESTAMP NULL, -- Date package expires (first date it's expired) + position INT NULL, -- Display order position + pricing TINYTEXT NULL, -- Pricing, descriptive + ref_type INT NULL, -- Type of entity this package is associated with + ref_dest INT NULL, -- Pointer to the specific entity + PRIMARY KEY (id), + INDEX(ref_type), + INDEX(ref_dest), + INDEX(start_date), + INDEX(end_date), + INDEX(expire_date) +); + +---- + +-- Package Elements - Items in a package +CREATE TABLE {prefix}package_elements ( + id INT NOT NULL AUTO_INCREMENT, + package INT NULL, -- Pointer to the package + active BOOLEAN NULL, -- Package is active + title TINYTEXT NULL, -- Title of element + descr TEXT NULL, -- Description for this entity's participation in the package + short_descr TEXT NULL, -- Short description for this entity's participation in the package + image TINYTEXT NULL, -- Element image + position INT NULL, -- Display order position + ref_type INT NULL, -- Type of entity this element is association with + ref_dest INT NULL, -- Pointer to the specific entity + PRIMARY KEY (id), + INDEX(package), + INDEX(ref_type), + INDEX(ref_dest) +); + diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php new file mode 100644 index 0000000..5451371 --- /dev/null +++ b/setup/databaseScripts/dbVersions.php @@ -0,0 +1,19 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +$glmMembersPackagingDbVersions = array( + '0.0.2' => array('version' => '0.0.2', 'tables' => 2) +); + diff --git a/setup/validActions.php b/setup/validActions.php index a766289..ba1e4d4 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -30,10 +30,13 @@ * DB plugin when this plugin registers itself. */ -$glmMembersAddOnValidActions = array( +$glmMembersPackagingAddOnValidActions = array( 'adminActions' => array( - 'sample' => array( - 'index' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG + 'members' => array( + 'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG + ), + 'member' => array( + 'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG ) ), 'frontActions' => array( diff --git a/views/admin/member/packaging.html b/views/admin/member/packaging.html new file mode 100644 index 0000000..611230d --- /dev/null +++ b/views/admin/member/packaging.html @@ -0,0 +1,184 @@ +{include file='admin/member/header.html'} + + {if $packageUpdated}

Package Updated

{/if} + {if $packageError}

Error submitting package, see below...

{/if} + +{if $option == 'edit' || $option == 'add'} + + {if $option == 'edit'} +

Edit Package

+ {else} +

Add new Package

+ {/if} + + +
+ + + + + {if $havePackage} + + + {else} + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Active: + +
Title: + + {if $packageInfo.fieldFail.title}

{$packageInfo.fieldFail.title}

{/if} +
Description: + {php} + wp_editor('{$packageInfo.fieldData.descr|escape:quotes}', 'glm_descr', array( + // 'media_buttons' => true, + // 'quicktags' => false, + // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. + 'textarea_name' => 'descr', + 'editor_height' => 200, // Height in px, overrides editor_rows + // 'textarea_rows' => 8 + )); + {/php} + {if $packageInfo.fieldFail.descr}

{$packageInfo.fieldFail.descr}

{/if} +
Short Description: + + {if $packageInfo.fieldFail.short_descr}

{$packageInfo.fieldFail.short_descr}

{/if} +
Logo: + + {if $packageInfo.fieldData.image} + + + + + {/if} + +
+
+ +
+
+ Delete Image
+ {$packageInfo.fieldData.image}
+
New image:
+ + {if $packageInfo.fieldFail.image}

{$packageInfo.fieldFail.image}

{/if} +
Start Date: + + {if $packageInfo.fieldFail.start_date}

{$packageInfo.fieldFail.start_date}

{/if} +
End Date: + + {if $packageInfo.fieldFail.end_date}

{$packageInfo.fieldFail.end_date}

{/if} +
Expire Date: + + {if $packageInfo.fieldFail.expire_date}

{$packageInfo.fieldFail.expire_date}

{/if} +
Pricing Description: + + {if $packageInfo.fieldFail.pricing}

{$packageInfo.fieldFail.pricing}

{/if} +
Display Order: + + {if $packageInfo.fieldFail.position}

{$packageInfo.fieldFail.position}

{/if} +
+ +
+ +{else} + +
Add a Package
+

Multi-Member Packages

+ + + + + + + + + + + + {if $havePackages} + {foreach $packages as $p} + + + + + + + {/foreach} + {else} + + {/if} + +
PackageStartEndExpire
+ {$p.title} + + {$p.start_date.date} + + {$p.end_date.date} + + {$p.expire_date.date} +
(no packages listed)
+ +{/if} + + + +{include file='admin/footer.html'} diff --git a/views/admin/members/packaging.html b/views/admin/members/packaging.html new file mode 100644 index 0000000..23d1992 --- /dev/null +++ b/views/admin/members/packaging.html @@ -0,0 +1,280 @@ +{include file='admin/members/header.html'} + + {if $packageUpdated}

Package Updated

{/if} + {if $packageError}

Error submitting package, see below...

{/if} + +{if $option == 'edit' || $option == 'add'} + + {if $option == 'edit'} +

Edit Multi-Member Package

+ {else} +

Add new Multi-Member Package

+ {/if} + + +
+ + + + {if $havePackage} + + + {else} + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Active: + +
Title: + + {if $packageInfo.fieldFail.title}

{$packageInfo.fieldFail.title}

{/if} +
Description: + {php} + wp_editor('{$packageInfo.fieldData.descr|escape:quotes}', 'glm_descr', array( + // 'media_buttons' => true, + // 'quicktags' => false, + // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. + 'textarea_name' => 'descr', + 'editor_height' => 200, // Height in px, overrides editor_rows + // 'textarea_rows' => 8 + )); + {/php} + {if $packageInfo.fieldFail.descr}

{$packageInfo.fieldFail.descr}

{/if} +
Short Description: + + {if $packageInfo.fieldFail.short_descr}

{$packageInfo.fieldFail.short_descr}

{/if} +
Logo: + + {if $packageInfo.fieldData.image} + + + + + {/if} + +
+
+ +
+
+ Delete Image
+ {$packageInfo.fieldData.image}
+
New image:
+ + {if $packageInfo.fieldFail.image}

{$packageInfo.fieldFail.image}

{/if} +
Start Date: + + {if $packageInfo.fieldFail.start_date}

{$packageInfo.fieldFail.start_date}

{/if} +
End Date: + + {if $packageInfo.fieldFail.end_date}

{$packageInfo.fieldFail.end_date}

{/if} +
Expire Date: + + {if $packageInfo.fieldFail.expire_date}

{$packageInfo.fieldFail.expire_date}

{/if} +
Pricing Description: + + {if $packageInfo.fieldFail.pricing}

{$packageInfo.fieldFail.pricing}

{/if} +
Display Order: + + {if $packageInfo.fieldFail.position}

{$packageInfo.fieldFail.position}

{/if} +
Participating Members + + + Search to add a member:
+ + + + + +
+
  • + + + + + + + + + +
    Package Member:{ memberName }
    Active:
    Package Element Title:
    Description:
    Short Description:
    Image:
    +
  • +
    + +
    +
      + {if $havePackageMembers} + + {foreach $packageMembers as $i} +
    • + + +
      + + + + + + + + +
      Package Member:{$i.memberName}
      Active:
      Package Element Title:
      Description:
      Short Description:
      Image:
      +
      +
    • + {/foreach} + {else} +
    • No members have been added to this package yet.
      Please select a member above.
    • + {/if} +
    +
    +
    + +
    + +{else} + +
    Add a Package
    +

    Multi-Member Packages

    + + + + + + + + + + + + {if $havePackages} + {foreach $packages as $p} + + + + + + + {/foreach} + {else} + + {/if} + +
    PackageStartEndExpire
    + {$p.title} + + {$p.start_date.date} + + {$p.end_date.date} + + {$p.expire_date.date} +
    (no packages listed)
    + +{/if} + + + +{include file='admin/footer.html'} diff --git a/views/admin/sample/header.html b/views/admin/sample/header.html deleted file mode 100644 index f9fdb91..0000000 --- a/views/admin/sample/header.html +++ /dev/null @@ -1,5 +0,0 @@ -
    - -

    {$glmPluginName}

    - - \ No newline at end of file diff --git a/views/admin/sample/index.html b/views/admin/sample/index.html deleted file mode 100644 index 6159f5d..0000000 --- a/views/admin/sample/index.html +++ /dev/null @@ -1,7 +0,0 @@ -{include file='admin/sample/header.html'} - -

    A Sample Add-On Menu

    - - This is a test - -{include file='admin/footer.html'}