From 4dfb38e5a18cec5204c6b14a892ca9af8885365a Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 5 May 2015 13:44:55 -0400 Subject: [PATCH] Unknown. --- activate.php | 2 +- glm-member-db.php | 411 ++++++++++++++++++++++++++++++++++++++++++++++ index.php | 411 +--------------------------------------------- 3 files changed, 413 insertions(+), 411 deletions(-) create mode 100644 glm-member-db.php diff --git a/activate.php b/activate.php index 71f7b731..181752a1 100644 --- a/activate.php +++ b/activate.php @@ -10,7 +10,7 @@ * @package glmMembersDatabase * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @release activate.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ diff --git a/glm-member-db.php b/glm-member-db.php new file mode 100644 index 00000000..ee289df4 --- /dev/null +++ b/glm-member-db.php @@ -0,0 +1,411 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 1.0 + */ + +/* + * 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 + */ + +$startupNotices = ''; + +// Get standard defined parameters +require_once('defines.php'); + +// Get plugin configuration +$configData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/plugin.ini', true); +$config = $configData['common']; +// Override parameters according to GLM_HOST_ID +$hostSection = strtolower(GLM_MEMBER_PLUGIN_HOST).':common'; +if (isset($configData[$hostSection])) { + $config = array_replace($config, $configData[strtolower(GLM_MEMBER_PLUGIN_HOST).':common']); +} else { + $startupNotices .= + '

Bad configuration file section name or section not found: '. $hostSection + .'
See plugin '.GLM_MEMBERS_PLUGIN_PATH.'config/plugin.ini file.' + .'
Also check that the server "GLM_HOST_ID" environment parameter exists and matches a section in the above ini file.

