From: Chuck Scott Date: Mon, 12 Oct 2015 15:29:05 +0000 (-0400) Subject: Interim commit X-Git-Tag: v1.0.30^2~1^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=8129f80f22b26e360b5836afd093230af6821ad5;p=WP-Plugins%2Fglm-member-db.git Interim commit --- diff --git a/activate.php b/activate.php index dceebd5a..9394f926 100644 --- a/activate.php +++ b/activate.php @@ -27,24 +27,6 @@ require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php'); class glmMembersPluginActivate extends 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) - ); - /** * WordPress Database Object * @@ -167,187 +149,6 @@ class glmMembersPluginActivate extends glmPluginSupport } - /* - * Check if database is installed and if it matches the current version - * - * @param string $capability Name of capability to add - * @param string $default Whether capability should be on by default - * - * @return void - * @access private - */ - private function checkDatabase () - { - - $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_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 the '.GLM_MEMBERS_PLUGIN_NAME.'.' - ."
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) { - - // Get current database version - $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION; - - // Read in Database creation script - $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/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); - - // Split script into separate queries by looking for lines with only "---" - $queries = preg_split('/^----$/m', $sql); - - // Try executing all queries to build database - do { - $q = current($queries); - $this->wpdb->query($q); - $queryError = $this->wpdb->last_error; - } while ($queryError == '' && next($queries)); - - // If there were no errors - if (trim($queryError) == '') { - - // Notify the user that the database has been installed - update_option('glmMembersInstallErrors', 'New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.'); - - // Save the version of the installed database - update_option('glmMembersDatabaseDbVersion', $dbVersion); - - // Indicate that we were successfull - $db_setup_status = true; - - } else { - update_option('glmMembersInstallErrors', 'Failure installing database tables for the '.GLM_MEMBERS_PLUGIN_NAME - .'
Database Installation Error: '.print_r($queryError,1) - .'
'.$q.'
' - ); - } - - // Otherwise, check if we need to update the database - } elseif ($dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) { - - // Include an admin message that we're updating the database - $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' database tables require updating...'); - - // 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 the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.
' - .'This could be due to an option naming conflict.'); - - } - - // Traverse version list to find any required updates - $curVerFound = false; - $db_setup_status = true; - foreach($this->dbVersions as $ver) { - - // 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; - - // Otherwise if it's already been found and $ver is not the new target version - } elseif ($curVerFound && $dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) { - - // Build database update script name - $updateScript = $dbVersion.'_'.$ver; - - // Read in Database creation script - $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$dbVersion.'_V'.$ver.'.sql'; - $sql = file_get_contents($sqlFile); - - // Replace {prefix} with table name prefix - $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $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)); - - // 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('Database Update Error: '.$queryError, 'Alert'); - } - - } - - $dbVersion = $ver; - - // 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('glmMembersDatabaseDbVersion', $dbVersion); - - } else { - break; - } - - } - - if ($db_setup_status) { - - // Save the updated version of the installed database -// update_option('glmMembersDatabaseDbVersion', $dbVersion); - - $this->addNotice('Database tables updated.'); - } - - } else { - $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.'); - $db_setup_status = true; - } - - return $db_setup_status; - } - /* * Add a role capability to all current roles * diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index a8a0c9b3..110f5c14 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -132,6 +132,13 @@ class GlmDataMemberInfo extends GlmDataAbstract 'use' => 'lg' ), + // Member Name (stored by member updates) for sorting + 'member_slug' => array( + 'field' => 'member_slug', + 'type' => 'text', + 'use' => 'a' + ), + // Member Pointer index 'member_pointer' => array ( 'field' => 'member', diff --git a/classes/data/settings/dataSettingsGeneral.php b/classes/data/settings/dataSettingsGeneral.php index 6fbd349e..336c9532 100644 --- a/classes/data/settings/dataSettingsGeneral.php +++ b/classes/data/settings/dataSettingsGeneral.php @@ -148,7 +148,7 @@ class GlmDataSettingsGeneral extends GlmDataAbstract ), /* - * Google Maps + * Misc Settings */ // Google Maps API Key @@ -172,9 +172,13 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), - /* - * Misc Settings - */ + // Google Maps Default Zoom + 'maps_default_zoom' => array( + 'field' => 'maps_default_zoom', + 'type' => 'integer', + 'default' => 10, + 'use' => 'a' + ), // Time Zone 'time_zone' => array( @@ -183,6 +187,13 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + // Canonical Member Page Name + 'canonical_member_page' => array( + 'field' => 'canonical_member_page', + 'type' => 'text', + 'use' => 'a' + ), + /* * Front-end Member Search Options */ @@ -357,6 +368,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + // Front-end Listings - Show E-Mail + 'list_show_email' => array( + 'field' => 'list_show_email', + 'type' => 'checkbox', + 'default' => true, + 'use' => 'a' + ), + // Front-end Listings - Show Categories 'list_show_categories' => array( 'field' => 'list_show_categories', @@ -498,6 +517,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + // Front-end Listings - Map Show E-Mail + 'list_map_show_email' => array( + 'field' => 'list_map_show_email', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + // Front-end Listings - Map Show Categories 'list_map_show_categories' => array( 'field' => 'list_map_show_categories', @@ -647,6 +674,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + // Front-end Memnber Detail - Show E-Mail + 'detail_show_email' => array( + 'field' => 'detail_show_email', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + // Front-end Member Detail - Show Categories 'detail_show_categories' => array( 'field' => 'detail_show_categories', @@ -679,6 +714,22 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + // Front-end Member Detail - Show Coupons + 'detail_show_coupons' => array( + 'field' => 'detail_show_coupons', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + + // Front-end Member Detail - Show Coupons + 'detail_show_packages' => array( + 'field' => 'detail_show_packages', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + /* * Front-end Member Detail Map Options */ @@ -788,6 +839,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + // Front-end Detail - Map Show Email + 'detail_map_show_email' => array( + 'field' => 'detail_map_show_email', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a' + ), + // Front-end Detail - Map Show Categories 'detail_map_show_categories' => array( 'field' => 'detail_map_show_categories', diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index fc7260d1..0b6cb652 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -20,6 +20,25 @@ 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) + ); + /* * Add a message to the 'glmMembersAdminNotices' option for output later. * @@ -155,6 +174,200 @@ class GlmPluginSupport } + /* + * Check if database is installed and if it matches the current version + * + * @param string $capability Name of capability to add + * @param string $default Whether capability should be on by default + * + * @return void + * @access private + */ + public function checkDatabase () + { + + $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_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.'.' + ."
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) { + + // Get current database version + $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION; + + // Read in Database creation script + $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/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); + + // Split script into separate queries by looking for lines with only "---" + $queries = preg_split('/^----$/m', $sql); + + // Try executing all queries to build database + do { + $q = current($queries); + $this->wpdb->query($q); + $queryError = $this->wpdb->last_error; + } while ($queryError == '' && next($queries)); + + // If there were no errors + if (trim($queryError) == '') { + + // Notify the user that the database has been installed + update_option('glmMembersInstallErrors', 'New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.'); + + // Save the version of the installed database + update_option('glmMembersDatabaseDbVersion', $ver); + + // Indicate that we were successfull + $db_setup_status = true; + + } else { + update_option('glmMembersInstallErrors', 'Failure installing database tables for the '.GLM_MEMBERS_PLUGIN_NAME + .'
Database Installation Error: '.print_r($queryError,1) + .'
'.$q.'
' + ); + } + + // Otherwise, check if we need to update the database + } elseif ($dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) { + + // Include an admin message that we're updating the database + $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' database tables require updating...'); + + // 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.
'); + } + + // Traverse version list to find any required updates + $curVerFound = false; + $db_setup_status = true; + foreach($this->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 != GLM_MEMBERS_PLUGIN_DB_VERSION) { + + // Build database update script name + $updateScript = $dbVersion.'_'.$ver; + + // Read in Database creation script + $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$ver.'.sql'; + $sql = file_get_contents($sqlFile); + + // Replace {prefix} with table name prefix + $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $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 = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$ver.'.php'; + + if (is_file($phpScript)) { + include ($phpScript); + } + + // 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('Database Update Error: '.$queryError, 'Alert'); + } + + } + + $dbVersion = $ver; + + // 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('glmMembersDatabaseDbVersion', $dbVersion); + + } else { + break; + } + + } + + if ($db_setup_status) { + + // Save the updated version of the installed database + // update_option('glmMembersDatabaseDbVersion', $dbVersion); + + $this->addNotice('Database tables updated.'); + } + + } else { +// $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.'); +// $db_setup_status = true; + } + + return $db_setup_status; + } + + } ?> \ No newline at end of file diff --git a/config.php b/config.php index b5f2e772..fa85c65f 100644 --- a/config.php +++ b/config.php @@ -22,14 +22,6 @@ $config['countries'] = $countryData['countries']; $settings = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_general WHERE id = 1;", ARRAY_A); unset($settings['id']); -// ************* NEED TO ADD TO MANAGEMENT SETTINGS - Might require database changes ************** -$settings['list_show_email'] = true; -$settings['list_map_show_email'] = true; -$settings['mapDefaultZoom'] = 10; -$settings['detail_show_coupons'] = false; -$settings['detail_show_packages'] = false; -// *************************************************************** - $config['settings'] = $settings; $terms = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_terms WHERE id = 1;", ARRAY_A); unset($terms['id']); diff --git a/controllers/admin.php b/controllers/admin.php index 651a757f..2f10f8a9 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -185,6 +185,9 @@ class glmMembersAdmin extends GlmPluginSupport // Save plugin configuration object $this->config = $config; + // Check the database + $this->checkDatabase(); + /* * Check if there's a request to bypass the WordPress Dashboard and * display directly to the browser using a specified diff --git a/controllers/front.php b/controllers/front.php index 164a6e8d..d0ba49b1 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -73,6 +73,21 @@ class glmMembersFront extends GlmPluginSupport // Save plugin configuration object $this->config = $config; + // Check if database needs to be setup or updated + $this->checkDatabase(); + + // Setup rewrite for member detail pages + add_filter( 'rewrite_rules_array', + array( + $this, + 'glm_members_insert_rewrite_rules' + )); + add_action( 'wp_loaded', + array( + $this, + 'glm_members_flush_rules' + )); + // Add front-end scripts and css add_action('wp_enqueue_scripts', array( @@ -94,6 +109,28 @@ class glmMembersFront extends GlmPluginSupport } + // Flush rules if the member detail rewrite hasn't been included + function glm_members_flush_rules(){ + $rules = get_option( 'rewrite_rules' ); +// if ( ! isset( $rules['('.$this->config['settings']['canonical_member_page'].')/(.*+)/?$'] ) ) { + global $wp_rewrite; + $wp_rewrite->flush_rules(); + // } + } + + // Add the rewrite rule for the member detail page + function glm_members_insert_rewrite_rules( $rules ) + { + $newrules = array(); +// $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/?$'] = 'index.php?pagename=$matches[1]&member=$matches[2]'; + $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/?$'] = 'index.php?pagename=$matches[1]&member=$matches[2]'; + $ret = $newrules + $rules; +var_dump($newrules); +echo "

