Update admin controller for creating action hooks feature/communicatorHooks
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 15 Feb 2017 17:49:17 +0000 (12:49 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 15 Feb 2017 17:49:17 +0000 (12:49 -0500)
Checking the return from the modelAction function of the called model to
see if it returns a view. If it does not return a view then don't run
anything that deals with the Smarty Engine.

controllers/admin.php

index 7812806..b196d9c 100644 (file)
@@ -945,63 +945,65 @@ class glmMembersAdmin extends GlmPluginSupport
          */
 
         // Get suggested view
-        $view = $results['view'];
+        $view = (isset($results['view'])?$results['view']:null);
+        if ( $view ) {
 
-        // If there's a general model failure use the error view
-        if (! $results['status']) {
-            $view = 'admin/error/index.html';
-        }
+            // If there's a general model failure use the error view
+            if (! $results['status']) {
+                $view = 'admin/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;
+            // 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
-         */
+            /*
+             * Merge data returned from the model with the selected view
+             */
 
-        // Load Smarty Template support
-        $smarty = new smartyTemplateSupport();
+            // Load Smarty Template support
+            $smarty = new smartyTemplateSupport();
 
-        // Add standard template parameters
-        require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
+            // Add standard template parameters
+            require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
 
-        // Add data from model to Smarty template
-        if (is_array($results['data']) && count($results['data']) > 0) {
-            foreach ($results['data'] as $k => $d) {
-                $smarty->templateAssign($k, $d);
+            // Add data from model to Smarty template
+            if (is_array($results['data']) && count($results['data']) > 0) {
+                foreach ($results['data'] as $k => $d) {
+                    $smarty->templateAssign($k, $d);
+                }
             }
-        }
 
-        $smarty->templateAssign ( 'thisAction', $action);
+            $smarty->templateAssign ( 'thisAction', $action);
 
-        // If there's an error message, add that also
-        if ($errorMsg != '') {
-            $smarty->templateAssign('errorMsg', $errorMsg);
-        }
+            // If there's an error message, add that also
+            if ($errorMsg != '') {
+                $smarty->templateAssign('errorMsg', $errorMsg);
+            }
 
-        // If view debug has been requested
-        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+            // If view debug has been requested
+            if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
 
-            glmMembersAdmin::addNotice("<b>Template Path:</b> $viewPath", 'Process');
-            glmMembersAdmin::addNotice("<b>Template File:</b> $viewFile", 'Process');
+                glmMembersAdmin::addNotice("<b>Template Path:</b> $viewPath", 'Process');
+                glmMembersAdmin::addNotice("<b>Template File:</b> $viewFile", 'Process');
 
-            $x = $smarty->template->getTemplateVars();
+                $x = $smarty->template->getTemplateVars();
 
-            if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
-                glmMembersAdmin::addNotice($x, 'DataBlock', 'Template Parameters');
-            }
+                if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+                    glmMembersAdmin::addNotice($x, 'DataBlock', 'Template Parameters');
+                }
 
-        }
+            }
 
-        // Update the Smarty view path - *** NEEED TO FIX THIS TO SUPPORT THEME VIEWS SOMEHOW ****
-        $smarty->template->addTemplateDir($viewPath);
+            // Update the Smarty view path - *** NEEED TO FIX THIS TO SUPPORT THEME VIEWS SOMEHOW ****
+            $smarty->template->addTemplateDir($viewPath);
 
-        // Generate output from model data and view
-        $smarty->template->display($viewFile);
+            // Generate output from model data and view
+            $smarty->template->display($viewFile);
+        }
 
         // If debug is requested, create debug window
         if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {