From a9c99b2e912699a0a945ac695aff4d27b7f632ea Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Wed, 14 Oct 2015 16:12:56 -0400 Subject: [PATCH] Added support for canonical pages and fixed a number of import issues. --- activate.php | 4 +- classes/data/dataMemberInfo.php | 17 +- classes/data/dataMembers.php | 8 + classes/glmPluginSupport.php | 26 +-- config.php | 2 +- controllers/admin.php | 3 + controllers/front.php | 44 +++-- glm-member-db.php | 6 +- lib/GlmDataAbstract/.~lock.documentation.odt# | 1 - lib/GlmDataAbstract/DataAbstract.php | 14 +- ...e_V0.1.sql => create_database_V1.0.30.sql} | 179 +++++++++--------- ...ase_V0.1.sql => drop_database_V1.0.30.sql} | 0 .../update_database_V1.0.30.php | 25 +++ .../update_database_V1.0.30.sql | 18 ++ models/admin/management/development.php | 1 + models/admin/management/import.php | 9 +- models/front/members/detail.php | 122 +++++++++++- models/front/members/list.php | 114 ++++++++++- views/admin/member/index.html | 11 ++ views/admin/member/memberInfo.html | 7 - views/admin/shortcodes/index.html | 122 +++++++++++- 21 files changed, 577 insertions(+), 156 deletions(-) delete mode 100644 lib/GlmDataAbstract/.~lock.documentation.odt# rename misc/databaseScripts/{create_database_V0.1.sql => create_database_V1.0.30.sql} (80%) rename misc/databaseScripts/{drop_database_V0.1.sql => drop_database_V1.0.30.sql} (100%) create mode 100644 misc/databaseScripts/update_database_V1.0.30.php create mode 100644 misc/databaseScripts/update_database_V1.0.30.sql diff --git a/activate.php b/activate.php index 9394f926..db1fa886 100644 --- a/activate.php +++ b/activate.php @@ -71,8 +71,8 @@ class glmMembersPluginActivate extends glmPluginSupport $this->checkErrorScrape(); - // Check the database - if (!$this->checkDatabase()) { + // Check the database and permit installation of a new database if it doesn't exist; + if (!$this->checkDatabase('install')) { // There was some kind of dataase failure, so die to prevent WordPress from marking plugin as activated. die(); diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index 110f5c14..fa5931a4 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -132,11 +132,16 @@ 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 Slug + 'member_slug' => array ( + 'field' => 'member', + 'as' => 'member_slug', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + 'p_field' => 'member_slug', + 'p_static' => true, + 'required' => true, + 'use' => 'gle' ), // Member Pointer index @@ -333,7 +338,7 @@ class GlmDataMemberInfo extends GlmDataAbstract /* * Find the active member info record for a specific member ID * - * @param integer $member ID of the member + * @param integer $member ID of the member name * * @return integer Member info record ID or false if not found */ diff --git a/classes/data/dataMembers.php b/classes/data/dataMembers.php index 5a2efb76..28845700 100644 --- a/classes/data/dataMembers.php +++ b/classes/data/dataMembers.php @@ -145,6 +145,14 @@ class GlmDataMembers extends GlmDataAbstract { 'use' => 'a' ), + // Member Name (stored by member updates) for sorting + 'member_slug' => array( + 'field' => 'member_slug', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + // Date created 'created' => array ( 'field' => 'created', diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 0b6cb652..a1d0c9b5 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -36,7 +36,8 @@ class GlmPluginSupport */ public $dbVersions = array( '0.1' => array('version' => '0.1', 'tables' => 26), - '1.0.28' => array('version' => '1.0.28', 'tables' => 26) + '1.0.28' => array('version' => '1.0.28', 'tables' => 26), + '1.0.30' => array('version' => '1.0.30', 'tables' => 26) ); /* @@ -177,15 +178,16 @@ class GlmPluginSupport /* * Check if database is installed and if it matches the current version * - * @param string $capability Name of capability to add + * @param string $option Set to 'install' to permit installation of the database. * @param string $default Whether capability should be on by default * * @return void * @access private */ - public function checkDatabase () + public function checkDatabase ($option = false) { + $dbVersion = get_option('glmMembersDatabaseDbVersion'); $db_setup_status = false; @@ -225,6 +227,11 @@ class GlmPluginSupport // If glmMembersDatabaseDbVersion is not set, install current version if (!$dbVersion) { + // 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; @@ -293,9 +300,6 @@ class GlmPluginSupport // 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); @@ -322,10 +326,6 @@ class GlmPluginSupport // 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 { @@ -335,9 +335,10 @@ class GlmPluginSupport $this->addNotice('Database Update Error: '.$queryError, 'Alert'); } - } + $dbVersion = $ver; + $db_setup_status = true; - $dbVersion = $ver; + } // Save the new version. If we've had a problem updating the database, then stop here. if ($db_setup_status) { @@ -367,7 +368,6 @@ class GlmPluginSupport return $db_setup_status; } - } ?> \ No newline at end of file diff --git a/config.php b/config.php index fa85c65f..7284d12f 100644 --- a/config.php +++ b/config.php @@ -21,8 +21,8 @@ $config['countries'] = $countryData['countries']; // Read in Settings and Terms from database $settings = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_general WHERE id = 1;", ARRAY_A); unset($settings['id']); - $config['settings'] = $settings; + $terms = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_terms WHERE id = 1;", ARRAY_A); unset($terms['id']); $config['terms'] = $terms; diff --git a/controllers/admin.php b/controllers/admin.php index 2f10f8a9..ca31c6bb 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -595,6 +595,9 @@ class glmMembersAdmin extends GlmPluginSupport if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + // Also turn on SQL error messages + $this->wpdb->show_errors(); + // If debug is VERBOSE $consts = get_defined_constants(true); if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { diff --git a/controllers/front.php b/controllers/front.php index d0ba49b1..ff8a2558 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -82,7 +82,12 @@ class glmMembersFront extends GlmPluginSupport $this, 'glm_members_insert_rewrite_rules' )); - add_action( 'wp_loaded', + add_filter('query_vars', + array( + $this, + 'glm_members_RewriteQueryVars' + )); + add_filter( 'init', array( $this, 'glm_members_flush_rules' @@ -112,25 +117,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'].')/(.*+)/?$'] ) ) { + 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; + $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)$'] = 'index.php?pagename=$matches[1]&memberslug=$matches[2]'; + return $newrules + $rules; + } + + // Have WP store memberid value so we can read it after rewrites + function glm_members_RewriteQueryVars($vars) + { + array_push($vars, 'memberslug'); + return $vars; } + /** * Setup inclusion of front-end scripts and css * @@ -235,7 +243,8 @@ echo "

