--- /dev/null
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Packaging Management data class
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package GLM Member-DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataPackagingManagement.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataManagementPackaging class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataPackagingManagement.php,v 1.0 2011/01/25 19:31:47 cscott
+ * Exp $
+ */
+class GlmDataPackagingManagement extends GlmDataAbstract
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Data Table Name
+ *
+ * @var $table
+ * @access public
+ */
+ public $table;
+ /**
+ * Field definitions
+ *
+ * 'type' is type of field as defined by the application
+ * text Regular text field
+ * pointer Pointer to an entry in another table
+ * 'filters' is the filter name for a particular filter ID in PHP filter
+ * functions
+ * See PHP filter_id()
+ *
+ * 'use' is when to use the field
+ * l = List
+ * g = Get
+ * n = New
+ * i = Insert
+ * e = Edit
+ * u = Update
+ * d = Delete
+ * a = All
+ *
+ * @var $ini
+ * @access public
+ */
+ public $fields = false;
+
+ /**
+ * Constructor
+ *
+ * @param object $d database connection
+ * @param array $config Configuration array
+ * @param bool $limitedEdit Flag to say indicate limited edit requested
+ *
+ * @return void
+ * @access public
+ */
+ public function __construct($wpdb, $config, $limitedEdit = false)
+ {
+
+ // If this class is not being extended along with existing $wpdb and $config
+ if (!$this->wpdb) {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /*
+ * Table Name
+ */
+ $this->table = GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX . 'management';
+
+ /*
+ * Table Data Fields
+ */
+
+ $this->fields = array (
+
+ 'id' => array (
+ 'field' => 'id',
+ 'type' => 'integer',
+ 'view_only' => true,
+ 'use' => 'a'
+ ),
+
+ // Canonical Page Slug
+ 'canonical_package_page' => array (
+ 'field' => 'canonical_package_page',
+ 'type' => 'text',
+ 'required' => true,
+ 'use' => 'a'
+ )
+
+ );
+
+ }
+
+
+}
+
+?>
\ No newline at end of file
'use' => 'a'
),
+ // Package Slug
+ 'package_slug' => array (
+ 'field' => 'package_slug',
+ 'type' => 'text',
+ 'required' => true,
+ 'use' => 'gle'
+ ),
+
// Description
'descr' => array (
'field' => 'descr',
'type' => 'pointer',
'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
'p_field' => 'name',
- 'p_orderby' => 'name',
'p_blank' => true,
'required' => true,
'use' => 'lged'
return $r;
}
+ /*
+ * Update package slug - should be called after a package record is added or updated
+ *
+ * @param integer id ID of package that needs the slug updated
+ * @access public
+ */
+ public function updateSlug($id = false)
+ {
+
+ if ($id == false) {
+ return false;
+ }
+
+ $p = $this->getEntry($id);
+
+ $slug = sanitize_title($p['title']);
+
+ // Update the slug
+ $sql = "
+ UPDATE ".GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX."packages
+ SET package_slug = '$slug'
+ WHERE id = $id
+ ;";
+ $this->wpdb->query($sql);
+
+ return $slug;
+
+ }
+
+
}
?>
\ No newline at end of file
* version nunmber of that release for the DB version.
*/
define('GLM_MEMBERS_PACKAGING_PLUGIN_VERSION', '1.0.5');
-define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION', '0.0.2');
+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.48');
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
'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(
--- /dev/null
+Add an admin tab
+
+* Add a new section in setup/adminTabs.php
+
+* Add a model file - models/admin/{menu}/{action}.php
+
+* Add a view file - views/admin/{menu}/{action}.html
+
+* Add action to setup/validActions.php
+
+* If needed add a database table to the create_database_V...sql file
+ and update name to current database version, add an
+ update_database_V....sql file, and/or update dbVersions.php
+
+* If required add a data definition for any new tables
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members DB - Packaging Add-on - Management Package Tab
+ *
+ * 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 Management Packaging data abstract
+require_once(GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH.'/data/dataManagement.php');
+
+/**
+ * GlmMembersAdmin_management_packaging
+ *
+ * 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_management_packaging extends GlmDataPackagingManagement
+{
+
+ /**
+ * 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)
+ {
+ $settingsUpdated = false;
+
+ // Determine if current user can edit configurations
+ if (!current_user_can('glm_members_configure')) {
+ return array(
+ 'status' => false,
+ 'menuItemRedirect' => 'error',
+ 'modelRedirect' => 'index',
+ 'view' => 'admin/error/index.html',
+ 'data' => array(
+ 'reason' => 'User does not have rights to make configuration changes.'
+ )
+ );
+ }
+
+ // Check for submission option
+ $option = '';
+ if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') {
+ $option = $_REQUEST['option'];
+ }
+
+ switch($option) {
+
+ // Update the settings and redisplay the form
+ case 'submit':
+
+ // Update the package management settings
+ $packageSettings = $this->updateEntry(1);
+ if ($packageSettings['status']) {
+ $settingsUpdated = true;
+ }
+
+ // Display admin message that the data has been updated
+ glmMembersAdmin::addNotice('Packaging Settings for the '.GLM_MEMBERS_PACKAGING_PLUGIN_NAME.' plugin have been updated.', 'AdminNotice');
+
+ break;
+
+ // Default is to get the current settings and display the form
+ default:
+
+ // Try to get the first (should be only) entry for general settings.
+ $packageSettings = $this->editEntry(1);
+
+ if ($packageSettings === false) {
+
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice("<b> /models/admin/management/packaging.php: Unable to load packaging management settings.", 'Alert');
+ }
+
+ }
+
+ break;
+
+ }
+
+ // Compile template data
+ $templateData = array(
+ 'reason' => '',
+ 'packagingSettings' => $packageSettings,
+ 'settingsUpdated' => $settingsUpdated
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => true,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/management/packaging.html',
+ 'data' => $templateData
+ );
+
+
+ }
+}
+
+?>
\ No newline at end of file
// If the package inserted successfully
if ($packageInfo && $packageInfo['status']) {
+ // Update the package title slug
+ $this->updateSlug($packageInfo['fieldData']['id']);
+
// Get the new package ID
$packageID = $packageInfo['fieldData']['id'];
// If it updated successfully
if ($packageInfo && $packageInfo['status']) {
+ // Update the package title slug
+ $this->updateSlug($packageID);
+
// Get the package data again prepared for editing
- $packages = $this->editEntry($packageID);
+ $packageInfo = $this->editEntry($packageID);
// Tell the template the package was updated
$packageUpdated = true;
default:
// Get the list of packages
- $packages = $this->getList("T.ref_type = 0");
+// $packages = $this->getList("T.ref_type = 0");
+ $packages = $this->getList();
// If we have some, tell the template
if ($packages && count($packages) > 0) {
);
}
+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
--- /dev/null
+-- Gaslight Media Members Database - Packaging
+-- File Created: 12/02/15 15:27:15
+-- Database Version: 0.0.2
+-- Database Creation Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Packages
+CREATE TABLE {prefix}packages (
+ id INT NOT NULL AUTO_INCREMENT,
+ active BOOLEAN NULL, -- Package is active
+ title TINYTEXT NULL, -- Title of package
+ package_slug TINYTEXT NULL, -- Package name slug for canonical URLs (lowercase, "-" for spaces, no punctuation)
+ descr TEXT NULL, -- Description of package
+ short_descr TINYTEXT NULL, -- Short description of package
+ image TINYTEXT NULL, -- Package image
+ start_date TIMESTAMP NULL, -- Date display of this package starts
+ end_date TIMESTAMP NULL, -- Date display of this package ends (last date of display)
+ expire_date TIMESTAMP NULL, -- Date package expires (first date it's expired)
+ position INT NULL, -- Display order position
+ pricing TINYTEXT NULL, -- Pricing, descriptive
+ ref_type INT NULL, -- Type of entity this package is associated with
+ ref_dest INT NULL, -- Pointer to the specific entity
+ PRIMARY KEY (id),
+ INDEX(ref_type),
+ INDEX(ref_dest),
+ INDEX(start_date),
+ INDEX(end_date),
+ INDEX(expire_date)
+);
+
+----
+
+-- Package Elements - Items in a package
+CREATE TABLE {prefix}package_elements (
+ id INT NOT NULL AUTO_INCREMENT,
+ package INT NULL, -- Pointer to the package
+ active BOOLEAN NULL, -- Package is active
+ title TINYTEXT NULL, -- Title of element
+ descr TEXT NULL, -- Description for this entity's participation in the package
+ short_descr TEXT NULL, -- Short description for this entity's participation in the package
+ image TINYTEXT NULL, -- Element image
+ position INT NULL, -- Display order position
+ ref_type INT NULL, -- Type of entity this element is association with
+ ref_dest INT NULL, -- Pointer to the specific entity
+ PRIMARY KEY (id),
+ INDEX(package),
+ INDEX(ref_type),
+ INDEX(ref_dest)
+);
+
+----
+
+-- Package Management Settings
+CREATE TABLE {prefix}management (
+ id INT NOT NULL AUTO_INCREMENT,
+ canonical_package_page TINYTEXT NULL, -- Canonical page slug for package detail
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Set default package management entry
+INSERT INTO {prefix}management
+ ( id, canonical_package_page )
+ VALUES
+ ( 1, 'package-detail' )
+;
+
*/
$glmMembersPackagingDbVersions = array(
- '0.0.2' => array('version' => '0.0.2', 'tables' => 2)
+ '0.0.2' => array('version' => '0.0.2', 'tables' => 2),
+ '1.1.0' => array('version' => '1.1.0', 'tables' => 3)
);
--- /dev/null
+<?php
+/*
+ * Gaslight Media Members Database - Packaging Add-On
+ *
+ * Database Update Script for version 1.1.0
+ */
+
+/*
+ * Update package records to build package_slug field data from title
+ */
+
+// Get all package records
+$packageRecords = $this->wpdb->get_results('SELECT id, title FROM '.GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX.'packages;', ARRAY_A);
+
+// If there's any package records
+if ($packageRecords && count($packageRecords) > 0) {
+
+ // For each package record
+ foreach ($packageRecords as $p) {
+
+ // Create a slug from the title
+ $slug = sanitize_title($p['title']);
+
+ // Store this value back into the record
+ $this->wpdb->update(
+ GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX.'packages',
+ array(
+ 'package_slug' => $slug
+ ),
+ array( 'id' => $p['id'] ),
+ array( '%s' ),
+ array( '%d')
+ );
+ }
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+-- Gaslight Media Members Database
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 1.0.28
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+-- Package Management Settings
+CREATE TABLE {prefix}management (
+ id INT NOT NULL AUTO_INCREMENT,
+ canonical_package_page TINYTEXT NULL, -- Canonical page slug for package detail
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Set default package management entry
+INSERT INTO {prefix}management
+ ( id, canonical_package_page )
+ VALUES
+ ( 1, 'package-detail' )
+;
+
+----
+
+ALTER TABLE {prefix}packages ADD COLUMN package_slug TINYTEXT;
+
+
+
),
'member' => array(
'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG
+ ),
+ 'management' => array(
+ 'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG
)
),
'frontActions' => array(
--- /dev/null
+{include file='admin/management/header.html'}
+
+
+ {if $settingsUpdated}<h2 class="glm-notice glm-flash-updated">Settings Updated</h2>{/if}
+
+ <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="packaging">
+ <input type="hidden" name="option" value="submit">
+
+ <table class="glm-admin-table">
+
+ <!-- General Packaging Settings -->
+
+ <tr><td colspan="2"><h2>General Packaging Settings</h2></td></tr>
+ <tr>
+ <th>Package Detail Page Permalink Name:</th>
+ <td>
+ <input type="text" name="canonical_package_page" value="{$packagingSettings.fieldData.canonical_package_page}">
+ <br>Use only the page name at the end of the permalink for the package detail page.
+ </td>
+ </tr>
+ </table>
+ <input type="submit" value="Update Settings" class="button-primary">
+ </form>
+
+ <script type="text/javascript">
+
+ jQuery(document).ready(function($) {
+
+ // 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).fadeIn(500).fadeOut(500);
+
+ });
+ </script>
+
+{include file='admin/footer.html'}
{if $packageInfo.fieldFail.title}<p>{$packageInfo.fieldFail.title}</p>{/if}
</td>
</tr>
+ <tr><th>Name for URLs:</th><td>{$packageInfo.fieldData.package_slug}</p></td></tr>
<tr>
<th>Active:</th>
<td>
<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>
{else} <!-- option is not edit or add -->
{if apply_filters('glm_members_permit_admin_members_packaging_add_package', true)}
- <div id="addPackageButton" class="button-primary glm-right">Add a Package</div>
+ <div id="addPackageButton" class="button-primary glm-right"> Add a Package</div>
{/if}
- <h2>Multi-Member Packages</h2>
+ <!-- Package list selection form -->
+ <form class="glm-right" onSubmit="return false;">
+ <span{if $haveFilter} class="glm-notice"{/if}><b>List Filters:</b> </span>
+ <input type="radio" name="filterPackageType" class="listFilter"{if $filterMultiMember} checked{/if} value="all">All
+ <input type="radio" name="filterPackageType" class="listFilter"{if $filterMultiMember} checked{/if} value="member">Member
+ <input type="radio" name="filterPackageType" class="listFilter"{if $filterMultiMember} checked{/if} value="multi-member">Multi-Member
+ Search: <input id="glmPackageSearch" type="text" id="autoTest">
+ </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>
{if $havePackages}
{foreach $packages as $p}
<tr>
- <td>
+ <td class="glm-nowrap">
<a href="{$thisURL}?page={$thisPage}&glm_action=packaging&option=edit&packageID={$p.id}">{$p.title}</a>
</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>
{/if}
/*
- * Package Members Processing
+ * 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.
*/
-
- // Build a list of members for the autocomplete search
- var availableTags = [
- {foreach $membersList as $m}
- { label: "{$m.name|unescape:'html'}", value: "{$m.name|unescape:'html'}", id: '{$m.id}', name: "{$m.name}" },
- {/foreach}
- ];
-
- $( "#glmMembersList" ).autocomplete({
+ var availableTags = [
+ {if $havePackages}
+ {foreach $packages as $p}
+ { label: "{$p.title|unescape:'html'} - {$p.ref_dest_name|unescape:'html'}", id: '{$p.id}' },
+ {/foreach}
+ {/if}
+ ];
+ $( "#glmPackageSearch" ).autocomplete({
source: availableTags,
html: true,
select: function( event, ui ) {
-
- // get the member ID and Name
- var memberID = ui.item.id;
- var memberName = ui.item.name
-
- // Get a copy of the template
- var memberTemplate = $('#glmGalleryItmeDataTemplate').html();
-
- // Set the member data into the template copy
- memberTemplate = memberTemplate.replace('{ id }', memberID).replace('{ memberName }', memberID);
-
- // Insert the selected member
- $('#glmPackageMembersList').append(memberTemplate);
-
- {if !$havePackageMembers}
- // Hide the no members selected message
- $('#glmNoMembersSelected').hide();
- {/if}
-
+ var packageID = ui.item.id;
+ window.location.replace("{$adminURL}?page=glm-members-admin-menu-members&glm_action=packaging&package=" + packageID );
}
});
-
+
});
</script>
<div><a class="url" title="url" href={$p.url}>{$p.url}</a></div>
{/if}
{if $p.email}
- <div><a class="email" title="Email" href={$p.email}>Email</a></div>
+ <div><a class="email" title="Email" href={$p.email}>{$p.email}</a></div>
{/if}
</div>
</div>
{if $p.image}
<img src="{$glmPluginMediaURL}/images/medium/{$p.image}">
{/if}
- <h3 class="package-title"><a href="{$thisURL}?glm_action=detail&packageID={$p.id}">{$p.title}</a></h3>
+ <h3 class="package-title"><a href="{$thisURL}{$settings.canonical_package_page}/{$p.package_slug}/">{$p.title}</a></h3>
{if $p.descr}
{$p.descr}
{else if $p.short_descr}