Events nearly ready, menu restructure
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 20 Apr 2016 21:16:32 +0000 (17:16 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 20 Apr 2016 21:16:32 +0000 (17:16 -0400)
12 files changed:
glm-member-db-packaging.php [deleted file]
index.php
models/admin/members/packaging.php [deleted file]
models/admin/packaging/index.php [new file with mode: 0644]
setup/adminMenus.php
setup/adminTabs.php
setup/databaseScripts/readme.txt [new file with mode: 0644]
setup/validActions.php
views/admin/member/packaging.html
views/admin/members/packaging.html
views/admin/packaging/header.html [new file with mode: 0644]
views/admin/packaging/index.html [new file with mode: 0644]

diff --git a/glm-member-db-packaging.php b/glm-member-db-packaging.php
deleted file mode 100644 (file)
index 478d13e..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-/**
- * 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 <cscott@gaslightmedia.com>
- * @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 '
-        <div class="error">
-            <p>The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!</p>
-            <p>The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.</p>
-        </div>
-    ';
-}
-
-/*
- * 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 '
-        <div class="error">
-            <p>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.'!<br>
-                    '.GLM_MEMBERS_PACKAGING_MIN_VERSION_NOTE.'</p>
-            <p>The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.</p>
-        </div>
-    ';
-}
-
-/*
- * 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');
-
index 4e6c07c..2db04be 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,3 +1,203 @@
 <?php
-// Silence is golden.
-?>
\ 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 <cscott@gaslightmedia.com>
+ * @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 '
+        <div class="error">
+            <p>The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!</p>
+            <p>The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.</p>
+        </div>
+    ';
+}
+
+/*
+ * 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 '
+        <div class="error">
+            <p>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.'!<br>
+                    '.GLM_MEMBERS_PACKAGING_MIN_VERSION_NOTE.'</p>
+            <p>The '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin has been de-activated.</p>
+        </div>
+    ';
+}
+
+/*
+ * 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 (file)
index e91f034..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-<?php
-/**
- * Gaslight Media Members Database
- * GLM Members DB - Packaging Add-on - Main packages list
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @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 <cscott@gaslightmedia.com>
- * @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 (file)
index 0000000..5c4d09b
--- /dev/null
@@ -0,0 +1,324 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members DB - Packaging Add-on - Main packages list
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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 <cscott@gaslightmedia.com>
+ * @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
index d23d5c2..0600747 100644 (file)
  *
  */
 
+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');}
+);
 
 ?>
index 63129a1..81d6150 100644 (file)
  *
  */
 
-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 (file)
index 0000000..141d8b5
--- /dev/null
@@ -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.
index 0d5a336..d700301 100644 (file)
@@ -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
         )