";var_dump($_REQUEST); 'alpha' => false, 'search' => false, 'amenities' => false, - 'detail-page' => false + 'detail-page' => false, + 'show' => false ), $atts, 'glm-members' @@ -247,7 +256,8 @@ echo "

";var_dump($_REQUEST); $request = shortcode_atts( array( 'map' => true, - 'id' => false + 'id' => false, + 'show' => false ), $atts, 'glm-members' @@ -269,6 +279,9 @@ echo "

";var_dump($_REQUEST); if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + // Also turn on SQL error messages + $this->wpdb->show_errors(); + // Get all defiend constants then if not VERBOSE select out only user contstants $consts = get_defined_constants(true); if (!GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) { @@ -427,6 +440,13 @@ echo "

";var_dump($_REQUEST); $view = 'front/error/index.html'; } + // Check for modified settings to save in conf + if (isset($results['settings'])) { + while (list($key, $val) = each($results['settings'])) { + $this->config['settings'][$key] = $val; + } + } + /* * Merge data returned from the model with the selected view */ diff --git a/glm-member-db.php b/glm-member-db.php index c75b940f..e6b5d7e2 100644 --- a/glm-member-db.php +++ b/glm-member-db.php @@ -29,10 +29,12 @@ * 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. + * made together with the DB_VERSION below. ONLY bump the DB + * version when there's a change in the database!! Use the + * version nunmber of that release for the DB version. */ define('GLM_MEMBERS_PLUGIN_VERSION', '1.0.28'); -define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.0.28'); +define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.0.30'); /* * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) diff --git a/lib/GlmDataAbstract/.~lock.documentation.odt# b/lib/GlmDataAbstract/.~lock.documentation.odt# deleted file mode 100644 index 0e5b58c4..00000000 --- a/lib/GlmDataAbstract/.~lock.documentation.odt# +++ /dev/null @@ -1 +0,0 @@ -,cscott,Ubuntu-1404,24.09.2015 14:41,file:///home/cscott/.config/libreoffice/4; \ No newline at end of file diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index cb164524..a7cc1f24 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -649,14 +649,12 @@ abstract class GlmDataAbstract reset($p_list); foreach ($p_list as $p) { - if ($this->optionIncludeSelectListData) { - $pick_list[$p['p_id']] = array( - 'value' => $p['p_id'], - 'name' => $p['p_value'], - 'nameEsc' => addslashes($p['p_value']), - 'default' => ($p['p_id'] == $p_value) - ); - } + $pick_list[$p['p_id']] = array( + 'value' => $p['p_id'], + 'name' => $p['p_value'], + 'nameEsc' => addslashes($p['p_value']), + 'default' => ($p['p_id'] == $p_value) + ); // Check for selected option if ($p['p_id'] == $p_value) { diff --git a/misc/databaseScripts/create_database_V0.1.sql b/misc/databaseScripts/create_database_V1.0.30.sql similarity index 80% rename from misc/databaseScripts/create_database_V0.1.sql rename to misc/databaseScripts/create_database_V1.0.30.sql index 3fc87ceb..c9e5964a 100644 --- a/misc/databaseScripts/create_database_V0.1.sql +++ b/misc/databaseScripts/create_database_V1.0.30.sql @@ -372,8 +372,10 @@ CREATE TABLE {prefix}members ( member_type INT NULL, created DATE NULL, name TINYTEXT NULL, + member_slug TINYTEXT NULL, PRIMARY KEY (id), INDEX(name(20)), + INDEX(member_slug(20)), INDEX(created) ); @@ -383,11 +385,10 @@ 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, - short_descr TINYTEXT NULL, + short_descr TEXT NULL, addr1 TINYTEXT NULL, addr2 TINYTEXT NULL, city INT NULL, @@ -477,98 +478,98 @@ CREATE TABLE {prefix}restaurants ( CREATE TABLE {prefix}settings_general ( id INT NOT NULL AUTO_INCREMENT, - admin_debug BOOLEAN DEFAULT true, - admin_debug_verbose BOOLEAN DEFAULT false, - front_debug BOOLEAN DEFAULT false, - front_debug_verbose BOOLEAN DEFAULT false, + admin_debug BOOLEAN DEFAULT '1', + admin_debug_verbose BOOLEAN DEFAULT '0', + front_debug BOOLEAN DEFAULT '0', + front_debug_verbose BOOLEAN DEFAULT '0', 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, - list_show_search_text BOOLEAN DEFAULT true, - list_show_search_category BOOLEAN DEFAULT true, - list_show_search_amenities BOOLEAN DEFAULT true, - list_show_search_alpha BOOLEAN DEFAULT true, - list_show_detail_link BOOLEAN DEFAULT true, - list_show_logo BOOLEAN DEFAULT true, + maps_default_lat FLOAT DEFAULT '45.3749', + maps_default_lon FLOAT DEFAULT '-84.9592', + maps_default_zoom INTEGER DEFAULT '10', + time_zone TINYTEXT DEFAULT NULL, + canonical_member_page TINYTEXT DEFAULT NULL, + list_show_map BOOLEAN DEFAULT '1', + list_show_list BOOLEAN DEFAULT '1', + list_show_search BOOLEAN DEFAULT '1', + list_show_search_text BOOLEAN DEFAULT '1', + list_show_search_category BOOLEAN DEFAULT '1', + list_show_search_amenities BOOLEAN DEFAULT '1', + list_show_search_alpha BOOLEAN DEFAULT '1', + list_show_detail_link BOOLEAN DEFAULT '1', + list_show_logo BOOLEAN DEFAULT '1', list_logo_size TINYTEXT NULL, - list_show_address BOOLEAN DEFAULT true, - list_show_street BOOLEAN DEFAULT true, - list_show_citystatezip BOOLEAN DEFAULT true, - list_show_country BOOLEAN DEFAULT true, - list_show_region BOOLEAN DEFAULT true, - list_show_descr BOOLEAN DEFAULT false, - list_show_short_descr BOOLEAN DEFAULT true, - list_show_phone BOOLEAN DEFAULT true, - 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, - list_map_show_detaillink BOOLEAN DEFAULT true, - list_map_show_logo BOOLEAN DEFAULT false, + list_show_address BOOLEAN DEFAULT '1', + list_show_street BOOLEAN DEFAULT '1', + list_show_citystatezip BOOLEAN DEFAULT '1', + list_show_country BOOLEAN DEFAULT '1', + list_show_region BOOLEAN DEFAULT '1', + list_show_descr BOOLEAN DEFAULT '0', + list_show_short_descr BOOLEAN DEFAULT '1', + list_show_phone BOOLEAN DEFAULT '1', + list_show_tollfree BOOLEAN DEFAULT '1', + list_show_url BOOLEAN DEFAULT '1', + list_show_url_newtarget BOOLEAN DEFAULT '1', + list_show_email BOOLEAN DEFAULT '1', + list_show_categories BOOLEAN DEFAULT '1', + list_show_creditcards BOOLEAN DEFAULT '1', + list_show_amenities BOOLEAN DEFAULT '0', + list_map_show_detaillink BOOLEAN DEFAULT '1', + list_map_show_logo BOOLEAN DEFAULT '0', list_map_logo_size TINYTEXT NULL, - list_map_show_descr BOOLEAN DEFAULT false, - list_map_show_short_descr BOOLEAN DEFAULT true, - list_map_show_address BOOLEAN DEFAULT true, - list_map_show_street BOOLEAN DEFAULT true, - list_map_show_citystatezip BOOLEAN DEFAULT true, - list_map_show_country BOOLEAN DEFAULT true, - list_map_show_region BOOLEAN DEFAULT true, - list_map_show_phone BOOLEAN DEFAULT true, - 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, - detail_show_map BOOLEAN DEFAULT true, - detail_show_directions BOOLEAN DEFAULT true, - detail_show_logo BOOLEAN DEFAULT true, + list_map_show_descr BOOLEAN DEFAULT '0', + list_map_show_short_descr BOOLEAN DEFAULT '1', + list_map_show_address BOOLEAN DEFAULT '1', + list_map_show_street BOOLEAN DEFAULT '1', + list_map_show_citystatezip BOOLEAN DEFAULT '1', + list_map_show_country BOOLEAN DEFAULT '1', + list_map_show_region BOOLEAN DEFAULT '1', + list_map_show_phone BOOLEAN DEFAULT '1', + list_map_show_tollfree BOOLEAN DEFAULT '1', + list_map_show_url BOOLEAN DEFAULT '1', + list_map_show_url_newtarget BOOLEAN DEFAULT '1', + list_map_show_email BOOLEAN DEFAULT '1', + list_map_show_categories BOOLEAN DEFAULT '0', + list_map_show_creditcards BOOLEAN DEFAULT '0', + list_map_show_amenities BOOLEAN DEFAULT '0', + detail_show_map BOOLEAN DEFAULT '1', + detail_show_directions BOOLEAN DEFAULT '1', + detail_show_logo BOOLEAN DEFAULT '1', detail_logo_size TINYTEXT NULL, - detail_show_descr BOOLEAN DEFAULT true, - detail_show_short_descr BOOLEAN DEFAULT false, - detail_show_address BOOLEAN DEFAULT true, - detail_show_street BOOLEAN DEFAULT true, - detail_show_citystatezip BOOLEAN DEFAULT true, - detail_show_country BOOLEAN DEFAULT true, - detail_show_region BOOLEAN DEFAULT true, - detail_show_phone BOOLEAN DEFAULT true, - 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_show_descr BOOLEAN DEFAULT '1', + detail_show_short_descr BOOLEAN DEFAULT '0', + detail_show_address BOOLEAN DEFAULT '1', + detail_show_street BOOLEAN DEFAULT '1', + detail_show_citystatezip BOOLEAN DEFAULT '1', + detail_show_country BOOLEAN DEFAULT '1', + detail_show_region BOOLEAN DEFAULT '1', + detail_show_phone BOOLEAN DEFAULT '1', + detail_show_tollfree BOOLEAN DEFAULT '1', + detail_show_url BOOLEAN DEFAULT '1', + detail_show_url_newtarget BOOLEAN DEFAULT '1', + detail_show_email BOOLEAN DEFAULT '1', + detail_show_categories BOOLEAN DEFAULT '1', + detail_show_creditcards BOOLEAN DEFAULT '1', + detail_show_amenities BOOLEAN DEFAULT '1', + detail_show_imagegallery BOOLEAN DEFAULT '1', + detail_show_coupons BOOLEAN DEFAULT '0', + detail_show_packages BOOLEAN DEFAULT '0', + detail_map_show_logo BOOLEAN DEFAULT '0', detail_map_logo_size TINYTEXT NULL, - detail_map_show_descr BOOLEAN DEFAULT false, - detail_map_show_short_descr BOOLEAN DEFAULT true, - detail_map_show_address BOOLEAN DEFAULT true, - detail_map_show_street BOOLEAN DEFAULT true, - detail_map_show_citystatezip BOOLEAN DEFAULT true, - detail_map_show_country BOOLEAN DEFAULT true, - detail_map_show_region BOOLEAN DEFAULT true, - detail_map_show_phone BOOLEAN DEFAULT true, - 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, + detail_map_show_descr BOOLEAN DEFAULT '0', + detail_map_show_short_descr BOOLEAN DEFAULT '1', + detail_map_show_address BOOLEAN DEFAULT '1', + detail_map_show_street BOOLEAN DEFAULT '1', + detail_map_show_citystatezip BOOLEAN DEFAULT '1', + detail_map_show_country BOOLEAN DEFAULT '1', + detail_map_show_region BOOLEAN DEFAULT '1', + detail_map_show_phone BOOLEAN DEFAULT '1', + detail_map_show_tollfree BOOLEAN DEFAULT '1', + detail_map_show_url BOOLEAN DEFAULT '1', + detail_map_show_url_newtarget BOOLEAN DEFAULT '1', + detail_map_show_email BOOLEAN DEFAULT '1', + detail_map_show_categories BOOLEAN DEFAULT '0', + detail_map_show_creditcards BOOLEAN DEFAULT '0', + detail_map_show_amenities BOOLEAN DEFAULT '0', PRIMARY KEY (id) ); diff --git a/misc/databaseScripts/drop_database_V0.1.sql b/misc/databaseScripts/drop_database_V1.0.30.sql similarity index 100% rename from misc/databaseScripts/drop_database_V0.1.sql rename to misc/databaseScripts/drop_database_V1.0.30.sql diff --git a/misc/databaseScripts/update_database_V1.0.30.php b/misc/databaseScripts/update_database_V1.0.30.php new file mode 100644 index 00000000..8d4b8964 --- /dev/null +++ b/misc/databaseScripts/update_database_V1.0.30.php @@ -0,0 +1,25 @@ +wpdb->get_results('SELECT id, name FROM '.GLM_MEMBERS_PLUGIN_DB_PREFIX.'members;', ARRAY_A); +if ($memberRecords && count($memberRecords) > 0) { + foreach ($memberRecords as $m) { + $slug = sanitize_title($m['name']); + $this->wpdb->update( + GLM_MEMBERS_PLUGIN_DB_PREFIX.'members', + array( + 'member_slug' => $slug + ), + array( 'id' => $m['id'] ), + array( '%s' ), + array( '%d') + ); + } +} + +?> \ No newline at end of file diff --git a/misc/databaseScripts/update_database_V1.0.30.sql b/misc/databaseScripts/update_database_V1.0.30.sql new file mode 100644 index 00000000..fde35512 --- /dev/null +++ b/misc/databaseScripts/update_database_V1.0.30.sql @@ -0,0 +1,18 @@ +-- 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}members ADD COLUMN member_slug TINYTEXT; + +---- + +ALTER TABLE {prefix}member_info DROP COLUMN member_slug; + +---- + +ALTER TABLE {prefix}member_info MODIFY short_descr TEXT; + diff --git a/models/admin/management/development.php b/models/admin/management/development.php index ee2b9bb1..b718ac78 100644 --- a/models/admin/management/development.php +++ b/models/admin/management/development.php @@ -308,6 +308,7 @@ class GlmMembersAdmin_management_development // 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 diff --git a/models/admin/management/import.php b/models/admin/management/import.php index bd269957..dfc11785 100644 --- a/models/admin/management/import.php +++ b/models/admin/management/import.php @@ -835,12 +835,14 @@ class GlmMembersAdmin_management_import 'access' => $this->config['memb_access_numb']['Full'], 'member_type' => $defaultMemberType, 'created' => date('Y-m-d'), - 'name' => $val['member_name'] + 'name' => $val['member_name'], + 'member_slug' => sanitize_title($val['member_name']), ), array( '%d', '%d', '%s', + '%s', '%s' ) ); @@ -849,7 +851,8 @@ class GlmMembersAdmin_management_import // Create truncated short_descr from descritions - Less tags, html encoded characters, newlines, tabs, etc. $stripped = str_replace(PHP_EOL, '', preg_replace('/\t+/', '', preg_replace("/&#?[a-z0-9]{2,8};/i", "", strip_tags($val['description'])))); - $short_descr = implode(' ', array_slice(explode(' ', $stripped), 0, 190)); + $short_descr = implode(' ', array_slice(explode(' ', $stripped), 0, 30)); + if (strlen($short_descr) < strlen($stripped)) { $short_descr .= ' ...'; } @@ -869,7 +872,6 @@ 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'], @@ -896,7 +898,6 @@ class GlmMembersAdmin_management_import array( '%d', '%s', - '%s', '%d', '%s', '%s', diff --git a/models/front/members/detail.php b/models/front/members/detail.php index 179f569c..5db68561 100644 --- a/models/front/members/detail.php +++ b/models/front/members/detail.php @@ -13,6 +13,43 @@ * @version 0.1 */ +// Translation table for [glm-member-detail] "show" options to configuration parameters +$GLOBALS['showOpts'] = array( + 'map' => 'detail_show_map', + 'map-logo' => 'detail_map_show_logo', + 'map-description' => 'detail_map_show_descr', + 'map-short-description' => 'detail_map_show_short_descr', + 'map-address' => 'detail_map_show_address', + 'map-street' => 'detail_map_show_street', + 'map-city-state-zip' => 'detail_map_show_citystatezip', + 'map-country' => 'detail_map_show_country', + 'map-region' => 'detail_map_show_region', + 'map-phone' => 'detail_map_show_phone', + 'map-toll-free' => 'detail_map_show_tollfree', + 'map-url' => 'detail_map_show_url', + 'map-url-new-target' => 'detail_map_show_url_newtarget', + 'map-email' => 'detail_map_show_email', + 'map-categories' => 'detail_map_show_categories', + 'map-credit-cards' => 'detail_map_show_creditcards', + 'map-amentities' => 'detail_map_show_amenities', + 'logo' => 'detail_show_logo', + 'address' => 'detail_show_address', + 'street' => 'detail_show_street', + 'city-state-zip' => 'detail_show_citystatezip', + 'country' => 'detail_show_country', + 'region' => 'detail_show_region', + 'description' => 'detail_show_descr', + 'short-description' => 'detail_show_short_descr', + 'phone' => 'detail_show_phone', + 'toll-free' => 'detail_show_tollfree', + 'url' => 'detail_show_url', + 'url-new-target' => 'detail_show_url_newtarget', + 'email' => 'detail_show_email', + 'categories' => 'detail_show_categories', + 'credit-cards' => 'detail_show_creditcards', + 'amentities' => 'detail_show_amenities' +); + // Load Members data abstract require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); @@ -98,14 +135,88 @@ 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; - // If member ID submitted in the URL - if (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) { + // Check for "show" shortcode parameter + $settings = array(); + $showList = $actionData['request']['show']; +echo "$showList
"; + + if ($showList) { + + // Separate options and see if we have any + $show = explode(',', $showList); + if (count($show) > 0) { + + // For each option + foreach ($show as $s) { + + $s = trim($s); + + // If we're setting all + if ($s == 'all') { + + while (list($key, $val) = each($GLOBALS['showOpts'])) { + $settings[$val] = true; + } + + // Or we're clearing all + } elseif ($s == 'none') { +echo "Here"; + while (list($key, $val) = each($GLOBALS['showOpts'])) { + $settings[$val] = false; + } + + // Or it's a single option + } else { + + // Check if we're setting or clearing + $tf = $s[0]; + if ($tf == '+') { + $tf = true; + } elseif ($tf == '-') { + $tf = false; + } else { + $tf = null; + } + + // If we have +/- and we have the key in our showOpts array + $k = substr($s, 1); + if ($tf !== null && isset($GLOBALS['showOpts'][$k])) { + + // Get the name of the configuration option + $c = $GLOBALS['showOpts'][$k]; + + // If the configuration option exists, add to list of modified settings + if (isset($this->config['settings'][$c])) { + $settings[$c] = $tf; + } + } + + } + + } + + } + } + + + // If we have a member slug supplied from a rewrite - get the id + $rrMemberSlug = get_query_var('memberslug', ''); + if ($rrMemberSlug != '') { + + $sql = " + SELECT id + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members + WHERE member_slug = '$rrMemberSlug' + ;"; + $id = $this->wpdb->get_var($sql); + + // Otherwise if member ID submitted in the URL + } elseif (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) { $id = ($_REQUEST['id'] - 0); @@ -175,7 +286,8 @@ class GlmMembersFront_members_detail extends GlmDataMemberInfo 'menuItemRedirect' => false, 'modelRedirect' => false, 'view' => 'front/members/detail.html', - 'data' => $templateData + 'data' => $templateData, + 'settings' => $settings ); } diff --git a/models/front/members/list.php b/models/front/members/list.php index c99b0601..92ec8e1c 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -13,6 +13,51 @@ * @version 0.1 */ +// Translation table for [glm-members-list] "show" options to configuration parameters +$GLOBALS['showOpts'] = array( + 'map' => 'list_show_map', + 'map-name-link' => 'list_map_show_detaillink', + 'map-logo' => 'list_map_show_logo', + 'map-description' => 'list_map_show_descr', + 'map-short-description' => 'list_map_show_short_descr', + 'map-address' => 'list_map_show_address', + 'map-street' => 'list_map_show_street', + 'map-city-state-zip' => 'list_map_show_citystatezip', + 'map-country' => 'list_map_show_country', + 'map-region' => 'list_map_show_region', + 'map-phone' => 'list_map_show_phone', + 'map-toll-free' => 'list_map_show_tollfree', + 'map-url' => 'list_map_show_url', + 'map-url-new-target' => 'list_map_show_url_newtarget', + 'map-email' => 'list_map_show_email', + 'map-categories' => 'list_map_show_categories', + 'map-credit-cards' => 'list_map_show_creditcards', + 'map-amentities' => 'list_map_show_amenities', + 'search' => 'list_show_search', + 'search-text' => 'list_show_search_text', + 'search-categories' => 'list_show_search_category', + 'search-amenities' => 'list_show_search_amenities', + 'search-alpha' => 'list_show_search_alpha', + 'list' => 'list_show_list', + 'name-link' => 'list_show_detail_link', + 'logo' => 'list_show_logo', + 'address' => 'list_show_address', + 'street' => 'list_show_street', + 'city-state-zip' => 'list_show_citystatezip', + 'country' => 'list_show_country', + 'region' => 'list_show_region', + 'description' => 'list_show_descr', + 'short-description' => 'list_show_short_descr', + 'phone' => 'list_show_phone', + 'toll-free' => 'list_show_tollfree', + 'url' => 'list_show_url', + 'url-new-target' => 'list_show_url_newtarget', + 'email' => 'list_show_email', + 'categories' => 'list_show_categroies', + 'credit-cards' => 'list_show_creditcards', + 'amentities' => 'list_show_amenities' +); + // Load Members data abstract require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); @@ -107,6 +152,68 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $haveFilter = false; $textSearch = ''; + // Check for "show" shortcode parameter + $settings = array(); + $showList = $actionData['request']['show']; + + if ($showList) { + + // Separate options and see if we have any + $show = explode(',', $showList); + if (count($show) > 0) { + + // For each option + foreach ($show as $s) { + + $s = trim($s); + + // If we're setting all + if ($s == 'all') { + + while (list($key, $val) = each($GLOBALS['showOpts'])) { + $settings[$val] = true; + } + + // Or we're clearing all + } elseif ($s == 'none') { + + while (list($key, $val) = each($GLOBALS['showOpts'])) { + $settings[$val] = false; + } + + // Or it's a single option + } else { + + // Check if we're setting or clearing + $tf = $s[0]; + if ($tf == '+') { + $tf = true; + } elseif ($tf == '-') { + $tf = false; + } else { + $tf = null; + } + + // If we have +/- and we have the key in our showOpts array + $k = substr($s, 1); + if ($tf !== null && isset($GLOBALS['showOpts'][$k])) { + + // Get the name of the configuration option + $c = $GLOBALS['showOpts'][$k]; + + // If the configuration option exists, add to list of modified settings + if (isset($this->config['settings'][$c])) { + $settings[$c] = $tf; + } + } + + } + + } + + } + } + // Apply any provided text search to name, description, short description, and street address if (isset($_REQUEST['textSearch']) && $_REQUEST['textSearch'] != '') { $textSearch = filter_input(INPUT_POST, 'textSearch', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); @@ -164,7 +271,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $categoryData[$c[0]]['default'] = true; } - + // Get amenity filter data $amenityData = false; @@ -228,7 +335,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo /* * Get a current list of members */ - + // Get member list and sort $list = $this->getList($where.$alphaWhere, 'member_name'); @@ -273,7 +380,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo 'menuItemRedirect' => false, 'modelRedirect' => false, 'view' => 'front/members/list.html', - 'data' => $templateData + 'data' => $templateData, + 'settings' => $settings ); } diff --git a/views/admin/member/index.html b/views/admin/member/index.html index c957fb79..bf7d4add 100644 --- a/views/admin/member/index.html +++ b/views/admin/member/index.html @@ -34,6 +34,17 @@ {if $member.fieldFail.name}

