From: Chuck Scott Date: Wed, 20 Apr 2016 21:16:32 +0000 (-0400) Subject: Events nearly ready, menu restructure X-Git-Tag: v1.1.3^2~19 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=50e3325bb6847fe033fad97f1318df8a0a912fd8;p=WP-Plugins%2Fglm-member-db-packaging.git Events nearly ready, menu restructure --- diff --git a/glm-member-db-packaging.php b/glm-member-db-packaging.php deleted file mode 100644 index 478d13e..0000000 --- a/glm-member-db-packaging.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 0.0.3 - */ - -/* - * Plugin and Database Versions - * - * Note that the database version matches the version of the last - * plugin version where there was a change in the database. - * - * Updates to checkDatabase() in glmPluginSupport.php must be - * made together with the DB_VERSION below. ONLY bump the DB - * version when there's a change in the database!! Use the - * version nunmber of that release for the DB version. - * - * We check the plugin version stored in the WordPress option below - * so that we're sure the other add-ons see an up to date - * version from this plugin. - */ -define('GLM_MEMBERS_PACKAGING_PLUGIN_VERSION', '1.0.20'); -define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION', '1.1.0'); - -// 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.57'); - -// Check if plugin version is not current in WordPress option and if needed updated it -if (GLM_MEMBERS_PACKAGING_PLUGIN_VERSION != get_option('glmMembersDatabasePackagingPluginVersion')) { - update_option('glmMembersDatabasePackagingPluginVersion', GLM_MEMBERS_PACKAGING_PLUGIN_VERSION); -} - -/* - * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -// Check that we're being called by WordPress. -if (!defined('ABSPATH')) { - die("Please do not call this code directly!"); -} - -/* -* Some initial setup and tests -*/ - -$startupNotices = ''; - -// Get standard defined parameters -require_once('defines.php'); - -// Required to be able to get user capabilities when being called as a filter from the main plugin -require_once(ABSPATH . 'wp-includes/pluggable.php'); - -/* - * Do some checks to make sure the main GLM Member DB is active and of a recceint enough version - */ - -// Function to generate message regarding main GLM Member DB plugin not installed and active -function glmMembersPackagingPluginRequired() { - echo ' -
-

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!

-

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.

