if (!$noDatabaseCheck) {
- // Check the database and permit installation of a new database if it doesn't exist;
+ // Check the database and permit installation of a new database tables if they doesn't exist and any updates
if (!$this->checkDatabase('install')) {
-
- // There was some kind of dataase failure, so die to prevent WordPress from marking plugin as activated.
- die();
-
+ // There was some kind of database failure, this is fatal so die
+ die('Database check failure');
}
// Check for plugin uploads directory
class GlmPluginSupport
{
- /**
- * Plugin Versions
- *
- * An array of past and current Member Database versions.
- * Note that Database Versions match plugin versions.
- *
- * Each entry below uses a key so code can find data on
- * a specific version and in the values are the version
- * again and the proper number of tables that should
- * exist with that version.
- *
- * @var $Versions
- * @access private
- */
- public $dbVersions = array(
- '0.1' => array('version' => '0.1', 'tables' => 26),
- '1.0.28' => array('version' => '1.0.28', 'tables' => 26),
- '1.0.30' => array('version' => '1.0.30', 'tables' => 26),
- '1.0.43' => array('version' => '1.0.43', 'tables' => 26)
- );
-
/*
* Add a message to the 'glmMembersAdminNotices' option for output later.
*
* @param string $option Set to 'install' to permit installation of the database.
* @param string $default Whether capability should be on by default
*
- * @return void
+ * @return boolean False if some failure
* @access private
*/
public function checkDatabase ($option = false)
{
- $dbVersion = get_option('glmMembersDatabaseDbVersion');
- $db_setup_status = false;
-
- // Do a quick check for there being a database version but not all the required tables for that version
- if ($dbVersion) {
-
- // Check if the database version set for this plugin is invalid.
- if (!isset($this->dbVersions[$dbVersion])) {
- update_option('glmMembersInstallErrors', "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.");
- return false;
- }
-
- // Get the number of tables for this plugin database version that should exist.
- $tables = $this->dbVersions[$dbVersion]['tables'];
-
- // Get the number of tables for this plugin that do currently exist.
- $existingTables = $this->wpdb->get_var("
- SELECT COUNT(*)
- FROM information_schema.tables
- WHERE table_schema = '".DB_NAME."'
- AND table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
- ");
-
- // If there's no tables, just assume we need to install all new ones.
- if ($existingTables == 0) {
- $dbVersion = false;
-
- // Otherwise check if the number of tables is correct
- } elseif ($tables != $existingTables) {
- update_option('glmMembersInstallErrors', 'We do not have the correct number of tables for the currently set database version (V'.$dbVersion.') for '.GLM_MEMBERS_PLUGIN_NAME.'.'
- ."<br>There should be $tables but there are currently $existingTables. Please call for support."
- );
- return false;
- }
-
- }
-
- // If glmMembersDatabaseDbVersion is not set, install current version
- if (!$dbVersion) {
+ $all_db_setup_status = true;
- // If $option is not 'install', then don't do it;
- if ($option != 'install') {
- return false;
- }
-
- // Get current database version
- $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
+ // For each plug-in in the registered add-on array (includes the main plugin)
+ foreach ($this->config['addOns'] as $a) {
- // Read in Database creation script
- $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/create_database_V'.$dbVersion.'.sql';
- $sql = file_get_contents($sqlFile);
+ $db_setup_status = false;
- // Replace {prefix} with table name prefix
- $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
+ // Has this plug-in registered any database versions
+ if ($a['database']) {
- // Split script into separate queries by looking for lines with only "---"
- $queries = preg_split('/^----$/m', $sql);
+ $dbVersion = get_option($a['database']['dbActiveVersionOption']);
- // Try executing all queries to build database
- do {
- $q = current($queries);
- $this->wpdb->query($q);
- $queryError = $this->wpdb->last_error;
- } while ($queryError == '' && next($queries));
+ // Do a quick check for there being a database version but not all the required tables for that version
+ if ($dbVersion) {
- // If there were no errors
- if (trim($queryError) == '') {
+ // Check if the database version set for this plug-in is invalid.
+ if (!isset($a['database']['dbVersions'][$dbVersion])) {
- // Notify the user that the database has been installed
- update_option('glmMembersInstallErrors', 'New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.');
+ update_option(
+ 'glmMembersInstallErrors',
+ "The last database version set for the ".$a['name']." (V$dbVersion) isn't valid.");
+ return false;
+ }
- // Save the version of the installed database
- update_option('glmMembersDatabaseDbVersion', $ver);
+ // Get the number of tables for this plugin database version that should exist.
+ $tables = $a['database']['dbVersions'][$dbVersion]['tables'];
- // Indicate that we were successfull
- $db_setup_status = true;
+ // Since MYSQL considers an "_" to be a single character wild-card, we need to escape them.
+ $prefixEscaped = str_replace('_', '\_', $a['database']['dbPrefix']);
- } else {
- update_option('glmMembersInstallErrors', 'Failure installing database tables for the '.GLM_MEMBERS_PLUGIN_NAME
- .'<br><b>Database Installation Error:</b> '.print_r($queryError,1)
- .'<br><pre>'.$q.'</pre>'
- );
- }
+ // Get the number of tables for this plugin that do currently exist.
+ $existingTables = $this->wpdb->get_var("
+ SELECT COUNT(*)
+ FROM information_schema.tables
+ WHERE table_schema = '".DB_NAME."'
+ AND table_name like '$prefixEscaped%';
+ ");
- // Otherwise, check if we need to update the database
- } elseif ($dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) {
+ // If there's no tables, just assume we need to install all new ones.
+ if ($existingTables == 0) {
- // Include an admin message that we're updating the database
- $this->addNotice('<b>The '.GLM_MEMBERS_PLUGIN_NAME.' database tables require updating...</b>');
+ $dbVersion = false;
- // Check if current glmMembersDatabaseDbVersion is invalid
- if (!in_array(GLM_MEMBERS_PLUGIN_DB_VERSION, $this->dbVersions)) {
- $this->addNotice('The database version currently installed for this plugin is unknown. '
- .'Unable to install/update the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.<br>');
- }
+ // Otherwise check if the number of tables is correct
+ } elseif ($tables != $existingTables) {
+ update_option('glmMembersInstallErrors', 'We do not have the correct number of tables for the currently set database version (V'.$dbVersion.') for '.$a['name'].'.'
+ ."<br>There should be $tables but there are currently $existingTables. Please call for support."
+ );
+ return false;
+ }
- // Traverse version list to find any required updates
- $curVerFound = false;
- $db_setup_status = true;
- foreach($this->dbVersions as $version) {
+ }
- $ver = $version['version'];
+ // If glmMembersDatabaseDbVersion is not set, install current version
+ if (!$dbVersion) {
- // Find the current version of the database
- if ($ver == $dbVersion) {
-// $this->addNotice('The database version installed for the '.GLM_MEMBERS_PLUGIN_NAME
-// .' plugin is current and does not require updating.');
- $db_setup_status = true;
- $curVerFound = true;
+ // If $option is not 'install', then don't do it;
+ if ($option != 'install') {
+ return false;
+ }
- // Otherwise if it's already been found and $ver is not the new target version
- } elseif ($curVerFound && $dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) {
+ // Get current database version
+ $dbVersion = $a['database']['dbCurrentVersion'];
// Read in Database creation script
- $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$ver.'.sql';
+ $sqlFile = $a['database']['dbScriptPath'].'/create_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);
+ $sql = str_replace('{prefix}', $a['database']['dbPrefix'], $sql);
// Split script into separate queries by looking for lines with only "---"
$queries = preg_split('/^----$/m', $sql);
- // Try executing all queries to update database
+ // Try executing all queries to build database
do {
$q = current($queries);
$this->wpdb->query($q);
$queryError = $this->wpdb->last_error;
} while ($queryError == '' && next($queries));
- // Check for PHP script to update database
- $phpScript = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$ver.'.php';
+ // If there were no errors
+ if (trim($queryError) == '') {
- if (is_file($phpScript)) {
- include ($phpScript);
- }
+ // Notify the user that the database has been installed
+ update_option('glmMembersInstallErrors', 'New database tables installed for the '.$a['name'].' plugin.');
+
+ // Save the version of the installed database
+ update_option($a['database']['dbActiveVersionOption'], $dbVersion);
+
+ // Indicate that we were successfull
+ $db_setup_status = true;
- // If there were no errors
- if ($queryError == '') {
- $this->addNotice('The database for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin has been updated '
- .'from V'.$dbVersion.'_V'.$ver.'.');
} else {
- $this->addNotice('Failure updating the database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin '
- .'from V'.$dbVersion.'_V'.$ver.'.');
- $db_setup_status = false;
- $this->addNotice('<b>Database Update Error:</b> '.$queryError, 'Alert');
+ update_option('glmMembersInstallErrors', 'Failure installing database tables for the '.$a['name']
+ .'<br><b>Database Installation Error:</b> '.print_r($queryError,1)
+ .'<br><pre>'.$q.'</pre>'
+ );
+ }
+
+ // Otherwise, check if we need to update the database
+ } elseif ($dbVersion != $a['database']['dbCurrentVersion']) {
+
+ // Include an admin message that we're updating the database
+ $this->addNotice('<b>The '.$a['name'].' database tables require updating...</b>');
+
+ // Check if current glmMembersDatabaseDbVersion is invalid
+ if (!in_array($a['database']['dbCurrentVersion'], $a['database']['dbVersions'])) {
+ $this->addNotice('The database version currently installed for this plugin is unknown. '
+ .'Unable to install/update the '.$a['name'].' plugin.<br>');
}
- $dbVersion = $ver;
+ // Traverse version list to find any required updates
+ $curVerFound = false;
$db_setup_status = true;
+ foreach($a['database']['dbVersions'] as $version) {
- }
+ $ver = $version['version'];
+
+ // Find the current version of the database
+ if ($ver == $dbVersion) {
+ // $this->addNotice('The database version installed for the '.GLM_MEMBERS_PLUGIN_NAME
+ // .' plugin is current and does not require updating.');
+ $db_setup_status = true;
+ $curVerFound = true;
+
+ // Otherwise if it's already been found and $ver is not the new target version
+ } elseif ($curVerFound && $dbVersion != $a['database']['dbCurrentVersion']) {
+
+ // Read in Database creation script
+ $sqlFile = $a['database']['dbScriptPath'].'/update_database_V'.$ver.'.sql';
+ $sql = file_get_contents($sqlFile);
+
+ // Replace {prefix} with table name prefix
+ $sql = str_replace('{prefix}', $a['database']['dbPrefix'], $sql);
+
+ // Split script into separate queries by looking for lines with only "---"
+ $queries = preg_split('/^----$/m', $sql);
+
+ // Try executing all queries to update database
+ do {
+ $q = current($queries);
+ $this->wpdb->query($q);
+ $queryError = $this->wpdb->last_error;
+ } while ($queryError == '' && next($queries));
+
+ // Check for PHP script to update database
+ $phpScript = $a['database']['dbScriptPath'].'/update_database_V'.$ver.'.php';
+
+ if (is_file($phpScript)) {
+ include ($phpScript);
+ }
+
+ // If there were no errors
+ if ($queryError == '') {
+ $this->addNotice('The database for the '.$a['name'].' plugin has been updated '
+ .'from V'.$dbVersion.'_V'.$ver.'.');
+ } else {
+ $this->addNotice('Failure updating the database tables for the '.$a['name'].' plugin '
+ .'from V'.$dbVersion.'_V'.$ver.'.');
+ $db_setup_status = false;
+ $this->addNotice('<b>Database Update Error:</b> '.$queryError, 'Alert');
+ }
- // Save the new version. If we've had a problem updating the database, then stop here.
- if ($db_setup_status) {
+ $dbVersion = $ver;
+ $db_setup_status = true;
- // Save the version of the installed database
- update_option('glmMembersDatabaseDbVersion', $dbVersion);
+ }
+
+ // Save the new version. If we've had a problem updating the database, then stop here.
+ if ($db_setup_status) {
+
+ // Save the version of the installed database
+ update_option($a['database']['dbActiveVersionOption'], $dbVersion);
+
+ } else {
+ break;
+ }
+
+ }
+
+ if ($db_setup_status) {
+
+ // Save the updated version of the installed database
+ // update_option('glmMembersDatabaseDbVersion', $dbVersion);
+
+ $this->addNotice('<b>Database tables updated.</b>');
+ }
} else {
- break;
+ $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.');
+ $db_setup_status = true;
}
- }
+ } else { // Plugin doesn't have registered database versions
- if ($db_setup_status) {
+ $db_setup_status = true;
- // Save the updated version of the installed database
- // update_option('glmMembersDatabaseDbVersion', $dbVersion);
+ } // Plugin has registered database versions
- $this->addNotice('<b>Database tables updated.</b>');
+ if (!$db_setup_status) {
+ $all_db_setup_status = false;
}
+ } // For each plugin
- } else {
- $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.');
- $db_setup_status = true;
- }
-
- return $db_setup_status;
+ return $all_db_setup_status;
}
}
$this->config = $config;
// Check the database
- $this->checkDatabase();
+ if (!$this->checkDatabase('install')) {
+
+ // There was some kind of dataase failure, so die to prevent WordPress from marking plugin as activated.
+ die();
+
+ }
/*
* Check if there's a request to bypass the WordPress Dashboard and
trigger_error ( 'ERROR: No "glm_action" itme in POST array.', E_USER_ERROR);
}
- // Check for a valid action
- if (!isset($GLOBALS['glmMembersValidActions']['adminActions']['ajax'][$glmAction])) {
+ // Check for a valid action. This only looks in the main plugin. Might have to change this later.
+ if (!$this->config['addOns'][GLM_MEMBERS_PLUGIN_SLUG]['adminActions']['ajax'][$glmAction]) {
// Menu item/Action not in valid actions array
trigger_error ( 'ERROR: The specified action is not valid - '.$glmAction, E_USER_ERROR);
);
}
- // For each add-on, read in their menu additions
+ // For each add-on, read in their menu additions - These are optional files
foreach ($this->config['addOns'] as $a) {
- require_once(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php');
- require_once(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminTabs.php');
+ if (is_file(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php')) {
+ require_once(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php');
+ }
+ if (is_file(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminTabs.php')) {
+ require_once(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminTabs.php');
+ }
}
}
// Loop till we have a final action
$loopCheck = 0;
+ $loopTracking = "<p>Menu: $menuItem, Action = $action</p>";
$actionData = false;
do {
$modelRedirect = false;
// Verify that we have the requested menu item in the valid actions
- if (!isset($GLOBALS['glmMembersValidActions']['adminActions'][$menuItem])) {
+ if (!isset($this->config['validActions']['adminActions'][$menuItem])) {
if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
$this->addNotice('<b>Error in Admin Controller:</b> Menu Item not specified!', 'Alert');
$action = 'index';
$errorMsg .= "<b>Menu not in valid list:</b> ".$menuItem;
+ $loopTracking .= "<p>*** Failed checking for valid menu selection ***</p>";
}
// Verify Menu item and action using array at top of this file
- if (! isset($GLOBALS['glmMembersValidActions']['adminActions'][$menuItem]) ||
- ! isset($GLOBALS['glmMembersValidActions']['adminActions'][$menuItem][$action])) {
+ if (! isset($this->config['validActions']['adminActions'][$menuItem]) ||
+ ! isset($this->config['validActions']['adminActions'][$menuItem][$action])) {
if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
$this->addNotice('<b>Error in Admin Controller:</b> Requested Menu Item is invalid! - '.$menuItem, 'Alert');
$menuItem = 'error';
$action = 'badAction';
+
+ $loopTracking .= "<p>*** Failed checking for valid menu action ***</p>";
+
}
/*
*/
// Get name of plugin where model and view are located
- $plugIn = $GLOBALS['glmMembersValidActions']['adminActions'][$menuItem][$action];
+ $plugIn = $this->config['validActions']['adminActions'][$menuItem][$action];
// Build model and path and class names
$modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/admin/$menuItem/$action.php";
$className = 'GlmMembersAdmin_' . $menuItem . '_' . $action;
+ $loopTracking .= "<p>Loop: $loopCheck<br>Model: $modelName<br>Class: $className</p>";
// Create hook to add page tabs by add-on plugins
$addOnTabs = array();
$action = 'index';
$errorMsg .= "<b>Model doesn't exist:</b> ".$modelName;
+ $loopTracking .= "<p>*** Failed checking model file ***</p>";
+
// Otherwise, load and run the model
} else {
$action = 'index';
$errorMsg .= "<b>Model class doesn't exist:</b> ".$className;
+ $loopTracking .= "<p>*** Failed checking model class name ***</p>";
+
} else {
// Check if this is a re-direct with parameters
$menuItem = 'error';
$action = 'index';
$errorMsg .= "<b>Bad or missing view file:</b> ".$view;
+
+ $loopTracking .= "<p>*** Failed checking for valid view file ***</p>";
}
} // model class exists
// This is just a sanity check on this loop to keep it from getting out of control
if (++$loopCheck > 10) {
- die('<h1>Serious failure looping on model load in "controllers/admin.php".</h1>');
+ die('
+ <h1>Serious failure looping on model load in "controllers/admin.php".</h1>
+ <div class="glm-item-container">
+ <p>Dear User:</p>
+ <p>
+ Pardon our mess, but something really went wrong with our innards here. Because of
+ that, we\'re dumping some information that hopefully will be useful to our programmers.
+ Please give us a little time to get our innards sorted out.
+ </p>
+ <p>Thanks,</p>
+ <p>The Management</p>
+ </div>
+ </p>
+ '.$loopTracking
+ );
}
if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG && $modelRedirect) {
// Save plugin configuration object
$this->config = $config;
- // Check if database needs to be setup or updated
- $this->checkDatabase();
+ // Check the database and permit installation of a new database tables if they doesn't exist and any updates
+ if (!$this->checkDatabase('install')) {
+ // There was some kind of database failure, this is fatal so die
+ die('Database check failure');
+ }
// Setup rewrite for member detail pages
add_filter( 'rewrite_rules_array',
// Verify that we have the requested menu item in the valid actions
- if (! isset($GLOBALS['glmMembersValidActions']['frontActions'][$menuItem])) {
+ if (! isset($this->config['validActions']['frontActions'][$menuItem])) {
$modelRedirect = true;
$menuItem = 'error';
$action = 'index';
}
// Verify Menu item and action using array at top of this file
- if (! isset($GLOBALS['glmMembersValidActions']['frontActions']) ||
+ if (! isset($this->config['validActions']['frontActions']) ||
! isset($action,
- $GLOBALS['glmMembersValidActions']['frontActions'][$menuItem])) {
+ $this->config['validActions']['frontActions'][$menuItem])) {
$menuItem = 'error';
$action = 'badAction';
}
// Directories
define('GLM_MEMBERS_PLUGIN_PATH', dirname(__FILE__));
-define('GLM_MEMBERS_PLUGIN_DB_SCRIPTS', dirname(__FILE__).'/misc/databaseScripts');
+define('GLM_MEMBERS_PLUGIN_SETUP_PATH', GLM_MEMBERS_PLUGIN_PATH.'/setup');
+define('GLM_MEMBERS_PLUGIN_DB_SCRIPTS', GLM_MEMBERS_PLUGIN_SETUP_PATH.'/databaseScripts');
define('GLM_MEMBERS_PLUGIN_CLASS_PATH', GLM_MEMBERS_PLUGIN_PATH.'/classes');
define('GLM_MEMBERS_PLUGIN_LIB_PATH', GLM_MEMBERS_PLUGIN_PATH.'/lib');
define('GLM_MEMBERS_PLUGIN_MEDIA_PATH', $WPUploadDir['basedir'].'/'.GLM_MEMBERS_PLUGIN_SLUG);
$pluginsPath = str_replace(GLM_MEMBERS_PLUGIN_SLUG, '', GLM_MEMBERS_PLUGIN_PATH);
define('GLM_MEMBERS_WORDPRESS_PLUGIN_PATH', $pluginsPath);
-// Database table prefixes
+// Database defines
global $wpdb;
define('GLM_MEMBERS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_');
+define('GLM_MEMBERS_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersDatabaseDbVersion');
?>
define('GLM_MEMBERS_PLUGIN_VERSION', '1.0.44');
define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.0.43');
-/**
- * Array of valid menu items and actions.
- *
- * The higher level elements are valid menu items. These correlate to
- * actual menu or sub menu items that are hooks back to this controller
- * class.
- *
- * The lower level items below each menu item are actions that may be specified
- * by a "glmMembersAction" form field.
- *
- * The string after the action is the slug of the plugin where the model/view
- * is to perform that action.
- *
- * This array is extended to include valid menus and actions from any add-on
- * plugins.
- */
-$GLOBALS['glmMembersValidActions'] = array(
- 'adminActions' => array(
- 'ajax' => array(
- 'imageUpload' => 'glm-member-db'
- ),
- 'dashboardWidget' => array(
- 'index' => 'glm-member-db'
- ),
- 'members' => array(
- 'index' => 'glm-member-db', // member list
- 'list' => 'glm-member-db',
- 'reports' => 'glm-member-db',
- 'other' => 'glm-member-db'
- ),
- 'member' => array(
- 'index' => 'glm-member-db', // Member Dashboard
- 'memberInfo' => 'glm-member-db',
- 'locations' => 'glm-member-db',
- 'facilities' => 'glm-member-db',
- 'activities' => 'glm-member-db',
- 'accommodations' => 'glm-member-db'
- )
- ,
- 'configure' => array(
- 'index' => 'glm-member-db', // Member Types
- 'categories' => 'glm-member-db',
- 'cities' => 'glm-member-db',
- 'regions' => 'glm-member-db',
- 'accommodationTypes' => 'glm-member-db',
- 'amenities' => 'glm-member-db'
- ),
- 'management' => array(
- 'index' => 'glm-member-db', // General Options
- 'terms' => 'glm-member-db',
- 'development' => 'glm-member-db',
- 'import' => 'glm-member-db',
- 'addons' => 'glm-member-db',
- 'hooks' => 'glm-member-db'
- ),
- 'shortcodes' => array(
- 'index' => 'glm-member-db'
- ),
- 'error' => array(
- 'index' => 'glm-member-db',
- 'badAction' => 'glm-member-db'
- )
- ),
- 'frontActions' => array(
- 'members' => array(
- 'list' => 'glm-member-db',
- 'detail' => 'glm-member-db'
- ),
- 'error' => array(
- 'index' => 'glm-member-db',
- 'badAction' => 'glm-member-db'
- )
- )
-);
-
/*
* Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com)
*
*
* Hook in add-ons and integrate their actions
*
+ * Each add-on should add an array element to the supplied array using the following structure.
+ *
+ * $addOns[{slug for add-on}] = array(
+ * 'dir' => {path to add-on directory},
+ * 'name' => {text name for add-on},
+ * 'short_name' => {an abreviated name for the add-on},
+ * 'slug' => {slug for add-on},
+ * 'actions' => array(
+ * 'adminActions => array(
+ * '{menu name}' => array(
+ * '{action}' => '{add-on slug}',
+ * ... additional actions ...
+ * ),
+ * ... additional menu names ...
+ * 'frontActions' => array(
+ * '{page}' => array(
+ * '{action name}' => '{add-on slug}',
+ * ... addional actions ---
+ * ),
+ * ... additional pages ...
+ * )
+ * ),
+ * // if the add-on is adding database tables use this, otherwise FALSE
+ * 'database' => array(
+ * 'dbPrefix' => '{database prefix to use}',
+ * 'dbCurrentVersion' => '{current add-on database version number}',
+ * 'dbActiveVersionOption' => '{option name used to get current active database version}',
+ * 'dbScriptPath' => '{full path to add-on database scripts directory}',
+ * 'dbVersions' => array(
+ * '{version#}' => array('version' => '{version#}', 'tables' => {# of tables},
+ * ... additional versions in order of version number - highest is last ---
+ * )
+ *
+ * )
+ *
+ * Note that the database prefix must not start with 'glm_members_'. It can however be something
+ * like 'glm_membersPackaging_', otherwise the tables will be counted along with those of the main
+ * plugin and database checks will fail.
+ *
+ * Also note that the default array includes information on the main member db plugin. This is
+ * done for consistency, particularly for database maintenance
*/
+require_once(GLM_MEMBERS_PLUGIN_SETUP_PATH.'/validActions.php');
+require_once(GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/dbVersions.php');
+$config['addOns'] = array(
+ GLM_MEMBERS_PLUGIN_SLUG => array(
+ 'dir' => GLM_MEMBERS_PLUGIN_PATH,
+ 'name' => GLM_MEMBERS_PLUGIN_NAME,
+ 'short_name' => GLM_MEMBERS_PLUGIN_SHORT_NAME,
+ 'slug' => GLM_MEMBERS_PLUGIN_SLUG,
+ 'actions' => $glmMembersValidActions,
+ 'database' => array(
+ 'dbPrefix' => GLM_MEMBERS_PLUGIN_DB_PREFIX,
+ 'dbCurrentVersion' => GLM_MEMBERS_PLUGIN_DB_VERSION,
+ 'dbActiveVersionOption' => GLM_MEMBERS_PLUGIN_ACTIVE_DB_OPTION,
+ 'dbScriptPath' => GLM_MEMBERS_PLUGIN_DB_SCRIPTS,
+ 'dbVersions' => $glmMembersDbVersions
+ )
+ )
+);
// Create hook for registering add-on plugins and their features
-$config['addOns'] = array();
$config['addOns'] = apply_filters('glm-member-db-register-addon', $config['addOns']);
// If any add-ons have registered, integrate their actions and drop the actions array from the $config object as they're not needed there
+$config['validActions'] = array();
if (count($config['addOns']) > 0) {
foreach ($config['addOns'] as $a) {
- // Add valid actions from add-on
+ // Add valid actions
if (isset($a['actions'])) {
- $GLOBALS['glmMembersValidActions'] = array_merge_recursive($GLOBALS['glmMembersValidActions'], $a['actions']);
+ $config['validActions'] = array_merge_recursive($config['validActions'], $a['actions']);
}
// Check for add-on config file
'message' => ''
);
- // Check for valid refType - See glmMembersAdminValidActions in Admin Controller
+ // Check for valid refType - See validActions in Admin Controller
if (!isset($_REQUEST['glm_refType']) || !isset($this->config['ref_type_table'][$_REQUEST['glm_refType']])) {
$return['message'] = 'Invalid target table does not exists!';
echo json_encode($return);
foreach ($this->config['addOns'] as $a) {
$addOns[$a['slug']] = $a;
- $addOns[$a['slug']]['print_r'] = print_r($a,1);
+ $d = print_r($a,1);
+ $dTrimmed = substr($d, 8, strlen($d)-11);
+ $addOns[$a['slug']]['print_r'] = print_r($dTrimmed, 1);
}
// Return status, suggested view, and data to controller
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members Packaging DB Versions
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+/**
+ * Database Versions
+ *
+ * An array of past and current Member Database versions.
+ *
+ * Each entry below uses a key so code can find data on
+ * a specific version and in the values are the version
+ * again and the proper number of tables that should
+ * exist with that version.
+ */
+$glmMembersDbVersions = array(
+ '0.1' => array('version' => '0.1', 'tables' => 26),
+ '1.0.28' => array('version' => '1.0.28', 'tables' => 26),
+ '1.0.30' => array('version' => '1.0.30', 'tables' => 26),
+ '1.0.43' => array('version' => '1.0.43', 'tables' => 26)
+);
+
+
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members Packaging Add-On Valid Actions
+ *
+ * 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/
+ */
+
+/*
+ * Array of valid menu items and actions.
+ *
+ * The higher level elements are valid menu items. These correlate to
+ * actual menu or sub menu items that are hooks back to this controller
+ * class.
+ *
+ * The lower level items below each menu item are actions that may be specified
+ * by a "glmMembersAction" form field.
+ *
+ * The string after the action is the slug of the plugin where the model/view
+ * is to perform that action.
+ *
+ * This array is integrated into the valid actions array in the main GLM Member
+ * DB plugin when this plugin registers itself.
+ */
+
+/**
+ * Array of valid menu items and actions.
+ *
+ * The higher level elements are valid menu items. These correlate to
+ * actual menu or sub menu items that are hooks back to this controller
+ * class.
+ *
+ * The lower level items below each menu item are actions that may be specified
+ * by a "glmMembersAction" form field.
+ *
+ * The string after the action is the slug of the plugin where the model/view
+ * is to perform that action.
+ *
+ * This array is extended to include valid menus and actions from any add-on
+ * plugins.
+ */
+
+$glmMembersValidActions = array(
+ 'adminActions' => array(
+ 'ajax' => array(
+ 'imageUpload' => 'glm-member-db'
+ ),
+ 'dashboardWidget' => array(
+ 'index' => 'glm-member-db'
+ ),
+ 'members' => array(
+ 'index' => 'glm-member-db', // member list
+ 'list' => 'glm-member-db',
+ 'reports' => 'glm-member-db',
+ 'other' => 'glm-member-db'
+ ),
+ 'member' => array(
+ 'index' => 'glm-member-db', // Member Dashboard
+ 'memberInfo' => 'glm-member-db',
+ 'locations' => 'glm-member-db',
+ 'facilities' => 'glm-member-db',
+ 'activities' => 'glm-member-db',
+ 'accommodations' => 'glm-member-db'
+ )
+ ,
+ 'configure' => array(
+ 'index' => 'glm-member-db', // Member Types
+ 'categories' => 'glm-member-db',
+ 'cities' => 'glm-member-db',
+ 'regions' => 'glm-member-db',
+ 'accommodationTypes' => 'glm-member-db',
+ 'amenities' => 'glm-member-db'
+ ),
+ 'management' => array(
+ 'index' => 'glm-member-db', // General Options
+ 'terms' => 'glm-member-db',
+ 'development' => 'glm-member-db',
+ 'import' => 'glm-member-db',
+ 'addons' => 'glm-member-db',
+ 'hooks' => 'glm-member-db'
+ ),
+ 'shortcodes' => array(
+ 'index' => 'glm-member-db'
+ ),
+ 'error' => array(
+ 'index' => 'glm-member-db',
+ 'badAction' => 'glm-member-db'
+ )
+ ),
+ 'frontActions' => array(
+ 'members' => array(
+ 'list' => 'glm-member-db',
+ 'detail' => 'glm-member-db'
+ ),
+ 'error' => array(
+ 'index' => 'glm-member-db',
+ 'badAction' => 'glm-member-db'
+ )
+ )
+);
+
+?>
\ No newline at end of file
{include file='admin/management/header.html'}
- <h2>Currently Installed and Active GLM Members DB Add-Ons</h2>
+ <h2>Currently Installed and Active GLM Members DB Plugins</h2>
{if $addOns}
<ul class="glm-li">
{foreach $addOns as $a}
<li>
- {$a.name}<br>
- <pre>{$a.print_r}</pre>
+ <b>{$a.name}</b><br>
+ <pre style="font-size: .9em; line-height: .9em; border: 1px solid black; padding: 5px;">{$a.print_r}</pre>
</li>
{/foreach}
</ul>