";var_dump($_REQUEST); +//echo "

".print_r($ret,1)."
"; + return $ret; + } + /** * Setup inclusion of front-end scripts and css * diff --git a/defines.php b/defines.php index 16e25ff8..6ae62067 100644 --- a/defines.php +++ b/defines.php @@ -5,6 +5,8 @@ * Set standard defined parameters */ +// NOTE: Plugin & Database versions are defined in "/glm-member-db.php". + define('GLM_MEMBERS_PLUGIN_NAME', 'Gaslight Media Members Database'); define('GLM_MEMBERS_PLUGIN_DIR', 'glm-member-db'); @@ -22,10 +24,6 @@ if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') { } define('GLM_MEMBERS_PLUGIN_HTTP_PROTOCOL', $pageProtocol); -// Plugin Versions -define('GLM_MEMBERS_PLUGIN_VERSION', 0.1); -define('GLM_MEMBERS_PLUGIN_DB_VERSION', 0.1); - // Get various pieces of the URL $urlParts = parse_url(get_bloginfo('url')); $pageUri = explode('?', $_SERVER['REQUEST_URI']); // Bust this up to access URL path and script name only @@ -34,6 +32,7 @@ $adminURL = admin_url('admin.php'); $WPUploadDir = wp_upload_dir(); // URLs +define('GLM_MEMBERS_SITE_BASE_URL', $pageProtocol.'://'.$urlParts['host'].$urlParts['path'].'/'); define('GLM_MEMBERS_PLUGIN_ADMIN_URL', $adminURL); define('GLM_MEMBERS_PLUGIN_URL', plugin_dir_url(__FILE__)); define('GLM_MEMBERS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_PLUGIN_DIR); diff --git a/glm-member-db.php b/glm-member-db.php index 1fd17b51..fdb4adef 100644 --- a/glm-member-db.php +++ b/glm-member-db.php @@ -22,6 +22,18 @@ * @version 1.0.28 */ +/* + * Plugin and Database Versions + * + * 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. + */ +define('GLM_MEMBERS_PLUGIN_VERSION', '1.0.28'); +define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.0.28'); + /* * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) * @@ -39,17 +51,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -$startupNotices = ''; - -// Get standard defined parameters -require_once('defines.php'); - -// Get configuration -require_once('config.php'); - -// 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); - /** * ******************************************************************************* * @@ -178,6 +179,21 @@ add_option('glmMembersDatabaseDbVersion', false); * ******************************************************************************** */ +/* + * Some initial setup and tests + */ + +$startupNotices = ''; + +// Get standard defined parameters +require_once('defines.php'); + +// Get configuration +require_once('config.php'); + +// 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); + /* * * Activate, Deactivate, Uninstall hooks diff --git a/misc/databaseScripts/create_database_V0.1.sql b/misc/databaseScripts/create_database_V0.1.sql index 50c0381a..3fc87ceb 100644 --- a/misc/databaseScripts/create_database_V0.1.sql +++ b/misc/databaseScripts/create_database_V0.1.sql @@ -4,7 +4,7 @@ -- Database Creation Script -- -- To permit each query below to be executed separately, --- all queries must be separated by a line with ---- +-- all queries must be separated by a line with four dashes CREATE TABLE {prefix}accommodation_types ( @@ -383,6 +383,7 @@ CREATE TABLE {prefix}member_info ( id INT NOT NULL AUTO_INCREMENT, member INT NULL, member_name TINYTEXT NULL, + member_slug TINYTEXT NULL, status INT NULL, reference_name TINYTEXT NULL, descr TEXT NULL, @@ -483,7 +484,9 @@ CREATE TABLE {prefix}settings_general ( google_maps_api_key TINYTEXT DEFAULT '', maps_default_lat FLOAT DEFAULT 45.3749, maps_default_lon FLOAT DEFAULT -84.9592, + maps_default_zoom INTEGER DEFAULT 10, time_zone TINYTEXT NULL, + canonical_member_page TINYTEXT NULL; list_show_map BOOLEAN DEFAULT true, list_show_list BOOLEAN DEFAULT true, list_show_search BOOLEAN DEFAULT true, @@ -505,6 +508,7 @@ CREATE TABLE {prefix}settings_general ( list_show_tollfree BOOLEAN DEFAULT true, list_show_url BOOLEAN DEFAULT true, list_show_url_newtarget BOOLEAN DEFAULT true, + list_show_email BOOLEAN DEFAULT true, list_show_categories BOOLEAN DEFAULT true, list_show_creditcards BOOLEAN DEFAULT true, list_show_amenities BOOLEAN DEFAULT false, @@ -522,6 +526,7 @@ CREATE TABLE {prefix}settings_general ( list_map_show_tollfree BOOLEAN DEFAULT true, list_map_show_url BOOLEAN DEFAULT true, list_map_show_url_newtarget BOOLEAN DEFAULT true, + list_map_show_email BOOLEAN DEFAULT true, list_map_show_categories BOOLEAN DEFAULT false, list_map_show_creditcards BOOLEAN DEFAULT false, list_map_show_amenities BOOLEAN DEFAULT false, @@ -540,10 +545,13 @@ CREATE TABLE {prefix}settings_general ( detail_show_tollfree BOOLEAN DEFAULT true, detail_show_url BOOLEAN DEFAULT true, detail_show_url_newtarget BOOLEAN DEFAULT true, + detail_show_email BOOLEAN DEFAULT true, detail_show_categories BOOLEAN DEFAULT true, detail_show_creditcards BOOLEAN DEFAULT true, detail_show_amenities BOOLEAN DEFAULT true, detail_show_imagegallery BOOLEAN DEFAULT true, + detail_show_coupons BOOLEAN DEFAULT false, + detail_show_packages BOOLEAN DEFAULT false, detail_map_show_logo BOOLEAN DEFAULT false, detail_map_logo_size TINYTEXT NULL, detail_map_show_descr BOOLEAN DEFAULT false, @@ -557,6 +565,7 @@ CREATE TABLE {prefix}settings_general ( detail_map_show_tollfree BOOLEAN DEFAULT true, detail_map_show_url BOOLEAN DEFAULT true, detail_map_show_url_newtarget BOOLEAN DEFAULT true, + detail_map_show_email BOOLEAN DEFAULT true, detail_map_show_categories BOOLEAN DEFAULT false, detail_map_show_creditcards BOOLEAN DEFAULT false, detail_map_show_amenities BOOLEAN DEFAULT false, @@ -566,9 +575,9 @@ CREATE TABLE {prefix}settings_general ( ---- INSERT INTO {prefix}settings_general - ( id, time_zone ) + ( id, time_zone, canonical_member_page ) VALUES - ( 1, 'America/Detroit' ) + ( 1, 'America/Detroit', 'member-detail' ) ; ---- diff --git a/misc/databaseScripts/update_database_V1.0.28.php b/misc/databaseScripts/update_database_V1.0.28.php new file mode 100644 index 00000000..78627274 --- /dev/null +++ b/misc/databaseScripts/update_database_V1.0.28.php @@ -0,0 +1,25 @@ +wpdb->get_results('SELECT id, member_name FROM '.GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info;', ARRAY_A); +if ($infoRecords && count($infoRecords) > 0) { + foreach ($infoRecords as $i) { + $slug = sanitize_title($i['member_name']); + $this->wpdb->update( + GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info', + array( + 'member_slug' => $slug + ), + array( 'id' => $i['id'] ), + array( '%s' ), + array( '%d') + ); + } +} + +?> \ No newline at end of file diff --git a/misc/databaseScripts/update_database_V1.0.28.sql b/misc/databaseScripts/update_database_V1.0.28.sql new file mode 100644 index 00000000..4f8a294a --- /dev/null +++ b/misc/databaseScripts/update_database_V1.0.28.sql @@ -0,0 +1,47 @@ +-- Gaslight Media Members Database +-- File Created: 12/09/14 15:27:15 +-- Database Version: 1.0.28 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashses + + +ALTER TABLE {prefix}member_info ADD COLUMN member_slug TINYTEXT; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN list_show_email BOOLEAN DEFAULT true; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN list_map_show_email BOOLEAN DEFAULT true; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN maps_default_zoom integer DEFAULT 10; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN canonical_member_page TINYTEXT; + +---- + +UPDATE {prefix}settings_general SET canonical_member_page = 'member'; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN detail_show_email BOOLEAN DEFAULT true; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN detail_map_show_email BOOLEAN DEFAULT true; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN detail_show_coupons BOOLEAN DEFAULT false; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN detail_show_packages BOOLEAN DEFAULT false; + diff --git a/models/admin/management/import.php b/models/admin/management/import.php index e503e096..bd269957 100644 --- a/models/admin/management/import.php +++ b/models/admin/management/import.php @@ -869,6 +869,7 @@ class GlmMembersAdmin_management_import array( 'member' => $membID, 'member_name' => $val['member_name'], + 'member_slug' => sanitize_title($val['member_name']), 'status' => $this->config['status_numb']['Active'], 'reference_name' => 'Imported Member Information', 'descr' => $val['description'], @@ -895,6 +896,7 @@ class GlmMembersAdmin_management_import array( '%d', '%s', + '%s', '%d', '%s', '%s', diff --git a/models/admin/member/memberInfo.php b/models/admin/member/memberInfo.php index bab96bb3..01a3b908 100644 --- a/models/admin/member/memberInfo.php +++ b/models/admin/member/memberInfo.php @@ -374,6 +374,8 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo // Clone the current member info $this->memberInfoID = $CloneMemberInfo->cloneMemberInfo($this->memberInfoID); + $this->memberInfo = $this->editEntry($this->memberInfoID); + break; // Default is to display the currently selected member information record in a form for updates diff --git a/models/front/members/detail.php b/models/front/members/detail.php index ffcba9ef..179f569c 100644 --- a/models/front/members/detail.php +++ b/models/front/members/detail.php @@ -98,7 +98,8 @@ class GlmMembersFront_members_detail extends GlmDataMemberInfo */ public function modelAction ($actionData = false) { - +//echo "top of modelAction() in front/members/detail.php
".print_r($_REQUEST,1).print_r($actionData,1)."
";exit; +//echo "
".print_r($_GET,1)."
"; $where = ''; $haveMember = false; $haveImageGallery = false; diff --git a/models/front/members/list.php b/models/front/members/list.php index 88ad297b..1ed47b64 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -251,6 +251,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // Compile template data $templateData = array( + 'siteBaseUrl' => GLM_MEMBERS_SITE_BASE_URL, 'haveMembers' => $haveMembers, 'members' => $list, 'haveFilter' => $haveFilter, diff --git a/views/admin/management/index.html b/views/admin/management/index.html index 9243f1b5..d9139124 100644 --- a/views/admin/management/index.html +++ b/views/admin/management/index.html @@ -54,6 +54,12 @@ {if $genSettings.fieldFail.maps_default_lat}

{$genSettings.fieldFail.maps_default_lat}

{/if} {if $genSettings.fieldFail.maps_default_lon}

{$genSettings.fieldFail.maps_default_lon}

{/if} + + + Google Maps Default Zoom: + + + Time Zone: @@ -66,6 +72,13 @@ {if $genSettings.fieldFail.time_zone}

{$genSettings.fieldFail.time_zone}

{/if} + + Member Detail Page Permalink Name: + + +
Use only the page name at the end of the permalink for the member detail page. + + @@ -111,6 +124,7 @@ Display URL as a link: + Show E-mail: Show Categories: Show Credit Cards: Show Amenitiies: @@ -182,6 +196,7 @@ Display URL as a link: + Show E-Mail: Show Categories: Show Credit Cards Accepted: Show Amenities: @@ -230,6 +245,7 @@ Display URL as a link: + Show E-mail: Show Categories: Show Credit Cards: Show Amenitiies: @@ -282,10 +298,13 @@ Display URL as a link: + Show E-mail: Show Categories: Show Credit Cards Accepted: Show Amenities: Show Image Gallery: + Show Coupons: + Show Packages: diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index c4eba6eb..92e8e641 100644 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -43,6 +43,13 @@ Member Name: {$member.name} + + Name for URLs: + + + {if $memberInfo.fieldFail.member_slug}