-
- '; -} - -/* - * Check installation, activation, and version of main Member DB plugin - */ -include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); -$plugin_name = 'glm-member-db/glm-member-db.php'; -$is_active = is_plugin_active($plugin_name); - -// If it's not active, then warn user and deactivate this add-on plugin -if ($is_active != '1') { - add_action( 'admin_notices', 'glmMembersPackagingPluginRequired' ); - deactivate_plugins('/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'.php'); -} - -// Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on -function glmMembersPluginMinVerRequired() { - echo ' -
-

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than ' - .GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!
- '.GLM_MEMBERS_PACKAGING_MIN_VERSION_NOTE.'

-

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.

-
- '; -} - -/* - * Check for Minimum DB version for main Member DB - */ -$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion'); -if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) { - define('GLM_MEMBERS_PACKAGING_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, Packaging Requires: ".GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION); - add_action( 'admin_notices', 'glmMembersPluginMinVerRequired'); - deactivate_plugins('/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'.php'); -} - -/* - * 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_SETUP_PATH.'/shortcodes.php'); -require_once(GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS.'/dbVersions.php'); - -// Load Packaging Management Settings data -$packagingManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A ); -unset($packagingManagementSettings['id']); - -function glmMembersRegisterPackaging($addOns) { - - // Add this add-on to the add-ons array - $addOns[GLM_MEMBERS_PACKAGING_PLUGIN_SLUG] = array( - 'dir' => GLM_MEMBERS_PACKAGING_PLUGIN_PATH, - 'name' => GLM_MEMBERS_PACKAGING_PLUGIN_NAME, - 'short_name' => GLM_MEMBERS_PACKAGING_PLUGIN_SHORT_NAME, - 'slug' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG, - 'actions' => $GLOBALS['glmMembersPackagingAddOnValidActions'], - 'config' => array( - 'settings' => $GLOBALS['packagingManagementSettings'] - ), - 'shortcodes' => $GLOBALS['glmMembersPackagingShortcodes'], - 'shortcodesDescription' => $GLOBALS['glmMembersPackagingShortcodesDescription'], - '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 - return $addOns; -} -add_filter('glm-member-db-register-addon','glmMembersRegisterPackaging', 10, 1); - - /* - * - * Activate and Deactivate hooks - * - */ - - // Activate - function glmMembersPackagingPluginActivate () - { - global $wpdb, $config; - require_once (GLM_MEMBERS_PACKAGING_PLUGIN_PATH . '/activate.php'); - new glmMembersPackagingPluginActivate($wpdb, $config); - } - register_activation_hook(__FILE__, 'glmMembersPackagingPluginActivate'); - - // Deactivate - function glmMembersPackagingPluginDeactivate () - { - global $wpdb, $config; - require_once (GLM_MEMBERS_PACKAGING_PLUGIN_PATH . '/deactivate.php'); - $x = new glmMembersPackagingPluginDeactivate($wpdb, $config); - return false; - } - register_deactivation_hook(__FILE__, 'glmMembersPackagingPluginDeactivate'); - -/* - * Hooks for testing capabilities provided by this add-on - */ -require_once(GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH.'/permissions.php'); - diff --git a/index.php b/index.php index 4e6c07c..2db04be 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,203 @@ \ No newline at end of file +/** + * Plugin Name: GLM Members Database Packaging + * Plugin URI: http://www.gaslightmedia.com/ + * Description: Gaslight Media Members Database. + * Version: 1.0.20 + * Author: Chuck Scott + * Author URI: http://www.gaslightmedia.com/ + * License: GPL2 + */ + +/** + * Gaslight Media Members Database Packaging Add-On + * Index + * + * PHP version 5.5 + * + * @category glmWordPressPluginChild + * @package glmMembersDatabasePackagingAddOn + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.0.3 + */ + +/* + * Plugin and Database Versions + * + * Note that the database version matches the version of the last + * plugin version where there was a change in the database. + * + * Updates to checkDatabase() in glmPluginSupport.php must be + * made together with the DB_VERSION below. ONLY bump the DB + * version when there's a change in the database!! Use the + * version nunmber of that release for the DB version. + * + * We check the plugin version stored in the WordPress option below + * so that we're sure the other add-ons see an up to date + * version from this plugin. + */ +define('GLM_MEMBERS_PACKAGING_PLUGIN_VERSION', '1.0.20'); +define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION', '1.1.0'); + +// 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.57'); + +// Check if plugin version is not current in WordPress option and if needed updated it +if (GLM_MEMBERS_PACKAGING_PLUGIN_VERSION != get_option('glmMembersDatabasePackagingPluginVersion')) { + update_option('glmMembersDatabasePackagingPluginVersion', GLM_MEMBERS_PACKAGING_PLUGIN_VERSION); +} + +/* + * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +// Check that we're being called by WordPress. +if (!defined('ABSPATH')) { + die("Please do not call this code directly!"); +} + +/* +* Some initial setup and tests +*/ + +$startupNotices = ''; + +// Get standard defined parameters +require_once('defines.php'); + +// Required to be able to get user capabilities when being called as a filter from the main plugin +require_once(ABSPATH . 'wp-includes/pluggable.php'); + +/* + * Do some checks to make sure the main GLM Member DB is active and of a recceint enough version + */ + +// Function to generate message regarding main GLM Member DB plugin not installed and active +function glmMembersPackagingPluginRequired() { + echo ' +
+

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!

+

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.

