Project

General

Profile

Bug #24203 » 16565_fe_flashmessages.patch

Administrator Admin, 2010-11-25 10:24

View differences:

t3lib/class.t3lib_flashmessagequeue.php (working copy)
if ($message->isSessionMessage()) {
$queuedFlashMessages = self::getFlashMessagesFromSession();
$queuedFlashMessages[] = $message;
$GLOBALS['BE_USER']->setAndSaveSessionData(
'core.template.flashMessages',
$queuedFlashMessages
);
self::storeFlashMessagesInSession($queuedFlashMessages);
} else {
self::$messages[] = $message;
}
......
$queuedFlashMessagesFromSession = self::getFlashMessagesFromSession();
if (!empty($queuedFlashMessagesFromSession)) {
// reset messages in user session
$GLOBALS['BE_USER']->setAndSaveSessionData(
'core.template.flashMessages',
null
);
self::removeAllFlashMessagesFromSession();
}
$queuedFlashMessages = array_merge($queuedFlashMessagesFromSession, self::$messages);
......
}
/**
* Stores given flash messages in the session
*
* @param array array of t3lib_FlashMessage
* @return void
*/
protected static function storeFlashMessagesInSession(array $flashMessages) {
if (TYPO3_MODE === 'BE') {
$GLOBALS['BE_USER']->setAndSaveSessionData('core.template.flashMessages', $flashMessages);
} else {
$GLOBALS['TSFE']->fe_user->setKey('ses', 'core.template.flashMessages', $flashMessages);
$GLOBALS['TSFE']->fe_user->storeSessionData();
}
}
/**
* Removes all flash messages from the session
*
* @return void
*/
protected static function removeAllFlashMessagesFromSession() {
if (TYPO3_MODE === 'BE') {
$GLOBALS['BE_USER']->setAndSaveSessionData('core.template.flashMessages', NULL);
} else {
$GLOBALS['TSFE']->fe_user->setKey('ses', 'core.template.flashMessages', NULL);
$GLOBALS['TSFE']->fe_user->storeSessionData();
}
}
/**
* Returns current flash messages from the session, making sure to always
* return an array.
*
* @return array An array of t3lib_FlashMessage flash messages.
*/
protected static function getFlashMessagesFromSession() {
$flashMessages = $GLOBALS['BE_USER']->getSessionData('core.template.flashMessages');
if (TYPO3_MODE === 'BE') {
$flashMessages = $GLOBALS['BE_USER']->getSessionData('core.template.flashMessages');
} else {
$flashMessages = $GLOBALS['TSFE']->fe_user->getKey('ses', 'core.template.flashMessages');
}
return is_array($flashMessages) ? $flashMessages : array();
}
(1-1/2)