[chuck:common]
admin_debug = true
+front_debug = true
googleMapsApiKey = ''
$GLOBALS['glmMembersFrontValidActions'] = array(
'members' => array(
- 'index', // member list
- 'list',
- 'reports',
- 'other'
+ 'list'
)
);
$this->config = $config;
// Add front-end scripts and css
- add_action('front_enqueue_scripts',
+ add_action('wp_enqueue_scripts',
array(
$this,
'glmMembersFrontScripts'
$this,
'controller'
));
+
}
/**
public function glmMembersFrontScripts ()
{
- /*
- *
- * wp_enqueue_script('jquery');
- * wp_enqueue_script('jquery-style');
- * wp_enqueue_script('jquery-ui-core');
- * wp_enqueue_script('jquery-ui-dialog');
- *
- * wp_register_script('glm-members-front-js',
- * GLM_MEMBERS_PLUGIN_URL . 'js/front.js',
- * array(
- * 'jquery'
- * ));
- * wp_enqueue_script('glm-members-front-js');
- */
+ wp_enqueue_script('jquery');
+ wp_enqueue_script('jquery-style');
+ wp_enqueue_script('jquery-ui-core');
+ wp_enqueue_script('jquery-ui-dialog');
+ wp_enqueue_style("wp-jquery-ui-dialog");
+
+ // Front end script
+ wp_register_script(
+ 'glm-members-front-js',
+ GLM_MEMBERS_PLUGIN_URL . 'js/front.js',
+ array(
+ 'jquery'
+ ));
+ wp_enqueue_script('glm-members-front-js');
// A simple set of styles for things I haven't found as a WordPress
- // default yet
- wp_register_style('glmMembersFrontStyle',
- GLM_MEMBERS_PLUGIN_URL . 'css/front.css');
+ wp_register_style(
+ 'glmMembersFrontStyle',
+ GLM_MEMBERS_PLUGIN_URL . 'css/front.css'
+ );
wp_enqueue_style('glmMembersFrontStyle');
+
}
/**
*/
public function controller ($atts, $content = null)
{
+
// Shortcode Attributes defaults
$request = shortcode_atts(
- array(
- 'action' => 'list',
- 'option' => false
- ), $atts);
+ array(
+ 'action' => 'index',
+ 'option' => false
+ ),
+ $atts,
+ 'glm-members'
+ );
/*
* Because WordPress insists on forcing the timezone to UTC
$errorMsg = '';
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
// Get all defiend constants then if not VERBOSE select out only user contstants
$consts = get_defined_constants(true);
- if (!GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ if (!GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
$consts = $consts['user'];
}
*/
// Default action is "index"
- $action = 'index';
+ $menuItem = 'members';
+ $action = 'list';
+ $option = false;
+
+ // First check shortcode attributes
+ if ($request['action']) {
+ $action = $request['action'];
+ }
+ if ($request['option']) {
+ $action = $request['option'];
+ }
- // Get any requested "action" from a form submission modify path/name
- // accordingly
+ // Get any requested "action" from a form submission - Overrides shortcode attributes
if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
$a = sanitize_text_field($_REQUEST['glm_action']);
if ($a != '') {
do {
if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
- $this->addNotice(
- "<b>Requested Action:</b> Menu item = $menuItem, Action = $action", 'Process');
+ glmMembersFront::addNotice("<b>Requested Action:</b> Menu item = $menuItem, Action = $action", 'Process');
}
$modelRedirect = false;
$smarty = new smartyTemplateSupport();
// Add standard parameters
- $smarty->templateAssign ( 'adminDebug', GLM_MEMBERS_PLUGIN_ADMIN_DEBUG);
+ $smarty->templateAssign ( 'frontDebug', GLM_MEMBERS_PLUGIN_FRONT_DEBUG);
$smarty->templateAssign ( 'baseURL', GLM_MEMBERS_PLUGIN_BASE_URL);
$smarty->templateAssign ( 'thisURL', GLM_MEMBERS_PLUGIN_CURRENT_URL );
- $smarty->templateAssign ( 'thisPage', $_REQUEST['page']);
$smarty->templateAssign ( 'glmPluginName', GLM_MEMBERS_PLUGIN_NAME );
$smarty->templateAssign ( 'glmPluginMediaURL', GLM_MEMBERS_PLUGIN_MEDIA_URL );
$smarty->templateAssign ( 'thisYear', date ( 'Y' ) );
$smarty->templateAssign ( $this->config['term']);
$smarty->templateAssign ( $this->config['phrase']);
+ $smarty->templateAssign ( 'googleMapsBrowserApiKey', $this->config['googleMapsApiKey']);
// Add all terms and phrases from the config/plugin.ini file
- $smarty->templateAssign ( 'terms', $this->config->term);
- $smarty->templateAssign ( 'phrase', $this->config->phrase);
+// $smarty->templateAssign ( 'terms', $this->config->term);
+// $smarty->templateAssign ( 'phrase', $this->config->phrase);
// Add data from model to Smarty template
if (is_array($results['data']) && count($results['data']) > 0) {
Gaslight Media Members Database Front-End Styles
*/
+
+.glm-right {
+ float: right;
+}
+.glm-left {
+ float: left;
+}
+
+
+.glm-item-container {
+ border: 1px #ccc solid;
+ padding: .4em;
+ background: #f8f8f8;
+}
+
+/* Map */
+.glm-map {
+ width:90%;
+ height:400px;
+ border: 2px black solid;
+}
+
+
+.glm-copyright {
+ text-align: center;
+ margin: 2em;
+}
;
}
-// Add Debug defines
+// Add Debug defines - These can't go into the defines.php file - Guess why.
define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', $config['admin_debug']);
define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', $config['admin_debug_verbose']);
define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', $config['front_debug']);
// Get pointer options from specified table
$order_by = $f['p_field'];
- if ($f['p_orderby']) {
+ if (isset($f['p_orderby']) && $f['p_orderby']) {
$order_by = $f['p_orderby'];
}
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-10 11:24:34
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-10 12:28:06
compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/index.html" */ ?>
<?php /*%%SmartyHeaderCode:43313958054c05ab60b0587-71987387%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
'081a36d97cdf30d438a1e104c26a275acc180da0' =>
array (
0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/index.html',
- 1 => 1426001070,
+ 1 => 1426001139,
2 => 'file',
),
),
$sql = "
UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info
SET status = ".$this->config['status_numb']['Inactive']."
- WHERE status = ".$this->config['status_numb']['Active']."
+ WHERE member = $memberID
+ AND status = ".$this->config['status_numb']['Active']."
AND id != $memberInfoID
;";
$this->wpdb->query($sql);
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Front List Members
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Members data abstract
+require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersFront_members_list extends GlmDataMemberInfo
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This contructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ 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($this->wpdb, $this->config);
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This method does the work for this model and returns any resulting data
+ *
+ * @return array Status and data array
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * '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.
+ *
+ */
+ public function modelAction ($redirectData = false)
+ {
+
+ $where = '';
+ $filterPending = false;
+ $filterArchived = false;
+ $filterName = false;
+ $haveFilter = false;
+
+ $where .= " T.status = ".$this->config['status_numb']['Active'];
+
+ // Get a current list of members
+ $list = $this->getList($where);
+
+ if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+ glmMembersFront::addNotice($list, 'DataBlock', 'Member Data');
+ }
+
+ // If we have list entries - even if it's an empty list
+ $success = true;
+ $haveMembers = false;
+ if ($list !== false) {
+
+ $success = true;
+
+ // If we have any entries
+ if (count($list) > 0) {
+ $haveMembers = true;
+ }
+ }
+
+ // Determine if current user can add, edit, delete member data
+// $canEdit = current_user_can('glm_members_edit');
+
+ // Compile template data
+ $templateData = array(
+ 'haveMembers' => $haveMembers,
+ 'members' => $list,
+ 'haveFilter' => $haveFilter,
+ 'filterArchived' => $filterArchived,
+ 'filterPending' => $filterPending,
+ 'filterName' => stripslashes($filterName)
+// 'canEdit' => $canEdit
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'front/members/list.html',
+ 'data' => $templateData
+ );
+
+ }
+
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+{include file='front/error/header.html'}
+
+ <h2>Sorry, we've had an error.</h2>
+
+ <p><b>Error: </b>: An invalid action has been specified.</p>
+
+ {if $errorMsg}<p>{$errorMsg}</p>{/if}
+
+ <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
+
+{include file='front/footer.html'}
--- /dev/null
+<div class="wrap">
+
+ <h2>{$glmPluginName}</h2>
+
+
\ No newline at end of file
--- /dev/null
+{include file='front/error/header.html'}
+
+ <center>
+
+ <h3>Sorry, we've had some type of fatal error.</h3>
+
+ <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
+
+ </center>
+
+{include file='front/footer.html'}
+
--- /dev/null
+
+ </div> <!-- / admin content area -->
+ <div class="glm-copyright">
+ {$glmPluginName}<br>
+ Copyright © 2014-{$thisYear} Gaslight Media - All Rights Reserved<br>
+ Phone: 231-487-0692 - E-Mail: info@gaslightmedia.com<br>
+ <a href="http://www.gaslightmedia.com">http://www.gaslightmedia.com</a>
+ </div>
+
+ {if $frontDebug}
+ <script>
+ window.open('{$thisURL}?glmDebugWindow=true','GLM_Plugin_Debug','width=800,height=800,left=50,top=50,resizable=yes,scrollbars=yes');
+ </script>
+ {/if}
+
+</div> <!-- / wrap -->
\ No newline at end of file
--- /dev/null
+<div class="wrap">
+ <div id="glm-front-content-container">
+
\ No newline at end of file
--- /dev/null
+{include file='front/members/header.html'}
+
+
+ <script src="http://maps.googleapis.com/maps/api/js?sensor=true&key={$googleMapsBrowserApiKey}"></script>
+
+ <div id="locationMap" class="glm-map">(map loads here)</div>
+
+
+ <h3>List of Members</h3>
+
+{if $haveMembers}
+ {foreach $members as $m}
+ <div class="glm-item-container">
+ <div><img src="{$glmPluginMediaURL}/images/small/{$m.logo}"></div>
+ <div>
+ <h2><a href=""{$thisURL}?action=detail&member={$m.id}">{$m.member}</a></h2>
+ <p>
+ {if $m.addr1}{$m.addr1}<br>{/if}
+ {if $m.addr2}{$m.addr2}<br>{/if}
+ {if $m.city.name}{$m.city.name}{if $m.state.name}, {/if}{/if}{if $m.state.name}{$m.state.name}{/if}{if $m.zip} {$m.zip}{/if}
+ {if $m.country.name}<br>{$m.country.name}{/if}
+ </p>
+
+
+ {if $m.descr}
+ <p>{$m.descr}</p>
+ {else if $m.short_descr}
+ <p>{$m.short_descr}</p>
+ {/if}
+ </div>
+
+ </div>
+ {/foreach}
+{else}
+ <div>(no members listed)</div>
+{/if}
+
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ /*
+ * Google Maps
+ * API reference: https://developers.google.com/maps/documentation/javascript/reference
+ */
+
+ // Set default - Need to make this configurable
+ var startLat = 45;
+ var startLon = -84;
+ var location = new google.maps.LatLng(startLat, startLon);
+ var map = new google.maps.Map(document.getElementById('locationMap'), {
+ maxZoom: 12,
+ disableDefaultUI: false,
+ mapTypeId: google.maps.MapTypeId.MAP,
+ });
+ var geocoder = new google.maps.Geocoder();
+
+ var bounds = new google.maps.LatLngBounds();
+
+ {if $haveMembers}
+ {foreach $members as $m}
+
+ var marker = new google.maps.Marker({
+ map: map,
+ position: new google.maps.LatLng({$m.lat}, {$m.lon}),
+ draggable: true,
+ animation: google.maps.Animation.DROP,
+ title: "{$m.member}",
+ memberID: {$m.id}
+ });
+
+ bounds.extend(marker.position);
+ {/foreach}
+ {/if}
+
+ map.fitBounds(bounds);
+
+ google.maps.event.addListener(marker, 'click', function() {
+ window.location.replace("{$thisURL}?action=detail&member=" + this.memberID);
+ });
+
+
+ });
+ </script>
+
+
+
+{include file='front/footer.html'}