Added region-search parameter to glm-members-list shortcode.
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 12 Aug 2016 17:37:58 +0000 (13:37 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 12 Aug 2016 17:37:58 +0000 (13:37 -0400)
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

15 files changed:
controllers/front.php
models/admin/ajax/memberClickThrough.php
models/admin/ajax/memberGraphs.php
models/admin/member/index.php
models/admin/settings/regions.php
models/front/members/list.php
setup/shortcodes.php
views/admin/error/badAction.html
views/admin/error/header.html
views/admin/error/index.html
views/admin/member/index.html
views/admin/settings/regions.html
views/front/error/badAction.html
views/front/error/header.html
views/front/error/index.html

index b078c92..926eaaa 100644 (file)
@@ -487,8 +487,32 @@ class glmMembersFront extends GlmPluginSupport
 
         // If there was an error
         if ($errorMsg != '') {
+            $mailMsg = "
+                <p>An error occurred while running the request below.</p>
+
+                <pre>
+                <table>
+                <tr><th>Error Msg: </th><td>$errorMsg</td></tr>
+                <tr><th>Server: </th><td>".$_SERVER['SERVER_NAME']."</td></tr>
+                <tr><th>Method: </th><td>".$_SERVER['REQUEST_METHOD']."</td></tr>
+                <tr><th>Time: </th><td>".date('r', $_SERVER['REQUEST_TIME'])."</td></tr>
+                <tr><th>Query: </th><td>".$_SERVER['QUERY_STRING']."</td></tr>
+                <tr><th>Referer: </th><td>".$_SERVER['HTTP_REFERER']."</td></tr>
+                <tr><th>User Agent: </th><td>".$_SERVER['HTTP_USER_AGENT']."</td></tr>
+                <tr><th>Remote Addr: </th><td>".$_SERVER['REMOTE_ADDR']."</td></tr>
+                <tr><th>Filename: </th><td>".$_SERVER['SCRIPT_FILENAME']."</td></tr>
+                <tr><th>URI: </th><td>".$_SERVER['REQUESST_URI']."</td></tr>
+                <tr><th valign=\"top\">Request Data: </th><td>".print_r($_REQUEST,1)."</td></tr>
+                </table>
+                </pre>
+                ";
+            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);
index 54a6dc9..9c9835c 100644 (file)
@@ -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)
index 736dd7d..1d975e7 100644 (file)
@@ -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
index d560cf5..3b39b9f 100644 (file)
@@ -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'));
index 72d1e8b..d0e3808 100644 (file)
@@ -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');
index a2dd497..311dcea 100644 (file)
@@ -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 = '';
index a48ff40..d42d68c 100644 (file)
@@ -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 = '
         </td>
     </tr>
     <tr>
+        <td>&nbsp;</td>
+        <th>
+            region-search="{ region ID }"
+        </th>
+        <td>
+            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.
+        </td>
+    </tr>
+        <tr>
         <td>&nbsp;</td>
         <th>
             alpha="{ initial letter of members }"
index a203586..3d7b5bc 100644 (file)
@@ -1,11 +1,31 @@
 {include file='admin/error/header.html'}
-    
-    <h2>Sorry, we've had an error.</h2>
-    
-    <p><b>Error: </b>: An invalid action has been specified.</p>
-    
-    {if $errorMsg}<p>{$errorMsg}</p>{/if}
-
-    <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
-      
+<center>    
+    <div id="glm-admin-content-container" class="glm-center" style="width: 600px; text-align: left; padding: 1em;">       
+        <center>
+            <h1 class="glm-error">Aw shucks!</h1>
+            <h3>We couldn't get you the page you wanted. </h3>
+            <div style="width: 600px; text-align: left;">
+                <p>
+                    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.
+                </p>
+                <p>
+                    As far as we can tell now, <b>an invalid action has been requested</b>. This really shouldn't
+                    happen, so we're going to research this to see if we can avoid this in the future.
+                </p>
+            {if isset($errorMsg) && $errorMsg}
+                <p>Oh, we have a little more information for you.</p>
+                <p>{$errorMsg}</p>
+            {/if}
+                
+                <p>
+                    Please head back to the link below and try again. If you continue to get this error,
+                    please call for assistance.
+                </p>
+                <p style="text-align: center;"><a href="{$siteBaseUrl}">Return to Home Page</a></p>
+            </div>
+        </center>
+    </div>
+</center>      
 {include file='admin/footer.html'}