' + ; +} + +// 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']); +define('GLM_MEMBERS_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_MEMBERS_PLUGIN_PATH.'/config/states.ini'); +$config['states'] = $stateData['states']; +$countryData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/countries.ini'); +$config['countries'] = $countryData['countries']; + +// Try to set the DB version option to false (new plugin) - If it's already set this won't do anything. +add_option('glmMembersDatabaseDbVersion', false); + +// Custom plugin post type (for wp_post entries) +// define('GLM_MEMBERS_PLUGIN_POST_TYPE', ''); + + +/** + * ******************************************************************************* + * + * *** Directory and File Structure *** + * + * index.php + * + * Index file for this plugin. All plugin processing starts here. (See + * "Process Flow" below.) + * + * controllers + * + * Directory containing any controllers. Typically there + * would be admin and front controllers in this directory. + * These controllers do the general setup for the plugin, + * determine and call the appropriate model, determine the + * appropriate view, then merge any data returned by the model + * with the view and output the result as appropriate. + * + * When executed, a model may determine that it cannot handle + * the current request and return such a notice to the controller + * possibly with a suggested model to execute. Models may also + * return a desired view back to the controller based on the + * result of processing, but should do so in a generic way so + * as to permit multi-lingual output and use of multiple "skins" + * (but not to the exception of appropriate use of WordPress + * Themes). + * + * css + * + * Directory containing any css files specific to this plugin. + * The use of additional styling should be kept to a minimum + * so as to not interfere with the application of WordPress + * default styling and Themes. + * + * js + * + * Directory containing any JAVAscript files specific to this + * Plugin. This directory should be reserved for general script + * files that provide functionality that can be used in various + * views. Any JAVAscript that is specific to a view should be + * located along with the associated view as it is logically + * part of the view. + * + * lib + * + * Directory containing any class or function libraries that + * are used generally by this plugin. Any class or other code + * that is specific to a particular model should be located + * in, or along with, that model since it is logically + * associated only with that model. + * + * misc + * + * Directory containing ancillary directories and files. This + * might be used for things like cach directories. An example + * might be the "smarty" directory for Smaarty Templates. + * + * models + * + * Directory containing model files that execute a specific + * process in this plugin. If this is a simple plugin, then + * the model files can be placed directly in this directory. + * If it's a more complex plugin, then there should be sub- + * directories for various groupings of related model files. + * + * An individual model may consist of a grouping of files, + * such as additional class files, that are specific only to + * that model. In that case, these should be located in a + * subdirectory under where the model file called by the + * controller is located and that directory should be named + * so as to be obviously associated with that model. + * + * There are three special files in the models directory. These + * are activate.php, deactivate.php, and uninstall.php. These + * are called via hooks setup in this file and should always + * be here. If they do not provide any real functionality, they + * should at least be a shell that can be called for those + * situations. + * + * views + * + * Directory containing view files for producing output upon + * request of a model file in the models directory. If this + * is a simply plugin, then the view files can be placed + * directly in this directory. If it's a more complex plugin, + * then there should be sub-directories for the various + * groupings of related view files. If using sub-directories, + * those should generally match the associated model directories. + * It may also be wise to use separate front and admin + * directories under views to keep things organized. + * + * Additionally, views may be grouped in such a way that they + * support the selection of various "skins" that output in + * different ways, although any styling should be provided by + * WordPress Themes or use default WordPress styling. + * + * *** Process Flow *** + * + * WordPress calls the plugin index file. All plugin processing starts here. + * + * The plugin index file performs the following operations ... + * - Sets-up any required plugin-wide defines and data + * - Instatiates any plugin-wide classes and objects + * - Sets-up any plugin-wide WordPress hooks + * - Determines which controller is to be executed + * - Executes the selected controller + * + * The selected controller performs the following operations ... + * - Sets-up any controller specific defines and data + * - Instatiates any controller specific classes and objects + * - Sets-up any controller specific WordPress hooks + * - Determines which model process is to be executed + * - Executes the selected model + * + * The selected model performs the following operations ... + * - Sets-up any model specific defines and data + * - Instatiates any model specific classes and objects + * - Sets-up any model specific WordPress hooks + * - Performs any specific processing required of the model + * - Determines which view is to be used to generate output + * - Generates output based on model data and the selected view + * + * WordPress wraps everything up + * + * ******************************************************************************** + */ + +/* + * + * Activate, Deactivate, Uninstall hooks + * + */ + +// Activate +function glmMembersPluginActivate () +{ + global $wpdb, $config; + require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php'); + new glmMembersPluginActivate($wpdb, $config); +} +register_activation_hook(__FILE__, 'glmMembersPluginActivate'); + +// Deactivate +function glmMembersPluginDeactivate () +{ + global $wpdb, $config; + require_once (GLM_MEMBERS_PLUGIN_PATH . '/deactivate.php'); + $x = new glmMembersPluginDeactivate($wpdb, $config); + return false; +} +register_deactivation_hook(__FILE__, 'glmMembersPluginDeactivate'); + +// Uninstall - Not using. Using "uninstall.php" in the root directory of this plugin. + +/* + * + * Load any other common files needed + * + */ + +// Load data abstract +require_once(GLM_MEMBERS_PLUGIN_LIB_PATH.'/GlmDataAbstract/DataAbstract.php'); + +/* + * + * Determine which controller to load + * + * The first is for displaying notices in another window, possibly for debug output. + * + */ +if (isset($_REQUEST['glmDebugWindow']) && $_REQUEST['glmDebugWindow'] == true) { + glmMembersAdminNotices(true); + exit; +} elseif (is_admin()) { + require_once (GLM_MEMBERS_PLUGIN_PATH . '/controllers/admin.php'); + new glmMembersAdmin($wpdb, $config); +} else { + require_once (GLM_MEMBERS_PLUGIN_PATH . '/controllers/front.php'); + new glmMembersFront($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 glmMembersAdminNotices($windowed = false) +{ + + $output = ''; + + // If windowed for debug, also include HTML header and stylesheet + if ($windowed) { + + $output .= ' + + + + + + +
'.date('m/d/Y G:i:s A').'
+
'.GLM_MEMBERS_PLUGIN_NAME.' - Debug Data
+ '; + + // Display alerts + $alerts = get_option('glmMembersAdminNoticeAlerts'); + if(is_array($alerts)) { + $output .= '

