From 8e1853e0f3ee1f73c07fc73965e4bc400c7fd567 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 12 Aug 2016 13:37:58 -0400 Subject: [PATCH] Added region-search parameter to glm-members-list shortcode. Added ID to regions list. Updated error pages for admin and front-end. Added sending E-mail to errors@gaslightmedia.com when front-end error occurs. Added XML Sitemap --- controllers/front.php | 26 +++++- models/admin/ajax/memberClickThrough.php | 2 +- models/admin/ajax/memberGraphs.php | 106 ++++++++++++++--------- models/admin/member/index.php | 2 +- models/admin/settings/regions.php | 2 +- models/front/members/list.php | 12 ++- setup/shortcodes.php | 12 +++ views/admin/error/badAction.html | 38 ++++++-- views/admin/error/header.html | 5 +- views/admin/error/index.html | 40 ++++++--- views/admin/member/index.html | 38 ++++---- views/admin/settings/regions.html | 2 + views/front/error/badAction.html | 36 ++++++-- views/front/error/header.html | 3 - views/front/error/index.html | 36 +++++--- 15 files changed, 252 insertions(+), 108 deletions(-) diff --git a/controllers/front.php b/controllers/front.php index b078c925..926eaaa4 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -487,8 +487,32 @@ class glmMembersFront extends GlmPluginSupport // If there was an error if ($errorMsg != '') { + $mailMsg = " +

An error occurred while running the request below.