index f9fdb91..378473b 100644 (file)
@@ -1,5 +1,2 @@
 <div class="wrap">
-       
-    <h2>{$glmPluginName}</h2>
-    
-  
\ No newline at end of file
+
index 9a763eb..687fdfd 100644 (file)
@@ -1,14 +1,32 @@
 {include file='admin/error/header.html'}
-    
-    <center>
-    
-        <h3>Sorry, we've had some type of fatal error.</h3>
-    {if $reason}
-        <p class="glm-error">{$reason}</p>
-    {/if}
-        <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
-          
-    </center>
-    
+<center>    
+    <div id="glm-admin-content-container" class="glm-center" style="width: 600px; text-align: left; padding: 1em;">       
+        <center>
+            <h1 class="glm-error">Aw shucks!</h1>
+            <h3>We couldn't get you the page you wanted. </h3>
+            <div style="width: 600px; text-align: left;">
+                <p>
+                    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.
+                </p>
+                <p>
+                    As far as we can tell now, <b>an invalid action has been requested</b>. This really shouldn't
+                    happen, so we're going to research this to see if we can avoid this in the future.
+                </p>
+            {if isset($reason) && $reason}
+                <p>Oh, we have a little more information for you.</p>
+                <p>{$reason}</p>
+            {/if}
+                
+                <p>
+                    Please head back to the link below and try again. If you continue to get this error,
+                    please call for assistance.
+                </p>
+                <p style="text-align: center;"><a href="{$siteBaseUrl}">Return to Home Page</a></p>
+            </div>
+        </center>
+    </div>
+</center>      
 {include file='admin/footer.html'}
 
index b51df2b..d633d53 100644 (file)
     <div id="daysClicks" class="graph-dialog glm-dialog-box" title="URL Click-Through Counts Graph">
         <div id="urlClicksPrintArea" class="PrintArea" style="padding: 10px;">
             <b>{$member.fieldData.name}</b>
-            <div>
+            <p>
                 <span class="glm-right">{$thisDate}</span>
                 <span class="glm-left">URL Click-Through Counts for Past Month</span>
-            </div>
-            <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=memberGraphs&graphType=clicksDays&memberId={$member.fieldData.id}&memberSlug={$member.fieldData.member_slug}">
+            </p>
+            <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=memberGraphs&graphType=clicks&graphPeriod=oneMonth&memberId={$member.fieldData.id}&memberSlug={$member.fieldData.member_slug}">
+            <p>
+                <span class="glm-right">{$thisDate}</span>
+                <span class="glm-left">URL Click-Through Counts for Past 2 Years</span>
+            </p>
+            <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=memberGraphs&graphType=clicks&graphPeriod=twoYears&memberId={$member.fieldData.id}&memberSlug={$member.fieldData.member_slug}">
         </div>
         <div class="button button-secondary graph-print glm-right" data-areaToPrint="urlClicksPrintArea">Print</div>
     </div>
                 <span class="glm-right">{$thisDate}</span>
                 <span class="glm-left">Detail Page Views for Past Month</span>
             </div>
