Re-activated management debug flags.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 17 Oct 2017 17:00:03 +0000 (13:00 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 17 Oct 2017 17:01:56 +0000 (13:01 -0400)
Added debug output for critical items in front controller.
Removed E-Mail feature that was supposed to send an error message from live sites when there was a front controller problem. Didn't work.

classes/data/settings/dataSettingsGeneral.php
config.php
controllers/front.php
setup/standardTemplateParams.php
views/admin/management/index.html
views/front/members/list.html

index b897983..d42854e 100644 (file)
@@ -118,7 +118,7 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
             /*
              * Debug Options
              */
-/* Depreciating debug system
+
             // Admin Debug
             'admin_debug' => array(
                 'field' => 'admin_debug',
@@ -146,8 +146,7 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                 'type' => 'checkbox',
                 'use' => 'a'
             ),
-*/
-            
+
             /*
              * Misc Settings
              */
index 5c61c0f..22c2502 100644 (file)
@@ -34,17 +34,10 @@ if ($glmMembersDatabaseDbVersion) {
     $config['terms'] = $terms;
 
     // Add Debug defines - These can't go into the defines.php file - Guess why.
-    // Depreciating debug system
-    define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', false);
-    define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', false);
-    define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', false);
-    define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', false);
-    /*
     define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', $settings['admin_debug']);
     define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', $settings['admin_debug_verbose']);
     define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', $settings['front_debug']);
     define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', $settings['front_debug_verbose']);
-    */
 }
 
 // Check for config value replacements in the current theme
index 56a7d3f..146246b 100644 (file)
@@ -326,6 +326,10 @@ class glmMembersFront extends GlmPluginSupport
                 $cached = $this->wpdb->get_results($sql, ARRAY_A);
                 if (count($cached) == 1) {
 
+                    if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                        trigger_error("Using Cached Result: cache code = $cache_code", E_USER_NOTICE);
+                    }
+
                     // Currently cached - Return cached content
                     return $cached[0]['html'];
 
@@ -353,21 +357,11 @@ class glmMembersFront extends GlmPluginSupport
         $defaultTimeZone = date_default_timezone_get();
         date_default_timezone_set($this->config['settings']['time_zone']);
 
-        $errorMsg = '';
+        $controlError = false;
 
         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) {
-                $consts = $consts['user'];
-            }
-
-        } else {
-            $this->clearNotices();
         }
 
         /*
@@ -397,7 +391,7 @@ class glmMembersFront extends GlmPluginSupport
                     }
 
                 } else {
-                    $errorMsg .= '<b>Missing shortcode default values table entry in table '.$shortcodeData['table'].'</b><br>';
+                    $controlError = true;
                 }
             }
 
@@ -429,12 +423,21 @@ class glmMembersFront extends GlmPluginSupport
                 )
             );
 
+            if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                trigger_error("Executing Shortcode: $shortcode", E_USER_NOTICE);
+            }
+
         } else {
-            $errorMsg .= "<b>Provided short-code is not valid: </b>$shortcode<br>";
+            $controlError = true;
+
+            if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                trigger_error("Shortcode Not Valid: $shortcode", E_USER_NOTICE);
+            }
+
         }
 
         // If there's been no error so far, try to process the supplied action
-        if($errorMsg == '') {
+        if(!$controlError) {
 
             /*
              * Processing loop - Loop till we have a final action
@@ -452,14 +455,14 @@ class glmMembersFront extends GlmPluginSupport
                 // Verify that we have the requested menu item in the valid actions
 
                 if (! isset($this->config['validActions']['frontActions'][$menuItem])) {
-                    $errorMsg .= "<b>Model doesn't exist:</b> " . $modelName;
+                    $controlError = true;
                 }
 
                 // Verify Menu item and action as valid action
                 if (! isset($this->config['validActions']['frontActions']) ||
                          ! isset($action,
                                 $this->config['validActions']['frontActions'][$menuItem])) {
-                    $errorMsg = '<b>Invalid action requested:</br> '.$action;
+                    $controlError = true;
                 }
 
                 /*
@@ -473,10 +476,14 @@ class glmMembersFront extends GlmPluginSupport
                 $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/front/$menuItem/$action.php";
                 $className = 'GlmMembersFront_' . $menuItem . '_' . $action;
 
+                if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                    trigger_error("Model: $modelName", E_USER_NOTICE);
+                }
+
                 // If model file doesn't exist - we have an error
                 if (!file_exists($modelName)) {
 
-                    $errorMsg .= "<b>Model doesn't exist:</b> " . $modelName;
+                    $controlError = true;
 
                     // Otherwise, load and run the model
                 } else {
@@ -491,7 +498,7 @@ class glmMembersFront extends GlmPluginSupport
                     // check for an invalid model class name
                     if (! class_exists($className)) {
 
-                        $errorMsg .= "<b>Model class doesn't exist:</b> ".$className;
+                        $controlError = true;
 
                     } else {
 
@@ -508,6 +515,10 @@ class glmMembersFront extends GlmPluginSupport
                             // Set the new model action
                             $action = $results['modelRedirect'];
 
+                            if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                                trigger_error("Model Redirect: ".$results['modelRedirect'], E_USER_NOTICE);
+                            }
+
                             // Check if there's also a menu item change
                             if ($results['menuItemRedirect']) {
                                 $menuItem = $results['menuItemRedirect'];
@@ -537,16 +548,28 @@ class glmMembersFront extends GlmPluginSupport
                             $viewFile = $view;
 
                             // If the view is not found in the theme, fall back to views in the plugin
+                            $inTheme = ' (In Theme)';
                             if (!is_file($viewPath.'/'.$viewFile)) {
+
                                 // Next try the plugin/add-on
                                 $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views";
                                 $viewFile = $view;
                                 if (!is_file($viewPath.'/'.$viewFile)) {
 
                                     // No matching view file found
-                                    $errorMsg .= "<b>Bad or missing view file:</b> $viewPath/$viewFile";
+                                    $controlError = true;
+
+                                    if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                                        trigger_error("Bad or missing view file: $viewPath/$viewFile", E_USER_NOTICE);
+                                    }
 
                                 }
+
+                                $inTheme = '';
+                            }
+
+                            if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                                trigger_error("View$inTheme: $viewPath", E_USER_NOTICE);
                             }
 
                         }
@@ -577,31 +600,8 @@ class glmMembersFront extends GlmPluginSupport
 
         } // if errorMsg
 
-        // If there was an error
-        if ($errorMsg != '' && isset($_SERVER['HTTP_REFERER'])) {
-            $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']."
-Referrer: ".$_SERVER['HTTP_REFERER']."
-User Agent: ".$_SERVER['HTTP_USER_AGENT']."
-Remote Addr: ".$_SERVER['REMOTE_ADDR']."
-Filename: ".$_SERVER['SCRIPT_FILENAME']."
-URL: http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_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';
-//            $viewFile = 'front/error/index.html';
+        // If there was a controller error - show error page
+        if ($controlError != '' && isset($_SERVER['HTTP_REFERER'])) {
             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);
@@ -635,15 +635,6 @@ Request Data: ".print_r($_REQUEST,1)."
         // Generate output from model data and view
         $out = $smarty->template->fetch($viewFile);
 
-        // If debug is requested, create debug window
-        if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
-            echo "
-                <script>
-                    window.open('".admin_url()."admin.php?page=glm-members-admin-menu-members&glmDebugWindow=true','GLM_Plugin_Debug','width=800,height=800,left=50,top=50,resizable=yes,scrollbars=yes');
-                </script>
-            ";
-        }
-
         // Restore timezone that was set before our code was called
         date_default_timezone_set($defaultTimeZone);
 
index 295b203..14310cd 100644 (file)
@@ -53,7 +53,6 @@ if (is_admin()) {
 
     // Front specific
     $smarty->templateAssign('frontDebug', GLM_MEMBERS_PLUGIN_FRONT_DEBUG);
-    $smarty->templateAssign('errorMsg', $errorMsg);
     $smarty->templateAssign('thisAction', ((isset($action)) ? $action: '' ) );
 
 }
index fa207e9..323cfc4 100644 (file)
 
 
             <!-- Debug Settings -->
-<!-- Depreciating Debug System
+
         <table id="glm-table-debug" class="glm-admin-table glm-settings-table">
             <tr><td colspan="2"><h2>Debug Settings</h2></td></tr>
+            <tr>
+                <td colspan="2">
+                    These settings now enabling "trigger_error()" output where that's available. This is replacing the legacy
+                    debug output that used a separate debug window. So far only Front Controller has debug tests included.
+                </td>
             <tr>
                 <th>Admin Debug Information:</th>
                 <td>
-                    <input type="checkbox" name="admin_debug"{ if $genSettings.fieldData.admin_debug.value } checked="checked"{ /if }>
+                    <input type="checkbox" name="admin_debug"{if $genSettings.fieldData.admin_debug.value} checked="checked"{/if}>
                 </td>
             </tr>
             <tr>
                 <th>Admin Debug Verbose:</th>
                 <td>
-                    <input type="checkbox" name="admin_debug_verbose"{ if $genSettings.fieldData.admin_debug_verbose.value } checked="checked"{ /if }>
+                    <input type="checkbox" name="admin_debug_verbose"{if $genSettings.fieldData.admin_debug_verbose.value} checked="checked"{/if}>
                 </td>
             </tr>
             <tr>
                 <th>Front-End Debug Information:</th>
                 <td>
-                    <input type="checkbox" name="front_debug"{ if $genSettings.fieldData.front_debug.value} checked="checked"{ /if}>
+                    <input type="checkbox" name="front_debug"{if $genSettings.fieldData.front_debug.value} checked="checked"{/if}>
                 </td>
             </tr>
             <tr>
                 <th>Front-End Debug Verbose:</th>
                 <td>
-                    <input type="checkbox" name="front_debug_verbose"{ if $genSettings.fieldData.front_debug_verbose.value} checked="checked"{ /if}>
+                    <input type="checkbox" name="front_debug_verbose"{if $genSettings.fieldData.front_debug_verbose.value} checked="checked"{/if}>
                 </td>
             </tr>
         </table>
-->
       <p>&nbsp;</p>
  
         <!-- Required Pages -->
 
index c7c23aa..1eb8c5d 100644 (file)
      <!-- Member information displayed in map bubbles -->
         {foreach $mapItems as $m}
             <div id="map_info_{$m.id}" class="glm-hidden">
-                {apply_filters('glm-member-db-front-members-list-mapBubbleTop', '', $m.member_pointer)}
+                {apply_filters('glm-member-db-front-members-list-mapBubbleTop', '', $m.member)}
                 {if $m.logo && $settings.list_map_show_logo}
                     <div class="glm-member-list-image">
                         <img src="{$glmPluginMediaUrl}/images/{$settings.list_map_logo_size}/{$m.logo}">
                         </div>
                     {/if}
                 </div>
-                {apply_filters('glm-member-db-front-members-list-mapBubbleBottom', '', $m.member_pointer)}
+                {apply_filters('glm-member-db-front-members-list-mapBubbleBottom', '', $m.member)}
             </div> <!-- End of information displayed in map bubbles -->
         {/foreach}
 
                             position: new google.maps.LatLng({$m.lat}, {$m.lon}),
                             draggable: false,
                             animation: google.maps.Animation.DROP,
-                            title: '{$m.member|escape}',
+                            title: '{$m.name|escape:quotes}',
                             descr: $('#map_info_' + {$m.id}).html(),
                             memberID: {$m.member}
                         });