+ +
+                
+                
+                
+                
+                
+                
+                
+                
+                
+                
+                
+                
+                
Error Msg: $errorMsg
Server: ".$_SERVER['SERVER_NAME']."
Method: ".$_SERVER['REQUEST_METHOD']."
Time: ".date('r', $_SERVER['REQUEST_TIME'])."
Query: ".$_SERVER['QUERY_STRING']."
Referer: ".$_SERVER['HTTP_REFERER']."
User Agent: ".$_SERVER['HTTP_USER_AGENT']."
Remote Addr: ".$_SERVER['REMOTE_ADDR']."
Filename: ".$_SERVER['SCRIPT_FILENAME']."
URI: ".$_SERVER['REQUESST_URI']."
Request Data: ".print_r($_REQUEST,1)."
+
+ "; + mail ( + 'errors@gaslightmedia.com', + 'Front-End GLM Associate Error', + $mailMsg + ); $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/views'; - $view = 'front/error/index.html'; + $viewFile = 'front/error/index.html'; require_once (GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/models/front/error/index.php'); $model = new GlmMembersFront_error_index($this->wpdb, $this->config); $results = $model->modelAction($actionData); diff --git a/models/admin/ajax/memberClickThrough.php b/models/admin/ajax/memberClickThrough.php index 54a6dc9f..9c9835c1 100644 --- a/models/admin/ajax/memberClickThrough.php +++ b/models/admin/ajax/memberClickThrough.php @@ -124,7 +124,7 @@ class GlmMembersAdmin_ajax_memberClickThrough extends GlmDataMembers UPDATE clicks = clicks + 1; "); - // Week count - stat_type = 3 + // Month count - stat_type = 3 $this->wpdb->query(" INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats (member, stat_type, stat_date, clicks) diff --git a/models/admin/ajax/memberGraphs.php b/models/admin/ajax/memberGraphs.php index 736dd7d8..1d975e7b 100644 --- a/models/admin/ajax/memberGraphs.php +++ b/models/admin/ajax/memberGraphs.php @@ -94,64 +94,86 @@ class GlmMembersAdmin_ajax_memberGraphs extends GlmDataMembers // Use selected graph type switch ($_GET['graphType']) { - - case 'clicksDays': - - // Get the current date, and start date (past month) - $today = date('Y-m-d', strtotime('+1 days')); - $startDate = date('Y-m-d', strtotime('-1 month')); - + case 'clicks': $statTable = 'clickthrough_stats'; - $statDateWhere = "stat_date BETWEEN '$startDate' AND '$today'"; - $graphTitle = $memb['name']." - Clicks this week"; - - - break; + case 'views': + $statTable = 'member_detail_stats'; + $graphTitle = $memb['name']." - Views this week"; + break; + default: + trigger_error ( "memberGraphs via AJAX - Graph Type invalid ".$_GET['graphType'], E_USER_NOTICE); + wp_die(); + break; + } - case 'viewsDays': + // Use selected time period + switch ($_GET['graphPeriod']) { + + case 'oneMonth': // Get the current date, and start date (past month) $today = date('Y-m-d', strtotime('+1 days')); $startDate = date('Y-m-d', strtotime('-1 month')); + $statsThisMonthWhere = "stat_date BETWEEN '$startDate' AND '$today'"; + + // Get stats for the past month + $dayCounts = $this->wpdb->get_results(" + SELECT stat_date, COALESCE (clicks, 0) as clicks + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."$statTable + WHERE member = $memberId + AND stat_type = 1 + AND $statsThisMonthWhere + ORDER BY stat_date + ", ARRAY_A); + + $data = array(); + + // Build default date values + for ($t=strtotime($startDate) ; $t<=strtotime($today) ; $t=strtotime(date('Y-m-d',$t).' +1 day') ) { + $data[date('n/d',$t)] = 0; + } + + if (count($dayCounts) > 0) { + foreach ($dayCounts as $c) { + $data[date('n/d', strtotime($c['stat_date']))] = $c['clicks']; + } + } - $statTable = 'member_detail_stats'; - $statDateWhere = "stat_date BETWEEN '$startDate' AND '$today'"; + break; - $graphTitle = $memb['name']." - Views this week"; + case 'twoYears': - break; + $thisMonth = date('Y-m-01'); + $startMonth = date('Y-m-01', strtotime('-23 months')); + $stats2YearsWhere = "stat_date BETWEEN '$startMonth' AND '$thisMonth'"; + // Get stats for the past 2 years + $monthCounts = $this->wpdb->get_results(" + SELECT stat_date, COALESCE (clicks, 0) as clicks + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."$statTable + WHERE member = $memberId + AND stat_type = 3 + AND $stats2YearsWhere + ORDER BY stat_date + ", ARRAY_A); - default: - trigger_error ( "memberGraphs via AJAX - Graph Type invalid ".$_GET['graphType'], E_USER_NOTICE); - wp_die(); - break; + $monthData = array(); - } + // Build default date values + for ($t=strtotime($startMonth) ; $t<=strtotime($thisMonth) ; $t=strtotime(date('Y-m-d',$t).' +1 month') ) { + $data[date('Y/m',$t)] = 0; + } - // Get click through data - $clickCounts = $this->wpdb->get_results(" - SELECT stat_date, COALESCE (clicks, 0) as clicks - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."$statTable - WHERE member = $memberId - AND stat_type = 1 - AND $statDateWhere - ORDER BY stat_date - ", ARRAY_A); - - $data = array(); - - // Build default date values - for ($t=strtotime($startDate) ; $t<=strtotime($today) ; $t=strtotime(date('Y-m-d',$t).' +1 day') ) { - $data[date('n/d',$t)] = 0; - } + if (count($monthCounts) > 0) { + foreach ($monthCounts as $c) { + $data[date('Y/m', strtotime($c['stat_date']))] = $c['clicks']; + } + } + + break; - if (count($clickCounts) > 0) { - foreach ($clickCounts as $c) { - $data[date('n/d', strtotime($c['stat_date']))] = $c['clicks']; - } } // Load PHPGraphLib diff --git a/models/admin/member/index.php b/models/admin/member/index.php index d560cf53..3b39b9ff 100644 --- a/models/admin/member/index.php +++ b/models/admin/member/index.php @@ -360,7 +360,7 @@ class GlmMembersAdmin_member_index extends GlmDataMembers * Get member view stats */ - // Get the current date, first date of this wee, and first date of this month + // Get the current date, first date of this week, and first date of this month $today = date('Y-m-d'); $thisWeek = date('Y-m-d', strtotime('-'.date('w').' days')); $thisMonth = date('Y-m-d', strtotime('-'.(date('j')-1).' days')); diff --git a/models/admin/settings/regions.php b/models/admin/settings/regions.php index 72d1e8be..d0e38080 100644 --- a/models/admin/settings/regions.php +++ b/models/admin/settings/regions.php @@ -136,7 +136,7 @@ class GlmMembersAdmin_settings_regions extends GlmDataRegions } // Get a current list of members - $regions = $this->getList(); + $regions = $this->getList('', 'name'); if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { glmMembersAdmin::addNotice($regions, 'DataBlock', 'Region Data'); diff --git a/models/front/members/list.php b/models/front/members/list.php index a2dd4971..311dceae 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -172,6 +172,9 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo if (isset($_REQUEST['amenitySearch'])) { $actionData['request']['amenity-search'] = $_REQUEST['amenitySearch']; } + if (isset($_REQUEST['regionSearch'])) { + $actionData['request']['region-search'] = $_REQUEST['regionSearch']; + } // Check for "show" shortcode parameter (what elements to show on the page) $settings = array(); @@ -385,7 +388,6 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } - // If we have a category ID or IDs if ($catSelectedForQuery != '') { @@ -400,6 +402,14 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } + // If we have a region + if ($actionData['request']['region-search']) { + $regionSearch = $actionData['request']['region-search']-0; + if ($regionSearch > 0) { + $where .= " AND T.region = $regionSearch"; + } + } + // Get amenity filter data $amenityData = false; $amenSelected = ''; diff --git a/setup/shortcodes.php b/setup/shortcodes.php index a48ff402..d42d68cf 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -74,6 +74,7 @@ $glmMembersShortcodes = array( 'category-search' => false, 'text-search' => false, 'amenity-search' => false, + 'region-search' => false, 'alpha' => false, 'blank-start' => false, 'show' => false, @@ -251,6 +252,17 @@ $glmMembersShortcodesDescription = ' +   + + region-search="{ region ID }" + + + The "region-search" attribute selects members who are listed in the specified + region. The region is specified by ID rather than name. This may be overridden by + a "regionSearch" URL parameter. + + +   alpha="{ initial letter of members }" diff --git a/views/admin/error/badAction.html b/views/admin/error/badAction.html index a2035865..3d7b5bc4 100644 --- a/views/admin/error/badAction.html +++ b/views/admin/error/badAction.html @@ -1,11 +1,31 @@ {include file='admin/error/header.html'} - -