-            <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=memberGraphs&graphType=viewsDays&memberId={$member.fieldData.id}&memberSlug={$member.fieldData.member_slug}">
+            <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=memberGraphs&graphType=views&graphPeriod=oneMonth&memberId={$member.fieldData.id}&memberSlug={$member.fieldData.member_slug}">
+            <div>
+                <span class="glm-right">{$thisDate}</span>
+                <span class="glm-left">Detail Page Views for Past 2 Years</span>
+            </div>
+            <img src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=memberGraphs&graphType=views&graphPeriod=twoYears&memberId={$member.fieldData.id}&memberSlug={$member.fieldData.member_slug}">
         </div>
         <div class="button button-secondary graph-print glm-right" data-areaToPrint="viewsPrintArea">Print</div>
     </div>
                 });
            });
 
-            
             // 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);
 
index 9867d71..d048fcb 100644 (file)
@@ -78,6 +78,7 @@
     <table class="wp-list-table widefat fixed posts glm-admin-table"">
         <thead>
             <tr>
+                <th>ID</th>
                 <th>Region</th>
                 <th>Description</th>
                 <th>Short Description</th>
@@ -93,6 +94,7 @@
         {else}
             <tr class="alternate">
         {/if}
+                <td>{$t.id}</td>
                 <td>
                     <a class="editRegion" data-regionID="{$t.id}">{$t.name}</a>
                 </td>
index a19e0f9..4ed0162 100644 (file)
@@ -1,9 +1,31 @@
 {include file='front/error/header.html'}
-    
-    <h2>Sorry, we've had an error.</h2>
-    
-    <p><b>Error: </b>: An invalid action or Shortcode attribute has been specified.</p>
-    
-    <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
-      
+<center>    
+    <div id="glm-admin-content-container" class="glm-center" style="width: 600px; text-align: left; padding: 1em;">       
+        <center>
+            <h1 class="glm-error">Aw shucks!</h1>
+            <h3>We couldn't get you the page you wanted. </h3>
+            <div style="width: 600px; text-align: left;">
+                <p>
+                    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.
+                </p>
+                <p>
+                    As far as we can tell now, <b>an invalid action has been requested</b>. This really shouldn't
+                    happen, so we're going to research this to see if we can avoid this in the future.
+                </p>
+            {if isset($errorMsg) && $errorMsg}
+                <p>Oh, we have a little more information for you.</p>
+                <p>{$errorMsg}</p>
+            {/if}
+                
+                <p>
+                    Please head back to the link below and try again. If you continue to get this error,
+                    please call for assistance.
+                </p>
+                <p style="text-align: center;"><a href="{$siteBaseUrl}">Return to Home Page</a></p>
+            </div>
+        </center>
+    </div>
+</center>      
 {include file='front/footer.html'}
index 2b17b0e..71bb229 100644 (file)
@@ -1,4 +1 @@
 <div class="wrap">
-       
-    
-  
\ No newline at end of file
index 16f771f..9914f31 100644 (file)
@@ -1,14 +1,28 @@
 {include file='front/error/header.html'}
-    
-    <center>
-    
-        <h3>Sorry, we've had some type of fatal error.</h3>
-        
-     {if $errorMsg}<p>{$errorMsg}</p>{/if}
-        
-        <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
-          
-    </center>
-    
+<center>    
+    <div id="glm-admin-content-container" class="glm-center" style="width: 600px; text-align: left; padding: 1em;">       
+        <center>
+            <h1 class="glm-error">Aw shucks!</h1>
+            <p><b>We couldn't get you the page you wanted.</b></p>
+            <div style="width: 600px; text-align: left;">
+                <p style="margin-top: .5em;">
+                    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.
+                </p>
+            {if isset($errorMsg) && $errorMsg}
+                <p style="margin-top: .5em;">Oh, we have a little more information for you.</p>
+                <p style="margin-top: .5em;"><b>{$errorMsg}</b></p>
+            {/if}
+                
+                <p style="margin-top: .5em;">
+                    Please head back to the link below and try again. If you continue to get this error,
+                    please call for assistance.
+                </p>
+                <p style="margin-top: .5em; text-align: center;"><a href="{$siteBaseUrl}">Return to Home Page</a></p>
+            </div>
+        </center>
+    </div>
+</center>      
 {include file='front/footer.html'}