Alerts

'; + foreach($alerts as $a) { + $output .= $a.'
'; + } + } else { + $output .= '

Alerts

'; + } + $output .= '

'; + delete_option('glmMembersAdminNoticeAlerts'); + + // Display process messages + $process = get_option('glmMembersAdminNoticeProcess'); + $output .= '

Processing

'; + if(is_array($process)) { + foreach($process as $p) { + $output .= $p.'
'; + } + } + $output .= '

'; + delete_option('glmMembersAdminNoticeProcess'); + + // Display data blocks table of contents then the data blocks + $dataBlocks = get_option('glmMembersAdminNoticeDataBlocks'); + $output .= '

Data Blocks

    '; + $n = 0; + if (is_array($dataBlocks)) { + foreach($dataBlocks as $d) { + $output .= '
  • '.$d['title'].'
  • '; + } + } + $output .= '

'; + if (is_array($dataBlocks)) { + reset($dataBlocks); + $n = 0; + foreach($dataBlocks as $d) { + $output .= ' +
+
[Top]
+ +
'.print_r($d['data'],1).'
+
+ '; + } + } + delete_option('glmMembersAdminNoticeDataBlocks'); + + echo $output.' + + + '; + + // 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 .= '

'; + + // Get the notice texts + $notices = get_option('glmMembersAdminNotices'); + + 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 = '
'; + } + + } + + echo $output.'

'; + + // Delete the option containing the notices to indicate they have been sent + delete_option('glmMembersAdminNotices'); + + } + +} + +/* + * 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 glmMembersStartupNotices() { + global $startupNotices; + echo '

'.GLM_MEMBERS_PLUGIN_NAME.' Plugin Warning

'.$startupNotices.'

'; +} +if ($startupNotices != '') { + add_action('admin_notices','glmMembersStartupNotices'); +} + +/* + * 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 glmMembersAdminNotices 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('glmMembersAdminNotices'); +if (is_admin() && $notices && !GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + + // Add action to output the notices + add_action('admin_notices','glmMembersAdminNotices'); + +} + +?> \ No newline at end of file diff --git a/index.php b/index.php index ee289df4..7e914158 100644 --- a/index.php +++ b/index.php @@ -1,411 +1,2 @@ - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0 - */ - -/* - * 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 - */ - -$startupNotices = ''; - -// Get standard defined parameters -require_once('defines.php'); - -// Get plugin configuration -$configData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/plugin.ini', true); -$config = $configData['common']; -// Override parameters according to GLM_HOST_ID -$hostSection = strtolower(GLM_MEMBER_PLUGIN_HOST).':common'; -if (isset($configData[$hostSection])) { - $config = array_replace($config, $configData[strtolower(GLM_MEMBER_PLUGIN_HOST).':common']); -} else { - $startupNotices .= - '

Bad configuration file section name or section not found: '. $hostSection - .'
See plugin '.GLM_MEMBERS_PLUGIN_PATH.'config/plugin.ini file.' - .'
Also check that the server "GLM_HOST_ID" environment parameter exists and matches a section in the above ini file.