index 765a075..03f6977 100644 (file)
@@ -78,7 +78,7 @@
                     <td {if $packageInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
                         {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',
index 7aed491..951076d 100644 (file)
@@ -65,7 +65,7 @@
                 <td {if $packageInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
                     {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 (file)
index 0000000..678e976
--- /dev/null
@@ -0,0 +1,8 @@
+<div class="wrap">
+    <h2>All Packages</h2>
+    <h2 class="nav-tab-wrapper">
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">Packages List</a>
+    </h2>
+    <div id="glm-admin-content-container">
+    
+    
\ No newline at end of file
diff --git a/views/admin/packaging/index.html b/views/admin/packaging/index.html
new file mode 100644 (file)
index 0000000..b13fd6d
--- /dev/null
@@ -0,0 +1,368 @@
+{include file='admin/packaging/header.html'}
+
+    {if $packageUpdated}<h2 class="glm-notice glm-flash-updated">Package Updated</h2>{/if}
+    {if $packageError}<h2 class="glm-error glm-flash-updated">Error submitting package, see below...</h2>{/if}
+    
+{if $option == 'edit' || $option == 'add'}
+    
+  {if apply_filters('glm_members_permit_admin_members_packaging_edit_package', true)}
+
+        
+      {if $option == 'edit'}
+        <h2>Edit Multi-Member Package</h2>
+        <a id="deletePackageButton" class="button button-primary glm-button glm-right">Delete this Package</a>
+        
+        <div id="deletePackageDialog" class="glm-dialog-box" title="Delete Package">
+            <center>
+                <p><a id="deletePackageCancel" class="button button-primary">Cancel</a></p>
+                <p><input id="deletePackageSubmit" type="submit" value="Delete this package"></p>
+            </center>
+            <div class="glm-item-container">
+                <p><center><span class="glm-error">WARNING:</span></center></p>
+                <p>
+                    <span class="glm-warning">Clicking the "Delete this Package" button above will 
+                    delete all of the data and images associated with this package.
+                    </span>
+                </p>
+                <p>
+                    <span class="glm-error">Once deleted, this information will no longer be available and cannot be retrieved!</span>
+                </p>
+            </div>
+        </div>
+      {else}
+        <h2>Add new Multi-Member Package</h2>
+      {/if}
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=packaging" class="button button-primary glm-button glm-right">Return to Package List</a>
+        
+    
+        <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+            <input type="hidden" name="glm_action" value="packaging">
+            <input type="hidden" name="ref_type" value="0">
+            <input type="hidden" name="ref_dest" value="0">
+          {if $havePackage}
+            <input type="hidden" name="option" value="update">
+            <input type="hidden" name="packageID" value="{$packageID}">
+          {else}
+            <input type="hidden" name="option" value="insert">
+          {/if}
+    
+            <table class="glm-admin-table">
+                <tr>
+                    <th {if $packageInfo.fieldRequired.title}class="glm-required"{/if}>Title:</th>
+                    <td {if $packageInfo.fieldFail.title}class="glm-form-bad-input"{/if}>
+                        <input type="text" name="title" value="{$packageInfo.fieldData.title}" class="glm-form-text-input-short">
+                        {if $packageInfo.fieldFail.title}<p>{$packageInfo.fieldFail.title}</p>{/if}
+                    </td>
+                </tr>
+                <tr>
+                    <th>Active:</th>
+                    <td>
+                        <input type="checkbox" name="active" {if $packageInfo.fieldData.active.value} checked{/if}>
+                    </td>
+                </tr>
+                <tr>
+                <th {if $packageInfo.fieldRequired.descr}class="glm-required"{/if}>Description:</th>
+                <td {if $packageInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
+                    {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}<p>{$packageInfo.fieldFail.descr}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.short_descr}class="glm-required"{/if}>Short Description:</th>
+                <td {if $packageInfo.fieldFail.short_descr}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="short_descr" value="{$packageInfo.fieldData.short_descr}" class="glm-form-text-input" placeholder="A short, one line, description of the package.">
+                    {if $packageInfo.fieldFail.short_descr}<p>{$packageInfo.fieldFail.short_descr}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.image}class="glm-required"{/if}>Image:</th>
+                <td {if $packageInfo.fieldFail.image}class="glm-form-bad-input"{/if}>
+                    <table class="glm-admin-image-edit-table">
+        {if $packageInfo.fieldData.image}
+                        <tr>
+                            <td>
+                                <div class="glm-galleryImage" data-id="image">
+                                    <img src="{$glmPluginMediaUrl}/images/small/{$packageInfo.fieldData.image}">
+                                </div>
+                            </td>
+                            <td>
+                                <input type="checkbox" name="image_delete"> Delete Image<br>
+                                {$packageInfo.fieldData.image}<br>
+                            </td>
+                        </tr>
+        {/if}
+                        <tr><td colspan="2"><b>New image:</b> <input type="file" name="image_new"></td></tr>
+                    </table>
+                    <div id="glm-galleryImageLarger_image" class="glm-imageDialog"><img src="{$glmPluginMediaUrl}/images/large/{$packageInfo.fieldData.image}"></div>
+                    {if $packageInfo.fieldFail.image}<p>{$packageInfo.fieldFail.image}</p>{/if}
+                </td>
+                </tr>
+                <tr>
+                    <th {if $packageInfo.fieldRequired.start_date}class="glm-required"{/if}>Start Date:</th>
+                    <td {if $packageInfo.fieldFail.start_date}class="glm-form-bad-input"{/if}>
+                        <input type="text" name="start_date" value="{$packageInfo.fieldData.start_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                        {if $packageInfo.fieldFail.start_date}<p>{$packageInfo.fieldFail.start_date}</p>{/if}
+                    </td>
+                </tr>
+                <tr>
+                    <th {if $packageInfo.fieldRequired.end_date}class="glm-required"{/if}>End Date:</th>
+                    <td {if $packageInfo.fieldFail.end_date}class="glm-form-bad-input"{/if}>
+                        <input type="text" name="end_date" value="{$packageInfo.fieldData.end_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                        {if $packageInfo.fieldFail.end_date}<p>{$packageInfo.fieldFail.end_date}</p>{/if}
+                    </td>
+                </tr>
+                <tr>
+                    <th {if $packageInfo.fieldRequired.expire_date}class="glm-required"{/if}>Expire Date:</th>
+                    <td {if $packageInfo.fieldFail.expire_date}class="glm-form-bad-input"{/if}>
+                        <input type="text" name="expire_date" value="{$packageInfo.fieldData.expire_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                        {if $packageInfo.fieldFail.expire_date}<p>{$packageInfo.fieldFail.expire_date}</p>{/if}
+                    </td>
+                </tr>
+                <tr>
+                    <th {if $packageInfo.fieldRequired.pricing}class="glm-required"{/if}>Pricing Description:</th>
+                    <td {if $packageInfo.fieldFail.pricing}class="glm-form-bad-input"{/if}>
+                        <input type="text" name="pricing" value="{$packageInfo.fieldData.pricing}" class="glm-form-text-input" placeholder="Describe package pricing.">
+                        {if $packageInfo.fieldFail.pricing}<p>{$packageInfo.fieldFail.pricing}</p>{/if}
+                    </td>
+                </tr>
+                <tr>
+                    <th {if $packageInfo.fieldRequired.position}class="glm-required"{/if}>Display Order:</th>
+                    <td {if $packageInfo.fieldFail.position}class="glm-form-bad-input"{/if}>
+                        <input type="text" name="position" value="{$packageInfo.fieldData.position}" class="glm-form-text-input-short">
+                        {if $packageInfo.fieldFail.position}<p>{$packageInfo.fieldFail.position}</p>{/if}
+                    </td>
+                </tr>
+                
+    <!-- NOT COMPLETING PARTICIPATING MEMBERS AT THIS TIME -->
+                
+                <tr>
+                    <th>Participating Members</th>
+                    <td class="glm-imageGalleryContainer">
+    
+                        
+                        Search to add a member: <input  id="glmMembersList" type="text" id="autoTest" style="margin-left: 2em;"><br>
+                                            
+                        
+                        <input type="hidden" id="galleryPositionOrder" name="galleryPositionOrder" 
+                            value="{if $havePackageMembers}{foreach $gallery as $i name=ig}{if $i.title}{$i.id}{if not $smarty.foreach.ig.last},{/if}{/if}{/foreach}{/if}" />
+    
+                        <!-- The contents of this div are read by imageUpload.js to use as a template for inserting a new image into the gallery area -->
+                        <div id="glmGalleryItmeDataTemplate" class="glm-imageItemHidden">
+                            <li id="packageMember_{ id }" class="glm-galleryContainerFlexible">
+                                <input type="hidden" name="packageMember_{ id }" value="{ id }">
+                                <input type="hidden" name="position_{ id }" value="{ position }">
+                                    <table class="glm-statusTable">
+                                        <tr><th>Package Member:</th><td>{ memberName }</td></tr>
+                                        <tr><th>Active:</th><td><input type="checkbox"></td></tr>
+                                        <tr><th>Package Element Title:</th><td><input type="text" value=""></td></tr>
+                                        <tr><th>Description:</th><td><input type="text" value=""></td></tr>
+                                        <tr><th>Short Description:</th><td><input type="text" value=""></td></tr>
+                                        <tr><th>Image:</th><td><input type="file"></td></tr>
+                                    </table>
+                            </li>
+                        </div>
+                        <!-- End of template -->
+                        <div class="glm-imageGalleryContainer glm-item-container">
+                            <ul id="glmPackageMembersList" class=".glm-galleryContainer">
+            {if $havePackageMembers}     
+                                <!-- Note that id in li is needed for sorting -->
+                {foreach $packageMembers as $i}
+                                <li id="packageMember_{$i.id}" class="glm-galleryContainerFlexible">
+                                    <input type="hidden" name="packageMember_{$i.id}" value="{$i.id}">
+                                    <input type="hidden" name="position_{$i.id}" value="{$i.position}">
+                                    <div class="glm-galleryImageData">
+                                    <table class="glm-galleryContainerContent">
+                                        <tr><th>Package Member:</th><td>{$i.memberName}</td></tr>
+                                        <tr><th>Active:</th><td><input type="checkbox"></td></tr>
+                                        <tr><th>Package Element Title:</th><td><input type="text"></td></tr>
+                                        <tr><th>Description:</th><td><input type="text"></td></tr>
+                                        <tr><th>Short Description:</th><td><input type="text"></td></tr>
+                                        <tr><th>Image:</th><td><input type="file"></td></tr>
+                                        
+                                    </table>
+                                    </div>
+                                </li>
+                {/foreach}
+            {else}
+                                <li id="glmNoMembersSelected">No members have been added to this package yet.<br>Please select a member above.</li>
+            {/if}
+                            </ul>
+                        </div>
+                    </td>
+                </tr>
+    
+                
+            </table>
+            <input type="submit" value="{if $havePackage}Update Package{else}Add New Package{/if}">
+        </form>
+        
+  {else} <!-- Can just display -->
+          
+        <table class="glm-admin-table">
+            <tr><th>Title:</th><td>{$packageInfo.fieldData.title}</td></tr>
+            <tr><th>Name for URLs:</th><td>{$packageInfo.fieldData.package_slug}</td></tr>
+            <tr><th>Active:</th><td>{$packageInfo.fieldData.active.name}</td></tr>
+            <tr><th>Description:</th><td>{$packageInfo.fieldData.descr}</td></tr>
+            <tr><th>Short Description:</th><td>{$packageInfo.fieldData.short_descr}</td></tr>
+            <tr><th>Image:</th><td><img src="{$glmPluginMediaUrl}/images/large/{$packageInfo.fieldData.image}"></td></tr>
+            <tr><th>Start Date:</th><td>{$packageInfo.fieldData.start_date.date}</td></tr>
+            <tr><th>End Date:</th><td>{$packageInfo.fieldData.end_date.date}</td></tr>
+            <tr><th>Expiration Date:</th><td>{$packageInfo.fieldData.expire_date.date}</td></tr>
+            <tr><th>Pricing Description:</th><td>{$packageInfo.fieldData.pricing}</td></tr>
+            <tr><th>Display Order:</th><td>{$packageInfo.fieldData.position}</td></tr>
+        </table>
+        
+  {/if}
+
+{else} <!-- option is not edit or add -->
+    
+  {if apply_filters('glm_members_permit_admin_members_packaging_add_package', true)}
+    <div id="addPackageButton" class="button button-primary glm-right" title='To create a member specific package, select that member from the "Member List" tab then select "Packaging" tab.'>&nbsp;&nbsp;Add a Multi-Member Package</div>
+  {/if}
+      
+    <!-- Package list selection form -->      
+    <form class="glm-right" onSubmit="return false;">
+       <span{if $haveFilter} class="glm-notice"{/if}><b>List Filters:</b>&nbsp;&nbsp;</span> 
+       <input type="radio" name="filterPackageType" class="listFilter"{if $filterPackageType == 'all'} checked{/if} value="all">All&nbsp;&nbsp;
+       <input type="radio" name="filterPackageType" class="listFilter"{if $filterPackageType == 'member'} checked{/if} value="member">Member&nbsp;&nbsp;
+       <input type="radio" name="filterPackageType" class="listFilter"{if $filterPackageType == 'multi-member'} checked{/if} value="multi-member">Multi-Member&nbsp;&nbsp;
+       Search: <input  id="glmPackageSearch" type="text" id="autoTest" title="Enter any portion of a package name then click on full name that shows below this input box.">&nbsp;&nbsp;
+    </form>
+    <br clear="all">
+      
+      
+    <h2>Packages</h2>
+
+    <table class="wp-list-table striped glm-admin-table">
+        <thead>
+            <tr>
+                <th>Package</th>
+                <th>Member</th>
+                <th>Start</th>
+                <th>End</th>
+                <th>Expire</th>
+            </tr>
+        </thead>
+        <tbody>
+  {if $havePackages}
+    {foreach $packages as $p}
+            <tr>
+                <td class="glm-nowrap">
+        {if $p.ref_type.value}
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=packaging&option=edit&member={$p.ref_dest}&packageID={$p.id}">{$p.title}</a>
+        {else}
+                    <a href="{$thisUrl}?page={$thisPage}&glm_action=packaging&option=edit&packageID={$p.id}">{$p.title}</a>
+        {/if}
+                </td>
+                <td class="glm-nowrap">
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=index&member={$p.ref_dest}">{$p.ref_dest_name}</a>
+                </td>
+                <td>
+                    {$p.start_date.date}
+                </td>
+                <td>
+                    {$p.end_date.date}
+                </td>
+                <td>
+                    {$p.expire_date.date}
+                </td>
+            </tr>
+    {/foreach}
+  {else}
+            <tr class="alternate"><td colspan="5">(no packages listed)</td></tr>
+  {/if}
+        </tbody>
+    </table>
+
+{/if}
+
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+    
+            // Add Package Button Action
+            $('#addPackageButton').click( function() {
+                window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=packaging&option=add";
+            });
+            
+            // Date Input
+            $('.glm-date-input').datepicker();
+            
+            // Flash certain elements for a short time after display      
+            $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+    {if $havePackage}
+            // Delete Package dialog
+            $("#deletePackageDialog").dialog({
+                autoOpen: false,
+                minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+            $('#deletePackageButton').click( function() {
+                $('#deletePackageDialog').dialog('open');
+            });
+            $('#deletePackageCancel').click( function() {
+                $("#deletePackageDialog").dialog("close");
+            });            
+            $('#deletePackageSubmit').click( function() {
+                window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=packaging&option=delete&packageID={$packageInfo.fieldData.id}");
+            });
+    {/if}
+
+            /*
+             * Filter triggers
+             */
+             var filter = '';
+             $("[name='filterPackageType']" ).change( function() {
+
+                 // Get type of package filter selected
+                 filter = $(this).val();
+                
+                 window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=packaging&filterPackageType=" + filter;
+                
+                return false;
+            });
+
+            /*
+             * Do autocomplete search for package
+             * label: What will be searched
+             * value: What will be displayed when selected
+             * id: Package id added so we can go to the member while showing what was selected
+             * Also note that autocomplete does not properly render HTML codes, so we 
+             * "unescape" them for HTML in Smarty.
+             */
+            var availableTags = [
+    {if $havePackages}
+        {foreach $packages as $p}
+                { label: "{$p.title|unescape:'html'} - {$p.ref_dest_name|unescape:'html'}", id: '{$p.id}', memb: '{if isset($p.member)}{$p.member.member_pointer}{else}0{/if}' },
+        {/foreach}
+    {/if}
+             ];
+             $( "#glmPackageSearch" ).autocomplete({
+                 source: availableTags,
+                 html: true,
+                 select: function( event, ui ) {
+                     var packageID = ui.item.id;
+                     var memberID = ui.item.memb;
+                     if (memberID > 0) {
+                         // Selected package is a member package
+                         window.location.replace("{$adminUrl}?page=glm-members-admin-menu-member&glm_action=packaging&option=edit&member=" + memberID + "&packageID=" + packageID );
+                     } else {
+                         // Selected package is a mulit-member package
+                         window.location.replace("{$adminUrl}?page=glm-members-admin-menu-members&glm_action=packaging&option=edit&packageID=" + packageID );
+                     }
+                 }
+             });
+             
+        });
+    </script>
+            
+{include file='admin/footer.html'}