diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 148a0cf39..34671eb3b 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -314,6 +314,7 @@ $this->error = $errorMsg; $_SESSION['XE_VALIDATOR_ERROR'] = -1; $_SESSION['XE_VALIDATOR_MESSAGE'] = $this->error; + $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error'; $_SESSION['XE_VALIDATOR_RETURN_URL'] = $returnUrl; $this->_setInputValueToSession(); return $oModule; @@ -342,11 +343,12 @@ { $error = $oModule->getError(); $message = $oModule->getMessage(); + $messageType = $oModule->getMessageType(); $redirectUrl = $oModule->getRedirectUrl(); if (!$procResult) { - $this->error = $oModule->getMessage(); + $this->error = $message; if (!$redirectUrl) $redirectUrl = Context::get('error_return_url')?Context::get('error_return_url'):getUrl(); $this->_setInputValueToSession(); } @@ -361,6 +363,7 @@ $_SESSION['XE_VALIDATOR_ERROR'] = $error; if ($message != 'success') $_SESSION['XE_VALIDATOR_MESSAGE'] = $message; + $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType; $_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl; } @@ -371,10 +374,12 @@ { if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR')) Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']); if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE')) Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']); + if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE')) Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']); if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL')) Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']); $_SESSION['XE_VALIDATOR_ERROR'] = ''; $_SESSION['XE_VALIDATOR_MESSAGE'] = ''; + $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = ''; $_SESSION['XE_VALIDATOR_RETURN_URL'] = ''; } diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php index 3d96320e4..2b2bce3d7 100644 --- a/classes/module/ModuleObject.class.php +++ b/classes/module/ModuleObject.class.php @@ -58,6 +58,35 @@ function getRedirectUrl(){ return $this->get('redirect_url'); } + + /** + * @brief set message + * @param $message a message string + * @param $type type of message (error, info, update) + **/ + function setMessage($message, $type = null){ + parent::setMessage($message); + $this->setMessageType($type); + } + + /** + * @brief set type of message + * @param $type type of message (error, info, update) + **/ + function setMessageType($type){ + $this->add('message_type', $type); + } + + /** + * @brief get type of message + **/ + function getMessageType(){ + $type = $this->get('message_type'); + if (!in_array($type, array('error', 'info', 'update'))){ + $type = $this->getError()?'error':'info'; + } + return $type; + } /** * @brief sett to set the template path for refresh.html