+
+ '; +} + +/* + * Check installation, activation, and version of main Member DB plugin + */ +include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); +$plugin_name = 'glm-member-db/index.php'; +$is_active = is_plugin_active($plugin_name); + +// If it's not active, then warn user and deactivate this add-on plugin +if ($is_active != '1') { + add_action( 'admin_notices', 'glmMembersPackagingPluginRequired' ); + deactivate_plugins('/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'.php'); +} + +// Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on +function glmMembersPluginMinVerRequired() { + echo ' +
+

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than ' + .GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!
+ '.GLM_MEMBERS_PACKAGING_MIN_VERSION_NOTE.'

+

The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.

+
+ '; +} + +/* + * Check for Minimum DB version for main Member DB + */ +$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion'); +if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) { + define('GLM_MEMBERS_PACKAGING_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, Packaging Requires: ".GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION); + add_action( 'admin_notices', 'glmMembersPluginMinVerRequired'); + deactivate_plugins('/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'/'.GLM_MEMBERS_PACKAGING_PLUGIN_SLUG.'.php'); +} + +/* + * 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_SETUP_PATH.'/shortcodes.php'); +require_once(GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS.'/dbVersions.php'); + +// Load Packaging Management Settings data +$packagingManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A ); +unset($packagingManagementSettings['id']); + +function glmMembersRegisterPackaging($addOns) { + + // Add this add-on to the add-ons array + $addOns[GLM_MEMBERS_PACKAGING_PLUGIN_SLUG] = array( + 'dir' => GLM_MEMBERS_PACKAGING_PLUGIN_PATH, + 'name' => GLM_MEMBERS_PACKAGING_PLUGIN_NAME, + 'short_name' => GLM_MEMBERS_PACKAGING_PLUGIN_SHORT_NAME, + 'slug' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG, + 'actions' => $GLOBALS['glmMembersPackagingAddOnValidActions'], + 'config' => array( + 'settings' => $GLOBALS['packagingManagementSettings'] + ), + 'shortcodes' => $GLOBALS['glmMembersPackagingShortcodes'], + 'shortcodesDescription' => $GLOBALS['glmMembersPackagingShortcodesDescription'], + '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 + return $addOns; +} +add_filter('glm-member-db-register-addon','glmMembersRegisterPackaging', 10, 1); + + /* + * + * Activate and Deactivate hooks + * + */ + + // Activate + function glmMembersPackagingPluginActivate () + { + global $wpdb, $config; + require_once (GLM_MEMBERS_PACKAGING_PLUGIN_PATH . '/activate.php'); + new glmMembersPackagingPluginActivate($wpdb, $config); + } + register_activation_hook(__FILE__, 'glmMembersPackagingPluginActivate'); + + // Deactivate + function glmMembersPackagingPluginDeactivate () + { + global $wpdb, $config; + require_once (GLM_MEMBERS_PACKAGING_PLUGIN_PATH . '/deactivate.php'); + $x = new glmMembersPackagingPluginDeactivate($wpdb, $config); + return false; + } + register_deactivation_hook(__FILE__, 'glmMembersPackagingPluginDeactivate'); + +/* + * Hooks for testing capabilities provided by this add-on + */ +require_once(GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH.'/permissions.php'); + diff --git a/models/admin/members/packaging.php b/models/admin/members/packaging.php deleted file mode 100644 index e91f034..0000000 --- a/models/admin/members/packaging.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @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 packages 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; - $filterPackageType = false; - $haveFilter = 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(); - } - - /* - * Process based on supplied option - */ - - 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': - - // Get the package ID - $packageID = 0; - if ($_REQUEST['packageID'] && $_REQUEST['packageID'] != '') { - $packageID = $_REQUEST['packageID'] - 0; - } - - // Delete the package - if ($packageID > 0) { - $this->deleteEntry($packageID, true); - $packageDeleted = true; - } - - // Look for matching package elements -// **** NEED TO MAKE SURE THAT THE MACTHING PACKAGE ELEMENTS ARE DELETED!!! **** // - - break; - - case 'list': - default: - - $where = ''; - - // Determine if there's any selected filters - if (isset($_REQUEST['filterPackageType'])) { - switch($_REQUEST['filterPackageType']) { - - case 'member': - $where = "T.ref_type > 0"; - $filterPackageType = 'member'; - $haveFilter = true; - break; - - case 'multi-member': - $where = "T.ref_type = 0"; - $filterPackageType = 'multi-member'; - $haveFilter = true; - break; - - case 'all': - default: - $filterPackageType = 'all'; - break; - - } - } else { - $filterPackageType = 'all'; - } - - // Get the list of packages - $packages = $this->getList($where); - - // 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, - 'filterPackageType' => $filterPackageType, - 'haveFilter' => $haveFilter, - '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/packaging/index.php b/models/admin/packaging/index.php new file mode 100644 index 0000000..5c4d09b --- /dev/null +++ b/models/admin/packaging/index.php @@ -0,0 +1,324 @@ + + * @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 packages 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_packaging_index 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; + $filterPackageType = false; + $haveFilter = 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(); + } + + /* + * Process based on supplied option + */ + + 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': + + // Get the package ID + $packageID = 0; + if ($_REQUEST['packageID'] && $_REQUEST['packageID'] != '') { + $packageID = $_REQUEST['packageID'] - 0; + } + + // Delete the package + if ($packageID > 0) { + $this->deleteEntry($packageID, true); + $packageDeleted = true; + } + + // Look for matching package elements +// **** NEED TO MAKE SURE THAT THE MACTHING PACKAGE ELEMENTS ARE DELETED!!! **** // + + break; + + case 'list': + default: + + $where = ''; + + // Determine if there's any selected filters + if (isset($_REQUEST['filterPackageType'])) { + switch($_REQUEST['filterPackageType']) { + + case 'member': + $where = "T.ref_type > 0"; + $filterPackageType = 'member'; + $haveFilter = true; + break; + + case 'multi-member': + $where = "T.ref_type = 0"; + $filterPackageType = 'multi-member'; + $haveFilter = true; + break; + + case 'all': + default: + $filterPackageType = 'all'; + break; + + } + } else { + $filterPackageType = 'all'; + } + + // Get the list of packages + $packages = $this->getList($where); + + // 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, + 'filterPackageType' => $filterPackageType, + 'haveFilter' => $haveFilter, + '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/packaging/index.html', + 'data' => $templateData + ); + + } +} + +?> \ No newline at end of file diff --git a/setup/adminMenus.php b/setup/adminMenus.php index d23d5c2..0600747 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -30,5 +30,13 @@ * */ +add_submenu_page( + 'glm-members-admin-menu-members', // Parent slug + 'Packaging', // Page title + 'Packaging', // Menu Title + 'glm_members_members', // Capability required + 'glm-members-admin-menu-packaging-index', // Menu slug + function() {$this->controller('packaging');} +); ?> diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 63129a1..81d6150 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -33,22 +33,6 @@ * */ -if (apply_filters('glm_members_permit_admin_members_packages_tab', true)) { - 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; - } - ); -} - if (apply_filters('glm_members_permit_admin_member_packages_tab', true)) { add_filter('glm-member-db-add-tab-for-member', function($addOnTabs) { @@ -65,21 +49,4 @@ if (apply_filters('glm_members_permit_admin_member_packages_tab', true)) { ); } -if (apply_filters('glm_members_permit_admin_members_packages_tab', true)) { - add_filter('glm-member-db-add-tab-for-management', - function($addOnTabs) { - $newTabs = array( - array( - 'text' => 'Packaging', - 'menu' => 'management', - 'action' => 'packaging' - ) - ); - $addOnTabs = array_merge($addOnTabs, $newTabs); - return $addOnTabs; - } - ); -} - - ?> \ No newline at end of file diff --git a/setup/databaseScripts/readme.txt b/setup/databaseScripts/readme.txt new file mode 100644 index 0000000..141d8b5 --- /dev/null +++ b/setup/databaseScripts/readme.txt @@ -0,0 +1,41 @@ +This directory contains database creation and update scripts for this add-on. + +The files in this directory are checked by the checkDatabase() function in the +main plugin classes/glmPluginSupport.php file. + +This directory is optional. If there are no data tables that need to be created +for this add-on, there should be no files in this directory. The directory may +also be deleted. + +See the "examples" directory for a sample of what can go in this directory. +Procedure to update database +----------------------------- + +0) Make a backup copy of the site's database. + +1) Rename "create_database_Vx.x.x.sql" to new version number. + example: create_database_V0.0.9.sql -> create_database_V0.0.10.sql + +2) Edit renamed create database file and make desired changes + +3) Add a new "update_database_Vx.x.x.sql" named with the correct version #. + +4) Edit new update database files with SQL script to make the necessary changes + from the previous version to the new version. (i.e. to add new fields, + rename fields, insert records, ...) + +5) Optionally add an "update_database_Vx.x.x.php" file if PHP scripting is + needed to update database content. (i.e. to make changes to database content) + +6) Edit the "dbVersions.php" file and add a new line for the new version. + *** Now please be sure to add a date for each entry *** + i.e. '1.1.2' => array('version' => '1.1.2', 'tables' => 14, 'date' => '4/11/16') + +7) When this is all done, edit the index.php file for the plugin/add-on and + change "GLM_MEMBERS_{addon}_PLUGIN_DB_VERSION" defined parameter where + {addon} is the add-on name. + +8) Go to an admin menu item for the main member db plugin or any add-on. If all + goes well, the main plugin should have detected the change and updated the + database. If not, restore the database and try again. +9) Check the database to make sure the changes to fields and data are correct. diff --git a/setup/validActions.php b/setup/validActions.php index 0d5a336..d700301 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -38,6 +38,9 @@ $glmMembersPackagingAddOnValidActions = array( 'member' => array( 'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG ), + 'packaging' => array( + 'index' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG + ), 'management' => array( 'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG ) diff --git a/views/admin/member/packaging.html b/views/admin/member/packaging.html index 765a075..03f6977 100644 --- a/views/admin/member/packaging.html +++ b/views/admin/member/packaging.html @@ -78,7 +78,7 @@ {php} wp_editor('{$packageInfo.fieldData.descr|escape:quotes}', 'glm_descr', array( - // 'media_buttons' => true, + 'media_buttons' => false, // 'quicktags' => false, // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. 'textarea_name' => 'descr', diff --git a/views/admin/members/packaging.html b/views/admin/members/packaging.html index 7aed491..951076d 100644 --- a/views/admin/members/packaging.html +++ b/views/admin/members/packaging.html @@ -65,7 +65,7 @@ {php} wp_editor('{$packageInfo.fieldData.descr|escape:quotes}', 'glm_descr', array( - // 'media_buttons' => true, + 'media_buttons' => false, // 'quicktags' => false, // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. 'textarea_name' => 'descr', diff --git a/views/admin/packaging/header.html b/views/admin/packaging/header.html new file mode 100644 index 0000000..678e976 --- /dev/null +++ b/views/admin/packaging/header.html @@ -0,0 +1,8 @@ +
+

