From a8d4e97ea450bb2932e631e909dc7723f7e1a789 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 11 Apr 2017 11:58:18 -0400 Subject: [PATCH] Added management options to turn on/off Member Info edit tabs. Added tests for those options in the Member Info edit views. Added teste for those options in necessary data classes to avoid problems with related data not being submitted. Added tests to front/members/list.php model to avoid problems with that data not being submitted. Added "blankStart" URL op[tion for member lists that can override the "blank-start' shortcode option. Fixed issues in the list.php code when overriding blank-start. --- classes/data/dataFiles.php | 5 ++ classes/data/dataImages.php | 5 ++ classes/data/dataMemberInfo.php | 41 ++++++++++---- classes/data/settings/dataSettingsGeneral.php | 54 +++++++++++++++++++ classes/memberDataByLatLon.php | 14 +++-- index.php | 2 +- models/front/members/list.php | 6 +++ ...1.1.28.sql => create_database_V1.1.29.sql} | 7 +++ setup/databaseScripts/dbVersions.php | 3 +- ..._V1.1.28.sql => drop_database_V1.1.29.sql} | 0 .../update_database_V1.1.28.sql | 2 +- .../update_database_V1.1.29.sql | 34 ++++++++++++ views/admin/management/index.html | 18 ++++++- views/admin/member/index.html | 2 +- views/admin/member/memberInfo.html | 29 +++++----- views/front/members/detail.html | 6 ++- views/front/members/list.html | 8 +-- 17 files changed, 191 insertions(+), 45 deletions(-) rename setup/databaseScripts/{create_database_V1.1.28.sql => create_database_V1.1.29.sql} (98%) rename setup/databaseScripts/{drop_database_V1.1.28.sql => drop_database_V1.1.29.sql} (100%) create mode 100644 setup/databaseScripts/update_database_V1.1.29.sql diff --git a/classes/data/dataFiles.php b/classes/data/dataFiles.php index 80db532b..d38d03e8 100644 --- a/classes/data/dataFiles.php +++ b/classes/data/dataFiles.php @@ -275,6 +275,11 @@ class GlmDataFiles extends GlmDataAbstract public function filePositionOrder($refType, $refID, $orderField) { + // If the Member Info "Files" tab is turned off, don't do anything here. + if(!$this->config['settings']['memb_info_files']) { + return true; + } + // Check for and retrieve the order field name if (isset($_REQUEST[$orderField]) && trim($_REQUEST[$orderField]) == '') { diff --git a/classes/data/dataImages.php b/classes/data/dataImages.php index 761a0cc4..cd7c3f31 100644 --- a/classes/data/dataImages.php +++ b/classes/data/dataImages.php @@ -282,6 +282,11 @@ class GlmDataImages extends GlmDataAbstract public function galleryPositionOrder($refType, $refID, $orderField) { + // If the Member Info "Images" tab is turned off, don't do anything here. + if(!$this->config['settings']['memb_info_images']) { + return true; + } + // Check for and retrieve the order field name if (isset($_REQUEST[$orderField]) && trim($_REQUEST[$orderField]) == '') { diff --git a/classes/data/dataMemberInfo.php b/classes/data/dataMemberInfo.php index 1d1220fe..32dfb0b7 100644 --- a/classes/data/dataMemberInfo.php +++ b/classes/data/dataMemberInfo.php @@ -507,6 +507,20 @@ class GlmDataMemberInfo extends GlmDataAbstract ); + // Unset some fields if certain member info tabs are off to avoid error messages. + if(!$this->config['settings']['memb_info_contact']) { + unset($this->fields['phone']); + unset($this->fields['toll_free']); + unset($this->fields['mailing_city']); + } + if(!$this->config['settings']['memb_info_location']) { + unset($this->fields['lat']); + unset($this->fields['lon']); + unset($this->fields['city']); + unset($this->fields['region']); + unset($this->fields['county']); + } + if (is_admin() && GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table); } @@ -530,10 +544,15 @@ class GlmDataMemberInfo extends GlmDataAbstract public function entryPostProcessing($r, $a) { - // Set flag if Lat or Lon are 0 - $r['bad_lat_lon'] = false; - if ($r['lat'] == 0 || $r['lon'] == 0) { - $r['bad_lat_lon'] = true; + // Only if the Member Info "Location" tab is turned on should we do this + if($this->config['settings']['memb_info_location'] && isset($r['lat']) && isset($r['lon'])) { + + // Set flag if Lat or Lon are 0 + $r['bad_lat_lon'] = false; + if ($r['lat'] == 0 || $r['lon'] == 0) { + $r['bad_lat_lon'] = true; + } + } // Only run these tests for 'l' (getList), 'g' (getEntry), 'e' (editEntry), 'u' (updateEntry) @@ -765,24 +784,24 @@ class GlmDataMemberInfo extends GlmDataAbstract 'status' => $f['status'], 'create_time' => $f['create_time'], 'modify_time' => $f['modify_time'], - 'lat' => $f['lat'], - 'lon' => $f['lon'] + 'lat' => ($this->config['settings']['memb_info_location'] && isset($v['lat']) ? $v['lat'] : ''), + 'lon' => ($this->config['settings']['memb_info_location'] && isset($v['lon']) ? $v['lon'] : '') ); if ($forMapItems) { $this->fields = array_merge($this->fields, array( 'addr1' => $f['addr1'], 'addr2' => $f['addr2'], - 'city' => $f['city'], + 'city' => ($this->config['settings']['memb_info_location'] && isset($v['city']) ? $v['city'] : ''), 'state' => $f['state'], 'country' => $f['country'], 'zip' => $f['zip'], - 'phone' => $f['phone'], - 'toll_free' => $f['toll_free'], + 'phone' => ($this->config['settings']['memb_info_contact'] && isset($v['phone']) ? $v['phone'] : ''), + 'toll_free' => ($this->config['settings']['memb_info_contact'] && isset($v['toll_free']) ? $v['toll_free'] : ''), 'email' => $f['email'], 'url' => $f['url'], - 'region' => $f['region'], - 'county' => $f['county'], + 'region' => ($this->config['settings']['memb_info_location'] && isset($v['region']) ? $v['region'] : ''), + 'county' => ($this->config['settings']['memb_info_location'] && isset($v['country']) ? $v['country'] : ''), 'cc_type' => $f['cc_type'], 'logo' => $f['logo'], 'descr' => $f['descr'], diff --git a/classes/data/settings/dataSettingsGeneral.php b/classes/data/settings/dataSettingsGeneral.php index a1766091..f5ab9bc4 100644 --- a/classes/data/settings/dataSettingsGeneral.php +++ b/classes/data/settings/dataSettingsGeneral.php @@ -233,6 +233,60 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'use' => 'a' ), + /* + * Member Info edit tab selection + */ + + // Location + 'memb_info_location' => array( + 'field' => 'memb_info_location', + 'type' => 'checkbox', + 'use' => 'a' + ), + + // Contact + 'memb_info_contact' => array( + 'field' => 'memb_info_contact', + 'type' => 'checkbox', + 'use' => 'a' + ), + + // Categories & Amenities + 'memb_info_categories' => array( + 'field' => 'memb_info_categories', + 'type' => 'checkbox', + 'use' => 'a' + ), + + // Images + 'memb_info_images' => array( + 'field' => 'memb_info_images', + 'type' => 'checkbox', + 'use' => 'a' + ), + + // Files + 'memb_info_files' => array( + 'field' => 'memb_info_files', + 'type' => 'checkbox', + 'use' => 'a' + ), + + // Video + 'memb_info_video' => array( + 'field' => 'memb_info_video', + 'type' => 'checkbox', + 'use' => 'a' + ), + + // Live Camera + 'memb_info_cam' => array( + 'field' => 'memb_info_cam', + 'type' => 'checkbox', + 'use' => 'a' + ), + + /* * Front-end Member Search Options */ diff --git a/classes/memberDataByLatLon.php b/classes/memberDataByLatLon.php index f85b1896..12eb1d9f 100644 --- a/classes/memberDataByLatLon.php +++ b/classes/memberDataByLatLon.php @@ -202,23 +202,21 @@ class GlmMembersFront_members_memberDataByLatLon extends GlmDataMemberInfo 'id' => $v['id'], 'member' => $v['member_pointer'], 'member_slug' => $v['member_slug'], - 'lat' => $v['lat'], - 'lon' => $v['lon'], + 'lat' => ($this->config['settings']['memb_info_location'] && isset($v['lat']) ? $v['lat'] : ''), + 'lon' => ($this->config['settings']['memb_info_location'] && isset($v['lon']) ? $v['lon'] : ''), 'name' => $v['member_name'], 'loc_name' => '', 'addr1' => $v['addr1'], 'addr2' => $v['addr2'], - 'city' => $v['city'], + 'city' => ($this->config['settings']['memb_info_location'] && isset($v['city']) ? $v['city'] : ''), 'state' => $v['state']['value'], 'zip' => $v['zip'], 'country' => $v['country']['name'], - 'lat' => $v['lat'], - 'lon' => $v['lon'], - 'phone' => $v['phone'], - 'toll_free' => $v['toll_free'], + 'phone' => ($this->config['settings']['memb_info_contact'] && isset($v['phone']) ? $v['phone'] : ''), + 'toll_free' => ($this->config['settings']['memb_info_contact'] && isset($v['toll_free']) ? $v['toll_free'] : ''), 'email' => $v['email'], 'url' => $v['url'], - 'region' => $v['region'], + 'region' => ($this->config['settings']['memb_info_location'] && isset($v['region']) ? $v['region'] : ''), 'categories' => $cats, 'cc_type' => $v['cc_type'], 'logo' => $v['logo'], diff --git a/index.php b/index.php index e955f141..d6ccbede 100644 --- a/index.php +++ b/index.php @@ -39,7 +39,7 @@ */ define('GLM_MEMBERS_PLUGIN_VERSION', '2.9.14'); -define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.28'); +define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.29'); // Check if plugin version is not current in WordPress option and if needed updated it if (GLM_MEMBERS_PLUGIN_VERSION != get_option('glmMembersDatabasePluginVersion')) { diff --git a/models/front/members/list.php b/models/front/members/list.php index 56d30d85..c3570a66 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -163,6 +163,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $regionSearchSelected = false; $mapItems = false; $multiSelectCats = false; + $filteredMembersFound = false; + $list = false; // Paging Parameters $paging = $this->config['settings']['list_pagination']; // Now this is in management @@ -180,6 +182,9 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } // Check for URL parameter override of shortcode parameters + if (isset($_REQUEST['blankStart'])) { + $actionData['request']['blank-start'] = $_REQUEST['blankStart']; + } if (isset($_REQUEST['categorySearch'])) { $actionData['request']['category-search'] = $_REQUEST['categorySearch']; } @@ -676,6 +681,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo strtolower($actionData['request']['blank-start']) == 'true' && !isset($_REQUEST['glm_action']) ) { $blankStart = true; + $paging = false; // If this is a blank start, then turn off paging to avoid errors } // Check if we're doing paging diff --git a/setup/databaseScripts/create_database_V1.1.28.sql b/setup/databaseScripts/create_database_V1.1.29.sql similarity index 98% rename from setup/databaseScripts/create_database_V1.1.28.sql rename to setup/databaseScripts/create_database_V1.1.29.sql index 71171a0e..73aba4ef 100644 --- a/setup/databaseScripts/create_database_V1.1.28.sql +++ b/setup/databaseScripts/create_database_V1.1.29.sql @@ -292,6 +292,13 @@ CREATE TABLE {prefix}settings_general ( phone_format TINYTEXT DEFAULT NULL, default_state TINYTEXT DEFAULT NULL, enable_counties BOOLEAN DEFAULT '1', + memb_info_location BOOLEAN DEFAULT '1', + memb_info_contact BOOLEAN DEFAULT '1', + memb_info_categories BOOLEAN DEFAULT '1', + memb_info_images BOOLEAN DEFAULT '1', + memb_info_files BOOLEAN DEFAULT '1', + memb_info_video BOOLEAN DEFAULT '1', + memb_info_cam BOOLEAN DEFAULT '1', list_show_map BOOLEAN DEFAULT '1', list_show_list BOOLEAN DEFAULT '1', list_order_list SMALLINT DEFAULT '10', diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 040fc30c..1da40a3a 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -59,7 +59,8 @@ $glmMembersDbVersions = array( '1.1.25' => array('version' => '1.1.25', 'tables' => 18, 'date' => '02/02/17'), '1.1.26' => array('version' => '1.1.26', 'tables' => 18, 'date' => '03/08/17'), '1.1.27' => array('version' => '1.1.27', 'tables' => 19, 'date' => '03/29/17'), - '1.1.28' => array('version' => '1.1.28', 'tables' => 19, 'date' => '04/04/17') + '1.1.28' => array('version' => '1.1.28', 'tables' => 19, 'date' => '04/04/17'), + '1.1.29' => array('version' => '1.1.29', 'tables' => 19, 'date' => '04/10/17') ); diff --git a/setup/databaseScripts/drop_database_V1.1.28.sql b/setup/databaseScripts/drop_database_V1.1.29.sql similarity index 100% rename from setup/databaseScripts/drop_database_V1.1.28.sql rename to setup/databaseScripts/drop_database_V1.1.29.sql diff --git a/setup/databaseScripts/update_database_V1.1.28.sql b/setup/databaseScripts/update_database_V1.1.28.sql index 504f6562..2c3d7e90 100644 --- a/setup/databaseScripts/update_database_V1.1.28.sql +++ b/setup/databaseScripts/update_database_V1.1.28.sql @@ -1,6 +1,6 @@ -- Gaslight Media Members Database -- File Created: 03/29/17 --- Database Version: 1.1.27 +-- Database Version: 1.1.28 -- Database Update From Previous Version Script -- -- To permit each query below to be executed separately, diff --git a/setup/databaseScripts/update_database_V1.1.29.sql b/setup/databaseScripts/update_database_V1.1.29.sql new file mode 100644 index 00000000..14edee5f --- /dev/null +++ b/setup/databaseScripts/update_database_V1.1.29.sql @@ -0,0 +1,34 @@ +-- Gaslight Media Members Database +-- File Created: 03/29/17 +-- Database Version: 1.1.29 +-- 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 dashes +-- Sets which character to use to separate phone numbers + +ALTER TABLE {prefix}settings_general ADD COLUMN memb_info_location BOOLEAN DEFAULT 1; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN memb_info_contact BOOLEAN DEFAULT 1; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN memb_info_categories BOOLEAN DEFAULT 1; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN memb_info_images BOOLEAN DEFAULT 1; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN memb_info_files BOOLEAN DEFAULT 1; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN memb_info_video BOOLEAN DEFAULT 1; + +---- + +ALTER TABLE {prefix}settings_general ADD COLUMN memb_info_cam BOOLEAN DEFAULT 1; diff --git a/views/admin/management/index.html b/views/admin/management/index.html index bc3881a3..d8806fe2 100644 --- a/views/admin/management/index.html +++ b/views/admin/management/index.html @@ -89,7 +89,7 @@ - + + + + + + +

Misc. Settings

Members Related Settings

Enable Members: @@ -103,6 +103,22 @@
Member Info Tabs Selection: + + + + + + + + +
Address & Location
Contact Info
Categories & Amentities
Images
Files
Video
Live Cam
+

Misc. Settings

Google Maps API Key: diff --git a/views/admin/member/index.html b/views/admin/member/index.html index ba06eab7..9ba95936 100644 --- a/views/admin/member/index.html +++ b/views/admin/member/index.html @@ -136,7 +136,7 @@ {$m.create_time.datetime} {$m.modify_time.datetime} - {if $m.bad_lat_lon}Bad Map Location{/if} + {if $settings.memb_info_location} {if $m.bad_lat_lon}Bad Map Location{/if} {/if} {if apply_filters('glm_members_permit_admin_member_index_clone_activate_info_version', true)} Clone  {if $m.status.name != 'Active'}Activate{/if} diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index 85cad94b..f85d1e34 100644 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -101,14 +101,13 @@