' - ; -} - -// 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']); -define('GLM_MEMBERS_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_MEMBERS_PLUGIN_PATH.'/config/states.ini'); -$config['states'] = $stateData['states']; -$countryData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/countries.ini'); -$config['countries'] = $countryData['countries']; - -// Try to set the DB version option to false (new plugin) - If it's already set this won't do anything. -add_option('glmMembersDatabaseDbVersion', false); - -// Custom plugin post type (for wp_post entries) -// define('GLM_MEMBERS_PLUGIN_POST_TYPE', ''); - - -/** - * ******************************************************************************* - * - * *** Directory and File Structure *** - * - * index.php - * - * Index file for this plugin. All plugin processing starts here. (See - * "Process Flow" below.) - * - * controllers - * - * Directory containing any controllers. Typically there - * would be admin and front controllers in this directory. - * These controllers do the general setup for the plugin, - * determine and call the appropriate model, determine the - * appropriate view, then merge any data returned by the model - * with the view and output the result as appropriate. - * - * When executed, a model may determine that it cannot handle - * the current request and return such a notice to the controller - * possibly with a suggested model to execute. Models may also - * return a desired view back to the controller based on the - * result of processing, but should do so in a generic way so - * as to permit multi-lingual output and use of multiple "skins" - * (but not to the exception of appropriate use of WordPress - * Themes). - * - * css - * - * Directory containing any css files specific to this plugin. - * The use of additional styling should be kept to a minimum - * so as to not interfere with the application of WordPress - * default styling and Themes. - * - * js - * - * Directory containing any JAVAscript files specific to this - * Plugin. This directory should be reserved for general script - * files that provide functionality that can be used in various - * views. Any JAVAscript that is specific to a view should be - * located along with the associated view as it is logically - * part of the view. - * - * lib - * - * Directory containing any class or function libraries that - * are used generally by this plugin. Any class or other code - * that is specific to a particular model should be located - * in, or along with, that model since it is logically - * associated only with that model. - * - * misc - * - * Directory containing ancillary directories and files. This - * might be used for things like cach directories. An example - * might be the "smarty" directory for Smaarty Templates. - * - * models - * - * Directory containing model files that execute a specific - * process in this plugin. If this is a simple plugin, then - * the model files can be placed directly in this directory. - * If it's a more complex plugin, then there should be sub- - * directories for various groupings of related model files. - * - * An individual model may consist of a grouping of files, - * such as additional class files, that are specific only to - * that model. In that case, these should be located in a - * subdirectory under where the model file called by the - * controller is located and that directory should be named - * so as to be obviously associated with that model. - * - * There are three special files in the models directory. These - * are activate.php, deactivate.php, and uninstall.php. These - * are called via hooks setup in this file and should always - * be here. If they do not provide any real functionality, they - * should at least be a shell that can be called for those - * situations. - * - * views - * - * Directory containing view files for producing output upon - * request of a model file in the models directory. If this - * is a simply plugin, then the view files can be placed - * directly in this directory. If it's a more complex plugin, - * then there should be sub-directories for the various - * groupings of related view files. If using sub-directories, - * those should generally match the associated model directories. - * It may also be wise to use separate front and admin - * directories under views to keep things organized. - * - * Additionally, views may be grouped in such a way that they - * support the selection of various "skins" that output in - * different ways, although any styling should be provided by - * WordPress Themes or use default WordPress styling. - * - * *** Process Flow *** - * - * WordPress calls the plugin index file. All plugin processing starts here. - * - * The plugin index file performs the following operations ... - * - Sets-up any required plugin-wide defines and data - * - Instatiates any plugin-wide classes and objects - * - Sets-up any plugin-wide WordPress hooks - * - Determines which controller is to be executed - * - Executes the selected controller - * - * The selected controller performs the following operations ... - * - Sets-up any controller specific defines and data - * - Instatiates any controller specific classes and objects - * - Sets-up any controller specific WordPress hooks - * - Determines which model process is to be executed - * - Executes the selected model - * - * The selected model performs the following operations ... - * - Sets-up any model specific defines and data - * - Instatiates any model specific classes and objects - * - Sets-up any model specific WordPress hooks - * - Performs any specific processing required of the model - * - Determines which view is to be used to generate output - * - Generates output based on model data and the selected view - * - * WordPress wraps everything up - * - * ******************************************************************************** - */ - -/* - * - * Activate, Deactivate, Uninstall hooks - * - */ - -// Activate -function glmMembersPluginActivate () -{ - global $wpdb, $config; - require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php'); - new glmMembersPluginActivate($wpdb, $config); -} -register_activation_hook(__FILE__, 'glmMembersPluginActivate'); - -// Deactivate -function glmMembersPluginDeactivate () -{ - global $wpdb, $config; - require_once (GLM_MEMBERS_PLUGIN_PATH . '/deactivate.php'); - $x = new glmMembersPluginDeactivate($wpdb, $config); - return false; -} -register_deactivation_hook(__FILE__, 'glmMembersPluginDeactivate'); - -// Uninstall - Not using. Using "uninstall.php" in the root directory of this plugin. - -/* - * - * Load any other common files needed - * - */ - -// Load data abstract -require_once(GLM_MEMBERS_PLUGIN_LIB_PATH.'/GlmDataAbstract/DataAbstract.php'); - -/* - * - * Determine which controller to load - * - * The first is for displaying notices in another window, possibly for debug output. - * - */ -if (isset($_REQUEST['glmDebugWindow']) && $_REQUEST['glmDebugWindow'] == true) { - glmMembersAdminNotices(true); - exit; -} elseif (is_admin()) { - require_once (GLM_MEMBERS_PLUGIN_PATH . '/controllers/admin.php'); - new glmMembersAdmin($wpdb, $config); -} else { - require_once (GLM_MEMBERS_PLUGIN_PATH . '/controllers/front.php'); - new glmMembersFront($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 glmMembersAdminNotices($windowed = false) -{ - - $output = ''; - - // If windowed for debug, also include HTML header and stylesheet - if ($windowed) { - - $output .= ' - - - - - - -
'.date('m/d/Y G:i:s A').'
-
'.GLM_MEMBERS_PLUGIN_NAME.' - Debug Data
- '; - - // Display alerts - $alerts = get_option('glmMembersAdminNoticeAlerts'); - if(is_array($alerts)) { - $output .= '