All Packages

+ +
+ + \ No newline at end of file diff --git a/views/admin/packaging/index.html b/views/admin/packaging/index.html new file mode 100644 index 0000000..b13fd6d --- /dev/null +++ b/views/admin/packaging/index.html @@ -0,0 +1,368 @@ +{include file='admin/packaging/header.html'} + + {if $packageUpdated}

Package Updated

{/if} + {if $packageError}

Error submitting package, see below...

{/if} + +{if $option == 'edit' || $option == 'add'} + + {if apply_filters('glm_members_permit_admin_members_packaging_edit_package', true)} + + + {if $option == 'edit'} +

Edit Multi-Member Package

+ Delete this Package + +
+
+

Cancel

+

+
+
+

WARNING:

+

+ Clicking the "Delete this Package" button above will + delete all of the data and images associated with this package. + +

+

+ Once deleted, this information will no longer be available and cannot be retrieved! +

+
+
+ {else} +

Add new Multi-Member Package

+ {/if} + Return to Package List + + +
+ + + + {if $havePackage} + + + {else} + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title: + + {if $packageInfo.fieldFail.title}

{$packageInfo.fieldFail.title}

{/if} +
Active: + +
Description: + {php} + wp_editor('{$packageInfo.fieldData.descr|escape:quotes}', 'glm_descr', array( + 'media_buttons' => false, + // '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} +
Image: + + {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} + + + + + + + + + + + + + +
    Title:{$packageInfo.fieldData.title}
    Name for URLs:{$packageInfo.fieldData.package_slug}
    Active:{$packageInfo.fieldData.active.name}
    Description:{$packageInfo.fieldData.descr}
    Short Description:{$packageInfo.fieldData.short_descr}
    Image:
    Start Date:{$packageInfo.fieldData.start_date.date}
    End Date:{$packageInfo.fieldData.end_date.date}
    Expiration Date:{$packageInfo.fieldData.expire_date.date}
    Pricing Description:{$packageInfo.fieldData.pricing}
    Display Order:{$packageInfo.fieldData.position}
    + + {/if} + +{else} + + {if apply_filters('glm_members_permit_admin_members_packaging_add_package', true)} +
      Add a Multi-Member Package
    + {/if} + + +
    + List Filters:   + All   + Member   + Multi-Member   + Search:    + +
    + + +

    Packages

    + + + + + + + + + + + + + {if $havePackages} + {foreach $packages as $p} + + + + + + + + {/foreach} + {else} + + {/if} + +
    PackageMemberStartEndExpire
    + {if $p.ref_type.value} + {$p.title} + {else} + {$p.title} + {/if} + + {$p.ref_dest_name} + + {$p.start_date.date} + + {$p.end_date.date} + + {$p.expire_date.date} +
    (no packages listed)
    + +{/if} + + + +{include file='admin/footer.html'}