{$member.fieldFail.name}

{/if} + + + + Name for URLs: + + + {if $member.fieldFail.member_slug}

{$member.fieldFail.member_slug}

{/if} + + + + Access: diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index 92e8e641..c4eba6eb 100644 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -43,13 +43,6 @@ 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 0379c8c4..b37fd3f8 100644 --- a/views/admin/shortcodes/index.html +++ b/views/admin/shortcodes/index.html @@ -20,12 +20,17 @@ + + + @@ -34,18 +39,77 @@ category="{ category ID(s) }" + + + + + + + + @@ -54,6 +118,7 @@ id="{ member ID }" + + + + +
ShortcodeAttributeDescription
[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. +

+

The "category" attribute is used display only members in a specific category or ctegories. To select multiple categories, separate the categories with a ",". Categories are specified by ID number. The ID for each category is - shown in the Member Categories list. + shown in the Member Categories list. +

  + show="{ content to show }" + +

+ The "show" attribute is used control what content should be displayed in the + member list. The default is to show the content selected in the "Management", + "General Settings" page under "Member List Page Options". +

+

+ Content to show or not show is specified by a comma separated list of the + items listed below. Each item must be preceeded by either a "+" or a "-" to + indecate whether the that content should or should not be shown. +

+

+ There are two special items "all" and "none". These should not have a "+" or + "-" in front of them and should be the first item in the comma separated + list. These can be used to turn all content on or turn all content off. Any + items listed after this will add or remove those items from being displayed. +

+

+ The only content that may not be dissabled is the member name. This will always + show regardless of any settings, although there is a setting to show this as a + link or not as a link. +

+

+ + + + + + + + + + + + + + + + + + + + +
Global Options
allnone
Map Options
mapmap-name-linkmap-logo
map-descriptionmap-short-descriptionmap-address
map-streetmap-city-state-zipmap-country
map-regionmap-phonemap-toll-free
map-urlmap-url-new-targetmap-email
map-categoriesmap-credit-cardsmap-amentities
Search Form Options
searchsearch-textsearch-categories
search-amenitiessearch-alpha
Member List Options
listname-linklogo
addressstreetcity-state-zip
countryregiondescription
short-descriptionphonetoll-free
urlurl-new-targetemail
categoriescredit-cardsamentities
+

+
[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. + "id" attribute below is required to specify which member to display. +

+

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 @@ -61,7 +126,58 @@ 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. - +

+
  + show="{ content to show }" + +

+ The "show" attribute is used control what content should be displayed in + member detail. The default is to show the content selected in the "Management", + "General Settings" page under "Member Detail Page Options". +

+

+ Content to show or not show is specified by a comma separated list of the + items listed below. Each item must be preceeded by either a "+" or a "-" to + indecate whether the that content should or should not be shown. +

+

+ There are two special items "all" and "none". These should not have a "+" or + "-" in front of them and should be the first item in the comma separated + list. These can be used to turn all content on or turn all content off. Any + items listed after this will add or remove those items from being displayed. +

+

+ The only content that may not be dissabled is the member name. This will always + show regardless of any settings, although there is a setting to show this as a + link or not as a link. +

+

+ + + + + + + + + + + + + + + + + + + +
Global Options
allnone
Map Options
mapmap-logomap-description
map-short-descriptionmap-addressmap-street
map-city-state-zipmap-countrymap-region
map-phonemap-toll-freemap-url
map-url-new-targetmap-emailmap-categories
map-credit-cardsmap-amentities
Directions Options
directions
Member Detail Options
logoaddressstreet
city-state-zipcountryregion
descriptionshort-descriptionphone
toll-freeurlurl-new-target
emailcategoriescredit-cards
amentities
+

-- 2.17.1