--- /dev/null
+<?php
+
+/**
+ * Plugin Name: GLM WooCommerce Merchant e-Solutions Gateway
+ * Activate Plugin Tasks
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMerchantESolutions
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release activate.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Load glmPluginSupport class
+require_once (GLM_MES_PLUGIN_PATH . '/classes/glmPluginSupport.php');
+
+/*
+ * This class performs all necessary additional work when this
+ * plugin is activated.
+ *
+ * Currently the only actions are to add role capability to display and modify
+ * prototypes.
+ */
+class glmMesPluginActivate extends glmPluginSupport
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * Note that the $noDatabaseCheck is used to access the database versions
+ * without triggering a database check.
+ *
+ * Performs all the work for this model
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Make sure the current user has this capability
+ if (! current_user_can('activate_plugins')) {
+ $this->addNotice("Interesting, you don't have permission to activate plugins.");
+ die();
+ }
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /*
+ * Add a role capability to all current roles
+ *
+ * @param string $capability Name of capability to add
+ * @param string $default Whether capability should be on by default
+ *
+ * @return void
+ * @access private
+ */
+ private function addRoleCapability ($capability, $default)
+ {
+ // Get list of role objects
+ $roleObjects = $GLOBALS['wp_roles']->role_objects;
+
+ // Get list of roles we can edit
+ $roles = get_editable_roles();
+
+ // For each role object
+ foreach ($roleObjects as $key => $role) {
+
+ // Check if the role exists in list of editable roles and capability
+ // does not exist
+ if (isset($roles[$key]) && ! isset($role->capabilities[$capability])) {
+
+ // Add the role
+ $role->add_cap($capability, $default);
+ }
+ }
+ }
+
+
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Plugin support class
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release glmPluginSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+/*
+ * This class provides some standard methods used by this plugin
+ */
+class GlmPluginSupport
+{
+
+ /*
+ * Add a message to the 'glmMembersAdminNotices' option for output later.
+ *
+ * Messages that don't have a $type specified are displayed in
+ * the admin WordPress message area.
+ *
+ * Messages that have a $type are for the debug window and are categorized
+ * as follows and in this order in the debug window
+ * Alert Placed sequentially in the Alerts list
+ * Process Placed sequentially in the process list
+ * DataBlock Placed in a colored data block. Requires a $title
+ *
+ * @param string $message
+ * @param string $type
+ * @param string $title
+ *
+ * @return void
+ * @access public
+ */
+ public static function addNotice ($message, $type = false, $title = false)
+ {
+
+ switch($type) {
+
+ case 'Alert';
+ $alerts = get_option('glmMembersAdminNoticeAlerts');
+ $alerts[] = $message;
+ update_option('glmMembersAdminNoticeAlerts', $alerts);
+ break;
+
+ case 'Process';
+ $process = get_option('glmMembersAdminNoticeProcess');
+ $process[] = $message;
+ update_option('glmMembersAdminNoticeProcess', $process);
+ break;
+
+ case 'DataBlock';
+ $dataBlocks = get_option('glmMembersAdminNoticeDataBlocks');
+ $dataBlocks[] = array('data' => $message, 'title' => $title);
+ update_option('glmMembersAdminNoticeDataBlocks', $dataBlocks);
+ break;
+
+ default;
+ $notices = get_option('glmMembersAdminNotices');
+ $notices[] = $message;
+ update_option('glmMembersAdminNotices', $notices);
+ break;
+
+ }
+
+ }
+
+ /*
+ * Check if this is a second call to the activation hook by WordPress to activate this plugin.
+ *
+ * (Yea, I know that's stupid behavior, but there's nothing I can do about it.)
+ * It tells us this is happening by setting the 'action' GET parameter to 'error_scrape',
+ * which is also stupid.
+ *
+ * In this case, we don't want to try again, so output any saved notices from the first pass
+ * and then exit to tell WordPress the plugin didn't install.
+ *
+ * @return void
+ * @access public
+ */
+ public function checkErrorScrape()
+ {
+
+ // Check for 'action' = 'error_scrape', which indicates a second call from WordPress due to an error.
+ if (isset($_GET['action']) && $_GET['action'] == 'error_scrape') {
+
+ // Sleep for a bit to make sure the glmMembersAdminNotices option is set. (seems to need this)
+ sleep(1);
+
+ // if we have pending messages, display those
+ if (get_option('glmMembersAdminNotices')) {
+
+ glmMembersAdminNotices();
+
+ // Otherwise, there must have been some other error.
+ } else {
+
+ echo 'There has been an unknown error installing the Gaslight Media Members Database plugin.';
+
+ }
+
+ // Quit here so Wordpress doesn't mark plugin as activated or deactivated
+ exit;
+
+ }
+
+ }
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+;
+; Main Configuration File
+; GLM WooCommerce Merchant e-Solutions Gateway
+;
+; Custom configurations for development and developer configuration at bottom of file.
+;
+
+[common]
+
+;
+; Site Configuration Options
+;
+
+; Debug Options
+debug = false
+debug_verbose = false
+
+; Site Time Zone
+timezone = America/Detroit
+
+;
+; End of site configuration options
+;
+
+; Phrases
+phrase['phrase_test'] = 'test'
+
+;
+; Override sections for various servers by GLM_HOST_ID
+;
+
+[production:common]
+
+
+[development:common]
+
+
+[chuck:common]
+debug = true
+debug_verbose = false
+
--- /dev/null
+<?php
+
+/**
+ * Plugin Name: GLM WooCommerce Merchant e-Solutions Gateway
+ * Controller
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMerchantESolutions
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release controllers/controller.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Load glmPluginSupport class
+require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php');
+
+/*
+ * This class controls which models are used.
+ */
+class glmMesController extends GlmPluginSupport
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+
+ }
+
+ /**
+ * Controller
+ *
+ * @return void
+ * @access public
+ */
+ public function controller ()
+ {
+
+ }
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * Plugin Name: GLM WooCommerce Merchant e-Solutions Gateway
+ * Deactivate Plugin Tasks
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMerchantESolutions
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release deactivate.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Load glmPluginSupport class
+require_once (GLM_MES_PLUGIN_PATH . '/classes/glmPluginSupport.php');
+
+/*
+ * This class performs all necessary additional work when this
+ * plugin is deactivated.
+ */
+class glmMesPluginDeactivate extends glmPluginSupport
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * Performs all the work for this model
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Make sure the current user has this capability
+ if (!current_user_can('activate_plugins')) {
+ die();
+ }
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /*
+ * Remove a role capability from all current roles
+ *
+ * @param string $capability
+ *
+ * @return void
+ * @access public
+ */
+ public function removeRoleCapability ($capability)
+ {
+ // Get list of role objects
+ $roleObjects = $GLOBALS['wp_roles']->role_objects;
+
+ // Get list of roles we can edit
+ $roles = get_editable_roles();
+
+ // For each role object
+ foreach ($roleObjects as $key => $role) {
+ // Check if the role exists in list of editable roles and capability
+ // does not exist
+ if (isset($roles[$key]) && isset($role->capabilities[$capability])) {
+
+ // Remove role
+ $role->remove_cap($capability);
+ }
+ }
+ }
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Plugin Name: GLM WooCommerce Merchant e-Solutions Gateway
+ *
+ * Set standard defined parameters
+ */
+
+define('GLM_MES_PLUGIN_NAME', 'Gaslight Media WooCommerce Merchant e-Solutions Gateway');
+define('GLM_MES_PLUGIN_DIR', 'glm-woocommerce-merchant-e-solutions-gateway');
+
+// Determine which system we're running on - If not provided, assume PRODUCTION
+$host = getenv('GLM_HOST_ID');
+if (trim($host) == '') {
+ $host = 'PRODUCTION';
+}
+define('GLM_MES_PLUGIN_HOST', $host);
+
+// Determine current http/https protocol
+$pageProtocol = 'http';
+if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
+ $pageProtocol = 'https';
+}
+define('GLM_MES_PLUGIN_HTTP_PROTOCOL', $pageProtocol);
+
+// Plugin Versions
+define('GLM_MES_PLUGIN_VERSION', 0.1);
+define('GLM_MES_PLUGIN_DB_VERSION', 0.1);
+
+// URLs
+$adminURL = admin_url('admin.php');
+define('GLM_MES_PLUGIN_ADMIN_URL', $adminURL);
+define('GLM_MES_PLUGIN_URL', plugin_dir_url(__FILE__));
+$pageUri = explode('?', $_SERVER['REQUEST_URI']); // Bust this up to access URL path and script name only
+define('GLM_MES_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MES_PLUGIN_DIR);
+define('GLM_MES_PLUGIN_CURRENT_URL', $pageProtocol.'://'.$_SERVER['SERVER_NAME'].$pageUri[0]);
+define('GLM_MES_PLUGIN_MEDIA_URL', WP_CONTENT_URL.'/plugins/'.GLM_MES_PLUGIN_DIR.'/media');
+
+
+// Directories
+define('GLM_MES_PLUGIN_PATH', dirname(__FILE__));
+define('GLM_MES_PLUGIN_CLASS_PATH', GLM_MES_PLUGIN_PATH.'/classes');
+define('GLM_MES_PLUGIN_CONFIG_PATH', GLM_MES_PLUGIN_PATH.'/config');
+
+
+// Database table prefixes
+global $wpdb;
+define('GLM_MES_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_MES_');
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Plugin Name: GLM WooCommerce Merchant e-Solutions Gateway
+ * Plugin URI: http://www.gaslightmedia.com/
+ * Description: Gaslight Media Merchant e-Solutions support for WooCommerce
+ * Version: 1.0
+ * Author: Chuck Scott
+ * Author URI: http://www.gaslightmedia.com/
+ * License: GPL2
+ */
+
+/**
+ * Gaslight Media Merchant e-Solutions Gateway
+ * Index
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMerchantESolutions
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 1.0
+ */
+
+/*
+ * Copyright 2014-2015 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
+ */
+
+// Get standard defined parameters
+require_once('defines.php');
+
+// Get plugin configuration
+$configData = parse_ini_file(GLM_MES_PLUGIN_PATH.'/config/plugin.ini', true);
+$config = $configData['common'];
+
+// Override parameters according to GLM_HOST_ID
+$hostSection = strtolower(GLM_MES_PLUGIN_HOST).':common';
+if (isset($configData[$hostSection])) {
+ $config = array_replace($config, $configData[strtolower(GLM_MES_PLUGIN_HOST).':common']);
+} else {
+ $startupNotices .=
+ '<p><b>Bad configuration file section name or section not found:</b> '. $hostSection
+ .'<br>See plugin '.GLM_MES_PLUGIN_PATH.'config/plugin.ini file.'
+ .'<br>Also check that the server "GLM_HOST_ID" environment parameter exists and matches a section in the above ini file.</p>'
+ ;
+}
+
+// Add Debug defines - These can't go into the defines.php file - Guess why.
+define('GLM_MES_PLUGIN_ADMIN_DEBUG', $config['admin_debug']);
+define('GLM_MES_PLUGIN_ADMIN_DEBUG_VERBOSE', $config['admin_debug_verbose']);
+define('GLM_MES_PLUGIN_FRONT_DEBUG', $config['front_debug']);
+define('GLM_MES_PLUGIN_FRONT_DEBUG_VERBOSE', $config['front_debug_verbose']);
+
+// Also get image sizes array from the plugin.ini - uses separate ini section.
+$config['imageSizes'] = $configData['imageSizes'];
+
+// Get additional configuration data
+$stateData = parse_ini_file(GLM_MES_PLUGIN_PATH.'/config/states.ini');
+$config['states'] = $stateData['states'];
+$countryData = parse_ini_file(GLM_MES_PLUGIN_PATH.'/config/countries.ini');
+$config['countries'] = $countryData['countries'];
+
+
+/**
+ * *******************************************************************************
+ *
+ * *** Directory and File Structure ***
+ *
+ * index.php
+ *
+ * Index file for this plugin. All plugin processing starts here. (See
+ * "Process Flow" below.)
+ *
+ * ********************************************************************************
+ */
+
+/*
+ *
+ * Activate, Deactivate, Uninstall hooks
+ *
+ */
+
+// Activate
+function glmMesPluginActivate ()
+{
+ global $wpdb, $config;
+ require_once (GLM_MES_PLUGIN_PATH . '/activate.php');
+ new glmMesPluginActivate($wpdb, $config);
+}
+register_activation_hook(__FILE__, 'glmMesPluginActivate');
+
+// Deactivate
+function glmMesPluginDeactivate ()
+{
+ global $wpdb, $config;
+ require_once (GLM_MES_PLUGIN_PATH . '/deactivate.php');
+ $x = new glmMesPluginDeactivate($wpdb, $config);
+ return false;
+}
+register_deactivation_hook(__FILE__, 'glmMesPluginDeactivate');
+
+
+/*
+ *
+ * Load Controller
+ *
+ */
+
+ require_once (GLM_MES_PLUGIN_PATH . '/controllers/controller.php');
+ new glmMesController($wpdb, $config);
+
+
+/*
+ * Function to display admin notices.
+ *
+ * This function is only called using the add_action('admin_notices','...') function
+ * in the code below this function.
+ *
+ * @return void
+ * @access public
+ */
+function glmMesAdminNotices($windowed = false)
+{
+
+ $output = '';
+
+ // If windowed for debug, also include HTML header and stylesheet
+ if ($windowed) {
+
+ $output .= '
+ <html>
+ <head>
+ <link rel="stylesheet" href="'.GLM_MES_PLUGIN_URL.'/css/admin.css">
+ <head>
+ <body>
+ <a name="top"></a>
+ <div id="glm-debug-timestamp">'.date('m/d/Y G:i:s A').'</div>
+ <div id="glm-debug-header">'.GLM_MES_PLUGIN_NAME.' - Debug Data</div>
+ ';
+
+ // Display alerts
+ $alerts = get_option('glmMesAdminNoticeAlerts');
+ if(is_array($alerts)) {
+ $output .= '<div id="glm-debug-alerts" class="glm-error"><h2>Alerts</h2>';
+ foreach($alerts as $a) {
+ $output .= $a.'<br>';
+ }
+ } else {
+ $output .= '<div id="glm-debug-alerts"><h2>Alerts</h2>';
+ }
+ $output .= '</div><hr>';
+ delete_option('glmMesAdminNoticeAlerts');
+
+ // Display process messages
+ $process = get_option('glmMesAdminNoticeProcess');
+ $output .= '<div id="glm-debug-process"><h2>Processing</h2>';
+ if(is_array($process)) {
+ foreach($process as $p) {
+ $output .= $p.'<br>';
+ }
+ }
+ $output .= '</div><hr>';
+ delete_option('glmMesAdminNoticeProcess');
+
+ // Display data blocks table of contents then the data blocks
+ $dataBlocks = get_option('glmMesAdminNoticeDataBlocks');
+ $output .= '<div id="glm-debug-contents"><h2>Data Blocks</h2><ul>';
+ $n = 0;
+ if (is_array($dataBlocks)) {
+ foreach($dataBlocks as $d) {
+ $output .= '<li><a href="#'.++$n.'">'.$d['title'].'</a></li>';
+ }
+ }
+ $output .= '</ul></div><hr>';
+ if (is_array($dataBlocks)) {
+ reset($dataBlocks);
+ $n = 0;
+ foreach($dataBlocks as $d) {
+ $output .= '
+ <div style="margin-top: 2em;">
+ <div style="float: right;"><a href="#top">[Top]</a></div>
+ <div class="glm-debug-section-title"><a name="'.++$n.'"><h4>'.$d['title'].'</h4></a></div>
+ <div class="glm-debug-section-body"><pre>'.print_r($d['data'],1).'</pre></div>
+ </div>
+ ';
+ }
+ }
+ delete_option('glmMesAdminNoticeDataBlocks');
+
+ echo $output.'
+ </body>
+ </html>
+ ';
+
+ // Otherwise we're outputting data to the message block in the WordPress admin area
+ } else {
+
+ // Start with div class to output in standard admin notice block
+ $output .= '<div class="updated"><p>';
+
+ // Get the notice texts
+ $notices = get_option('glmMesAdminNotices');
+
+ if (is_array($notices) && count($notices) > 0) {
+
+ // For each notice retrieved
+ $br = '';
+ foreach($notices as $n) {
+
+ // Add the notice to the output
+ $output .= $br.$n;
+ $br = '<br>';
+ }
+
+ }
+
+ echo $output.'</p></div>';
+
+ // Delete the option containing the notices to indicate they have been sent
+ delete_option('glmMesAdminNotices');
+
+ }
+
+}
+
+/*
+ * Check if there's any startup notices in this file. (stuff that happens before we get all setup)
+ *
+ * If there is, have the message displayed at the top of the wp-admin content area.
+ */
+function glmMesStartupNotices() {
+ global $startupNotices;
+ echo '<div class="updated"><h3>'.GLM_MES_PLUGIN_NAME.' Plugin Warning</h3><p>'.$startupNotices.'</p></div>';
+}
+if ($startupNotices != '') {
+ add_action('admin_notices','glmMesStartupNotices');
+}
+
+/*
+ * Check if there's any debug information or other notices that need to be displayed
+ *
+ * If there is, display as a separate window.
+ *
+ * NOTE: Need to break out notices that should be displayed in the wp-admin content area. To
+ * do that I need to modify the glmMesAdminNotices function above and the
+ * addNotice() function in the classes/glmPluginSupport.php file. Should have addNotice()
+ * function be able to add to another option specifically for doing this.
+ */
+$notices = get_option('glmMesAdminNotices');
+if (is_admin() && $notices && !GLM_MES_PLUGIN_ADMIN_DEBUG) {
+
+ // Add action to output the notices
+ add_action('admin_notices','glmMesAdminNotices');
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database Plugin
+ * Uninstall Plugin
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Get setup and configuration
+require_once('defines.php');
+
+//if uninstall not called from WordPress exit
+if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
+ exit();
+
+// Delete options
+delete_option('glmMembersDatbasePluginVersion');
+delete_option('glmMembersDatabaseDbVersion');
+delete_option('glmMembersAdminNotices');
+
+// Same for Multi-site
+delete_site_option('glmMembersDatbasePluginVersion');
+delete_site_option('glmMembersDatabaseDbVersion');
+delete_site_option('glmMembersAdminNotices');
+
+/*
+ * Drop database tables
+ */
+// Set current database version
+$dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
+
+// Read in Database deletion script - assumes the current db version.
+$sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/drop_database_V'.$dbVersion.'.sql';
+$sql = file_get_contents($sqlFile);
+
+// Replace {prefix} with table name prefix
+$sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
+
+// Removing the tables using the script
+global $wpdb;
+$wpdb->query($sql);
+
+?>
\ No newline at end of file