Sorry, we've had an error.

- -

Error: : An invalid action has been specified.

- - {if $errorMsg}

{$errorMsg}

{/if} - -

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

- +
+
+
+

Aw shucks!

+

We couldn't get you the page you wanted.

+
+

+ Yes, something went wrong, but we really want to make it right. In fact, we've already + notified our hard-working Web crew that you had this problem and will do what we can + to make sure it doesn't happen again. +

+

+ As far as we can tell now, an invalid action has been requested. This really shouldn't + happen, so we're going to research this to see if we can avoid this in the future. +

+ {if isset($errorMsg) && $errorMsg} +

Oh, we have a little more information for you.

+

{$errorMsg}

+ {/if} + +

+ Please head back to the link below and try again. If you continue to get this error, + please call for assistance. +

+

Return to Home Page

+
+
+
+
{include file='admin/footer.html'} diff --git a/views/admin/error/header.html b/views/admin/error/header.html index f9fdb916..378473b8 100644 --- a/views/admin/error/header.html +++ b/views/admin/error/header.html @@ -1,5 +1,2 @@
- -

{$glmPluginName}

- - \ No newline at end of file + diff --git a/views/admin/error/index.html b/views/admin/error/index.html index 9a763ebd..687fdfd1 100644 --- a/views/admin/error/index.html +++ b/views/admin/error/index.html @@ -1,14 +1,32 @@ {include file='admin/error/header.html'} - -
- -

Sorry, we've had some type of fatal error.

- {if $reason} -

{$reason}

- {/if} -

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

- -
- +
+
+
+

Aw shucks!

+

We couldn't get you the page you wanted.

+
+

+ Yes, something went wrong, but we really want to make it right. In fact, we've already + notified our hard-working Web crew that you had this problem and will do what we can + to make sure it doesn't happen again. +

+

+ As far as we can tell now, an invalid action has been requested. This really shouldn't + happen, so we're going to research this to see if we can avoid this in the future. +

+ {if isset($reason) && $reason} +

Oh, we have a little more information for you.

+

{$reason}

