From 825e5d04b91d5c65ed06dcfec06d9dca715f6f9f Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 15 Feb 2017 12:49:17 -0500 Subject: [PATCH] Update admin controller for creating action hooks 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 | 82 ++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 78128062..b196d9c2 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -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("Template Path: $viewPath", 'Process'); - glmMembersAdmin::addNotice("Template File: $viewFile", 'Process'); + glmMembersAdmin::addNotice("Template Path: $viewPath", 'Process'); + glmMembersAdmin::addNotice("Template File: $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) { -- 2.17.1