{$memberInfo.fieldFail.member_slug}

{/if} + + Member Type: {$member.member_type.name} diff --git a/views/admin/shortcodes/index.html b/views/admin/shortcodes/index.html index 096820b0..0379c8c4 100644 --- a/views/admin/shortcodes/index.html +++ b/views/admin/shortcodes/index.html @@ -21,8 +21,9 @@ - - + + @@ -40,7 +41,8 @@ - + +
ShortcodeAttributeDescription
[glm-members-list] + [glm-members-list]  Displays a list of members and a map with markers for each member. Optionally, the attributes below may used to modify the display of this page.
[glm-member-detail][glm-member-detail]  Displays details for a speicif member along with a map showing their location. The "id" attribute below is required to specify which member to display. @@ -52,10 +54,14 @@ id="{ member ID }" - This is a required attribute for [glm-member-detail] that specifies the ID of + This is an optional attribute for [glm-member-detail] that specifies the ID of the desired member. The ID for a member is displayed both in the left column of the member list and at the top of the Member Dashboard. Only one ID may - be specified. + be specified. If this attribute is not supplied, the page will look for a + member name slug as the last part of the path in the URL and try to locate + an active member information record with "Name for URLs" set to the same + string. +
diff --git a/views/front/members/detail.html b/views/front/members/detail.html index a918f870..342152c0 100644 --- a/views/front/members/detail.html +++ b/views/front/members/detail.html @@ -188,7 +188,7 @@ // Set default - Need to make this configurable var map = new google.maps.Map(document.getElementById('glm-locationMap'), { - zoom: 14, + zoom: {$settings.maps_default_zoom}, center: memberlocation, disableDefaultUI: false, mapTypeId: google.maps.MapTypeId.MAP, diff --git a/views/front/members/list.html b/views/front/members/list.html index 45a0f325..7ac353e1 100644 --- a/views/front/members/list.html +++ b/views/front/members/list.html @@ -93,7 +93,8 @@

{if $settings.list_show_detail_link} - {$m.member} + {$m.member} + {else} {$m.member} {/if} @@ -255,7 +256,7 @@ // Create a Google Map object var map = new google.maps.Map(document.getElementById('glm-locationMap'), { center: new google.maps.LatLng({$settings.maps_default_lat}, {$settings.maps_default_lon}), - zoom: {$settings.mapDefaultZoom}, + zoom: {$settings.maps_default_zoom}, disableDefaultUI: false, mapTypeId: google.maps.MapTypeId.MAP, });