+ {/if} + +

+ Please head back to the link below and try again. If you continue to get this error, + please call for assistance. +

+

Return to Home Page

+
+
+
+
{include file='admin/footer.html'} diff --git a/views/admin/member/index.html b/views/admin/member/index.html index b51df2bd..d633d530 100644 --- a/views/admin/member/index.html +++ b/views/admin/member/index.html @@ -58,11 +58,16 @@
{$member.fieldData.name} -
+

{$thisDate} URL Click-Through Counts for Past Month -

- +

+ +

+ {$thisDate} + URL Click-Through Counts for Past 2 Years +

+
Print
@@ -75,7 +80,12 @@ {$thisDate} Detail Page Views for Past Month
- + +
+ {$thisDate} + Detail Page Views for Past 2 Years +
+
Print
@@ -182,26 +192,22 @@ }); }); - - // Display selected graph dialog box $('.dialog-button').click( function() { - $(".graph-dialog").dialog("close"); + $(".graph-dialog").dialog("close"); var graph = $(this).attr('data-type'); $('#' + graph).dialog("open"); return false; }); - - - $('#showArchived').click( function() { - checked = 'false'; - if ($(this).attr('checked') == 'checked') { - checked = 'true'; - } + $('#showArchived').click( function() { + checked = 'false'; + if ($(this).attr('checked') == 'checked') { + checked = 'true'; + } window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=index&member={$memberID}&showArchived=" + checked); - }); - + }); + // Flash certain elements for a short time after display $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500); diff --git a/views/admin/settings/regions.html b/views/admin/settings/regions.html index 9867d717..d048fcbe 100644 --- a/views/admin/settings/regions.html +++ b/views/admin/settings/regions.html @@ -78,6 +78,7 @@ + @@ -93,6 +94,7 @@ {else} {/if} + diff --git a/views/front/error/badAction.html b/views/front/error/badAction.html index a19e0f9a..4ed0162a 100644 --- a/views/front/error/badAction.html +++ b/views/front/error/badAction.html @@ -1,9 +1,31 @@ {include file='front/error/header.html'} - -

Sorry, we've had an error.

- -

Error: : An invalid action or Shortcode attribute has been specified.

- -

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

- +
+
+
+

Aw shucks!

+

We couldn't get you the page you wanted.

+
+

+ Yes, something went wrong, but we really want to make it right. In fact, we've already + notified our hard-working Web crew that you had this problem and will do what we can + to make sure it doesn't happen again. +

+

+ As far as we can tell now, an invalid action has been requested. This really shouldn't + happen, so we're going to research this to see if we can avoid this in the future. +

+ {if isset($errorMsg) && $errorMsg} +

Oh, we have a little more information for you.

+

{$errorMsg}

+ {/if} + +

+ Please head back to the link below and try again. If you continue to get this error, + please call for assistance. +

+

Return to Home Page

+
+
+
+
{include file='front/footer.html'} diff --git a/views/front/error/header.html b/views/front/error/header.html index 2b17b0e1..71bb229f 100644 --- a/views/front/error/header.html +++ b/views/front/error/header.html @@ -1,4 +1 @@
- - - \ No newline at end of file diff --git a/views/front/error/index.html b/views/front/error/index.html index 16f771fd..9914f318 100644 --- a/views/front/error/index.html +++ b/views/front/error/index.html @@ -1,14 +1,28 @@ {include file='front/error/header.html'} - -
- -

Sorry, we've had some type of fatal error.

- - {if $errorMsg}

{$errorMsg}

{/if} - -

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

- -
- +
+
+
+

Aw shucks!

+

We couldn't get you the page you wanted.

+
+

+ Yes, something went wrong, but we really want to make it right. In fact, we've already + notified our hard-working Web crew that you had this problem and will do what we can + to make sure it doesn't happen again. +

+ {if isset($errorMsg) && $errorMsg} +

Oh, we have a little more information for you.

+

{$errorMsg}

+ {/if} + +

+ Please head back to the link below and try again. If you continue to get this error, + please call for assistance. +

+

Return to Home Page

+
+
+
+
{include file='front/footer.html'} -- 2.17.1
ID Region Description Short Description
{$t.id} {$t.name}