// 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();
+ die("Interesting, you don't have permission to activate plugins.");
}
// Save WordPress Database object
if (!$noDatabaseCheck) {
- // Check the database and permit installation of a new database tables if they doesn't exist and any updates
+ // Check the database - allow installation of tables for a new add-on
if (!$this->checkDatabase('install')) {
- // There was some kind of database failure, this is fatal so die
die('Database check failure');
}
// 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 plug-in is invalid.
+ // Check if the database version set for this plug-in is invalid - not in the dbVersions array
if (!isset($a['database']['dbVersions'][$dbVersion])) {
-
update_option(
'glmMembersInstallErrors',
"The last database version set for the ".$a['name']." (V$dbVersion) isn't valid.");
// Get the number of tables for this plugin database version that should exist.
$tables = $a['database']['dbVersions'][$dbVersion]['tables'];
- // Since MYSQL considers an "_" to be a single character wild-card, we need to escape them.
+ // Since MYSQL considers an underscore (_) to be a single character wild-card, we need to escape them.
$prefixEscaped = str_replace('_', '\_', $a['database']['dbPrefix']);
- // Get the number of tables for this plugin that do currently exist.
+ // Get the number of tables for this plugin that match the
$existingTables = $this->wpdb->get_var("
SELECT COUNT(*)
FROM information_schema.tables
/**
* Admin Controller Constructor
*
- * This contructor is executed by the main plugin index file when the site
+ * This constructor is executed by the main plugin index file when the site
* Dashboard is displayed. It's responsible for setting up any needed hooks
* into WordPress and setting up any support classes required to do admin
* work.
*
- * (no prameters)
+ * (no parameter)
*
* @return void
* @access public
// Save plugin configuration object
$this->config = $config;
- // Check the database
+ // Check the database - allow installation of tables for a new add-on
if (!$this->checkDatabase('install')) {
-
- // There was some kind of dataase failure, so die to prevent WordPress from marking plugin as activated.
- die();
-
+ die('Database check failure');
}
/*
// Save plugin configuration object
$this->config = $config;
- // Check the database and permit installation of a new database tables if they doesn't exist and any updates
+ // Check the database - allow installation of tables for a new add-on
if (!$this->checkDatabase('install')) {
- // There was some kind of database failure, this is fatal so die
die('Database check failure');
}
* Note that the database version matches the version of the last
* plugin version where there was a change in the database.
*
- * Updates to checkDatabase() in glmPluginSupport.php must be
- * made together with the DB_VERSION below. ONLY bump the DB
- * version when there's a change in the database!! Use the
- * version number of that release for the DB version.
+ * Database updates for the main plugin and add-ons must also be
+ * listed in the /setup/databaseScripts/dbVersions.php file of
+ * the corresponding plugin/add-on. The table in that file
+ * determines which version is installed for a new activation
+ * and which update scrips are run to bring the database up to
+ * the current version.
*/
define('GLM_MEMBERS_PLUGIN_VERSION', '1.0.48');
$addOns = array();
foreach ($this->config['addOns'] as $a) {
+ $a['shortcodesDescription'] = '<span class="glm-notice">(not shown here - see "Shortcodes" menu)</span><br />';
$addOns[$a['slug']] = $a;
$d = print_r($a,1);
$dTrimmed = substr($d, 8, strlen($d)-11);
}
break;
-
+/*
case 'drop':
case 'reset':
}
break;
-
+*/
case 'list':
+ // For each plug-in in the registered add-on array (includes the main plugin) - Updated for plug-able database tables
+ foreach ($this->config['addOns'] as $a) {
+
+ $templateData['resultMessage'] .= '<b>Current database tables for: '.$a['name'].'</b><br><div style="margin-left: 2em; margin-bottom: 2em;">';
+
+ if ($a['database'] ) {
+
+ // Since MYSQL considers an underscore (_) to be a single character wild-card, we need to escape them.
+ $prefixEscaped = str_replace('_', '\_', $a['database']['dbPrefix']);
+
+ // Get the number of tables for this plugin that do currently exist.
+ $existingTables = $this->wpdb->get_results("
+ SELECT table_name
+ FROM information_schema.tables
+ WHERE table_name like '".$prefixEscaped."%';
+ ", ARRAY_A);
+
+ if (is_array($existingTables)) {
+ foreach($existingTables as $t){
+ $templateData['resultMessage'] .= $t['table_name'].'<br>';
+ }
+ } else {
+ $templateData['resultMessage'] .= '<b>No tables currently exist</b><br>';
+ }
+ } else {
+ $templateData['resultMessage'] .= '(This plugin/add-on does not have database tables.)<br>';
+ }
+
+ $templateData['resultMessage'] .= '</div>';
+ }
+/*
// Check if the database version set for this plugin is invalid.
if (!isset($activate->dbVersions[$dbVersion])) {
$templateData['resultMessage'] .= "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.<br>";
// Get the number of tables for this plugin database version that should exist.
$tables = $activate->dbVersions[$dbVersion]['tables'];
-
- // Get the number of tables for this plugin that do currently exist.
- $existingTables = $this->wpdb->get_results("
- SELECT table_name
- FROM information_schema.tables
- WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
- ", ARRAY_A);
-
- if (is_array($existingTables)) {
-
-
-
-
- $templateData['resultMessage'] .= '<b>Current database tables</b><br><ul>';
- foreach($existingTables as $t){
- $templateData['resultMessage'] .= "<li>".$t['table_name'].'</li><br>';
- }
- $templateData['resultMessage'] .= '</ul>';
- } else {
- $templateData['resultMessage'] .= '<b>No tables currently exist</b><br>';
- }
+*/
break;
</ul>
<H3>Database</H3>
<ul>
+<!-- These need to be converted to using the dbVersions tables for all plugins
<li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=drop">Drop database tables</a> (WARNING: Destroys all current data)</li>
<li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=create">Create database tables</a></li>
<li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=reset">Fully Reset Database (drop/create)</a> (WARNING: Destroys all current data)</li>
+-->
<li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=list">List database tables</a></li>
</ul>
</li>