Alerts

'; - foreach($alerts as $a) { - $output .= $a.'
'; - } - } else { - $output .= '

Alerts

'; - } - $output .= '

'; - delete_option('glmMembersAdminNoticeAlerts'); - - // Display process messages - $process = get_option('glmMembersAdminNoticeProcess'); - $output .= '

Processing

'; - if(is_array($process)) { - foreach($process as $p) { - $output .= $p.'
'; - } - } - $output .= '

'; - delete_option('glmMembersAdminNoticeProcess'); - - // Display data blocks table of contents then the data blocks - $dataBlocks = get_option('glmMembersAdminNoticeDataBlocks'); - $output .= '

Data Blocks

    '; - $n = 0; - if (is_array($dataBlocks)) { - foreach($dataBlocks as $d) { - $output .= '
  • '.$d['title'].'
  • '; - } - } - $output .= '

'; - if (is_array($dataBlocks)) { - reset($dataBlocks); - $n = 0; - foreach($dataBlocks as $d) { - $output .= ' -
- - -
'.print_r($d['data'],1).'
-
- '; - } - } - delete_option('glmMembersAdminNoticeDataBlocks'); - - echo $output.' - - - '; - - // 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 .= '

'; - - // Get the notice texts - $notices = get_option('glmMembersAdminNotices'); - - 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 = '
'; - } - - } - - echo $output.'

'; - - // Delete the option containing the notices to indicate they have been sent - delete_option('glmMembersAdminNotices'); - - } - -} - -/* - * 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 glmMembersStartupNotices() { - global $startupNotices; - echo '

'.GLM_MEMBERS_PLUGIN_NAME.' Plugin Warning

'.$startupNotices.'

'; -} -if ($startupNotices != '') { - add_action('admin_notices','glmMembersStartupNotices'); -} - -/* - * 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 glmMembersAdminNotices 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('glmMembersAdminNotices'); -if (is_admin() && $notices && !GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - - // Add action to output the notices - add_action('admin_notices','glmMembersAdminNotices'); - -} - -?> \ No newline at end of file +// Silence is golden. \ No newline at end of file -- 2.17.1