diff --git a/classes/Controller.php b/classes/Controller.php index ee81913..b906ebb 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -368,7 +368,17 @@ class Controller extends Object * module know to use the cache, either passing in a variable * or setting it on the object */ - $display->setModuleReturn($valid_request && $valid_security_hash ? $module->__default() : array('status' => 'error', 'message' => $error_message)); + if ($valid_request && $valid_security_hash) + { + $module_return = $module->__default(); + + if ($module_return === null) + { + $module_return = $module->return; + } + } + + $display->setModuleReturn(isset($module_return) ? $module_return : array('status' => 'error', 'message' => $error_message)); unset($error_message); diff --git a/classes/Module.php b/classes/Module.php index cd65d52..3fdf255 100644 --- a/classes/Module.php +++ b/classes/Module.php @@ -158,6 +158,19 @@ class Module extends Object */ protected $template = 'index'; + /** + * Return + * + * Array that is returned to the template in the case of the module not + * returning anything itself. This is somewhat of a one way trip as you + * cannot get the variable unless you reference the return array explicitly + * $this->return['variable'] + * + * @access protected + * @var array + */ + protected $return = array(); + /** * Constructor * @@ -198,14 +211,16 @@ class Module extends Object /** * Magic Setter Method * - * Prohibits the direct modification of module variables. + * Places the variables that are being modified in the return array that is + * returned if nothing is returned by the module itself. This also prohibits + * the direct modification of module variables which could cause issues. * * @param string $name name of the variable to be set * @param mixed $value value of the variable to be set */ public function __set($name, $value) { - throw new Exception('Cannot set module variables directly'); + $this->return[$name] = $value; } /** diff --git a/jar.php b/jar.php index e35993c..a9a1d98 100755 --- a/jar.php +++ b/jar.php @@ -1315,7 +1315,17 @@ class Controller extends Object * module know to use the cache, either passing in a variable * or setting it on the object */ - $display->setModuleReturn($valid_request && $valid_security_hash ? $module->__default() : array('status' => 'error', 'message' => $error_message)); + if ($valid_request && $valid_security_hash) + { + $module_return = $module->__default(); + + if ($module_return === null) + { + $module_return = $module->return; + } + } + + $display->setModuleReturn(isset($module_return) ? $module_return : array('status' => 'error', 'message' => $error_message)); unset($error_message); @@ -5552,6 +5562,19 @@ class Module extends Object */ protected $template = 'index'; + /** + * Return + * + * Array that is returned to the template in the case of the module not + * returning anything itself. This is somewhat of a one way trip as you + * cannot get the variable unless you reference the return array explicitly + * $this->return['variable'] + * + * @access protected + * @var array + */ + protected $return = array(); + /** * Constructor * @@ -5592,14 +5615,16 @@ class Module extends Object /** * Magic Setter Method * - * Prohibits the direct modification of module variables. + * Places the variables that are being modified in the return array that is + * returned if nothing is returned by the module itself. This also prohibits + * the direct modification of module variables which could cause issues. * * @param string $name name of the variable to be set * @param mixed $value value of the variable to be set */ public function __set($name, $value) { - throw new Exception('Cannot set module variables directly'); + $this->return[$name] = $value; } /**