$existingTables = $this->wpdb->get_var("
SELECT COUNT(*)
FROM information_schema.tables
- WHERE table_schema = '".DB_NAME."'
+ WHERE table_schema = '".DB_NAME."'
AND table_name like '$prefixEscaped%';
");
}
} else {
- $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.');
+ if ($option == 'install') {
+ $this->addNotice('The '.$a['name'].' plugin/add-on has been reactivated using the existing database tables.');
+ }
$db_setup_status = true;
}
}
}
-
-?>
\ No newline at end of file
$config = array_replace($config, $themeIni);
}
-
-?>
$this->config = $config;
// Check the database - allow installation of tables for a new add-on
- if (!$this->checkDatabase('install')) {
+ if (!$this->checkDatabase()) {
die('Database check failure');
}
}
}
-
-
$this->config = $config;
// Check the database - allow installation of tables for a new add-on
- if (!$this->checkDatabase('install')) {
+ if (!$this->checkDatabase()) {
die('Database check failure');
}
}
}
-?>
\ No newline at end of file
}
}
}
-
-?>
\ No newline at end of file
define('GLM_MEMBERS_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_');
define('GLM_MEMBERS_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersDatabaseDbVersion');
-?>
// Get standard defined parameters
require_once('defines.php');
+// Check if plugin version is not current in WordPress option and if needed updated it
+if (GLM_MEMBERS_PLUGIN_VERSION != get_option('glmMembersDatabasePluginVersion')) {
+ update_option('glmMembersDatabasePluginVersion', GLM_MEMBERS_PLUGIN_VERSION);
+}
+
// Get configuration
require_once('config.php');
*
* Determine which controller to load
*
- * The first is for displaying notices in another window, possibly for debug output.
- *
*/
+
+// If the call to this code is to display a separate debug window
if (isset($_REQUEST['glmDebugWindow']) && $_REQUEST['glmDebugWindow'] == true) {
glmMembersAdminNotices(true);
exit;
+
+// Otherwise select appropriate controller
} elseif (is_admin()) {
require_once (GLM_MEMBERS_PLUGIN_PATH . '/controllers/admin.php');
new glmMembersAdmin($wpdb, $config);
}
-/*
- * If not doing debug, then just keep all of the debug messages cleared
- */
-if (!GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
- delete_option('glmMembersAdminNoticeAlerts');
- delete_option('glmMembersAdminNotices');
- delete_option('glmMembersAdminNoticeProcess');
- delete_option('glmMembersAdminNoticeDataBlocks');
-}
-
/*
* Check if there's any startup notices in this file. (stuff that happens before we get all setup)
*
echo '<div class="updated"><h3>'.GLM_MEMBERS_PLUGIN_NAME.' Plugin Warning</h3><p>'.$startupNotices.'</p></div>';
}
if ($startupNotices != '') {
- add_action('admin_notices','glmMembersStartupNotices');
+ //add_action('admin_notices','glmMembersStartupNotices');
}
/*
* 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
+// Check for any notices that need to display at the top of an admin screen
+$notices = get_option('glmMembersAdminNotices');
+if (is_admin() && $notices) {
add_action('admin_notices','glmMembersAdminNotices');
+}
+/*
+ * If not doing debug, then just keep all of the debug messages cleared
+ */
+if (!GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ delete_option('glmMembersAdminNoticeAlerts');
+// delete_option('glmMembersAdminNotices');
+ delete_option('glmMembersAdminNoticeProcess');
+ delete_option('glmMembersAdminNoticeDataBlocks');
}
-?>
public function modelAction ($actionData = false)
{
+ $resultMessage = '';
+ $success = false;
+ $haveMembers = false;
+ $import = false;
+ $importNotice = '';
+ $haveDatabaseTableList = false;
+ $databaseList = false;
+
// Get current database version
$dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
settype($dbVersion, 'string');
- $templateData['resultMessage'] = '';
- $templateData['success'] = false;
- $templateData['haveNotices'] = false;
- $notices = array();
- $templateData['haveMembers'] = false;
- $templateData['import'] = false;
- $templateData['importNotice'] = false;
- $templateData['haveDatabaseTableList'] = false;
-
// Load database activation class to get access to database version information
require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php');
$activate = new glmMembersPluginActivate($this->wpdb, $this->config, true);
}
}
- $templateData['import'] = true;
+ $import = true;
$templateData['membersImported'] = $Connections->doImport();
} else {
break;
}
$templateData['numbEntries'] = $c;
- $importNotice = 'Connections Business Directory plugin is active.<br>Number of businesses listed: '.$c.'<br>';
+ $importNotice .= 'Connections Business Directory plugin is active.<br>Number of businesses listed: '.$c.'<br>';
// Get the basic business data for review.
$templateData['members'] = $Connections->getList();
if ($templateData['members'] === false) {
- $importNotice = 'No businesses were retieved.';
+ $importNotice .= 'No businesses were retieved.<br>';
break;
}
*/
case 'list':
+ $databaseList = array();
+
// 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;">';
+ $databaseList[$a['name']] = array(
+ 'addonName' => $a['name'],
+ 'haveDatabase' => false
+ );
if ($a['database'] ) {
+ // Add add-on database info to list
+ $databaseList[$a['name']] = array_merge_recursive($databaseList[$a['name']], $a['database']);
+ $databaseList[$a['name']]['haveDatabase'] = true;
+
// Since MYSQL considers an underscore (_) to be a single character wild-card, we need to escape them.
$prefixEscaped = str_replace('_', '\_', $a['database']['dbPrefix']);
$existingTables = $this->wpdb->get_results("
SELECT table_name
FROM information_schema.tables
- WHERE table_name like '".$prefixEscaped."%';
+ WHERE table_schema = '".DB_NAME."'
+ AND table_name like '".$prefixEscaped."%';
", ARRAY_A);
+ // If we have a good list of tables
if (is_array($existingTables)) {
- foreach($existingTables as $t){
- $templateData['resultMessage'] .= $t['table_name'].'<br>';
+
+ // Check for request to list a table's fields
+ if (isset($_REQUEST['descTable'])) {
+ while (list ($k, $v) = each ($existingTables)) {
+ if ($_REQUEST['descTable'] == $v['table_name']) {
+ $existingTables[$k]['desctable'] = true;
+ $fields = $this->wpdb->get_results("
+ DESCRIBE ".$v['table_name']."
+ ", ARRAY_A);
+ $existingTables[$k]['tablefields'] = $fields;
+ }
+ }
}
+
+ $databaseList[$a['name']]['tables'] = $existingTables;
+
} else {
- $templateData['resultMessage'] .= '<b>No tables currently exist</b><br>';
+ $databaseList[$a['name']]['tables'] = false;
}
- } 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.
}
+ $templateData['resultMessage'] = $resultMessage;
+ $templateData['success'] = $success;
+ $templateData['haveMembers'] = $haveMembers;
+ $templateData['importNotice'] = $importNotice;
+ $templateData['haveDatabaseTableList'] = $haveDatabaseTableList;
+ $templateData['databaseList'] = $databaseList;
+
+
// Return status, suggested view, and data to controller
return array(
'status' => true,
}
}
-
-?>
\ No newline at end of file
// Removing the tables using the script
global $wpdb;
$wpdb->query($sql);
-
-?>
{$resultMessage}
</div>
{/if}
+
+{if $databaseList}
+ <div>
+ <hr>
+ <h3>List of Database Tables</h3>
+ {foreach $databaseList as $d}
+ <div style="margin-left: 2em !important;">
+ <h4>{$d.addonName}</h4>
+ <div style="margin-left: 2em !important;">
+ {if $d.haveDatabase}
+ <table style="font-size: .9em;">
+ <tr><th align="left">Prefix: </th><td>{$d.dbPrefix}</td></tr>
+ <tr><th align="left">Current Version: </th><td>{$d.dbCurrentVersion}</td></tr>
+ <tr>
+ <th align="left" valign="top">Versions: </th>
+ <td>
+ <table style="font-size: .9em;">
+ {foreach $d.dbVersions as $v}
+ <tr><th align="left">{$v.version}</th><td>Number of tables: {$v.tables}</td></tr>
+ {/foreach}
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <th align="left" valign="top">Tables: </th>
+ <td>
+ <table style="font-size: .9em;">
+ {foreach $d.tables as $t}
+ <tr>
+ <td align="left"><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=list&descTable={$t.table_name}">{$t.table_name}</a></td>
+ </tr>
+ {if isset($t.desctable)}
+ <tr><td>
+ <table style="margin-left: 2em;">
+ {foreach $t.tablefields as $f}
+ <tr><td>{$f.Field}</td><td>{$f.Type}</td></tr>
+ {/foreach}
+ </table>
+ </td></tr>
+ {/if}
+ {/foreach}
+ </table>
+ </td>
+ </tr>
+ </table>
+ {else}
+ (No database tables)
+ {/if}
+ </div>
+ </div>
+ {/foreach}
+ </div>
+{/if}
{if $haveMembers}
<script type="text/javascript">