Bug #24203 » 16565_fe_flashmessages_v3.patch
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;
|
||
}
|
||
... | ... | |
/**
|
||
* Returns all messages from the current PHP session and from the current request.
|
||
*
|
||
* @return array array of t3lib_FlashMessage objects
|
||
*/
|
||
public static function getAllMessages() {
|
||
// get messages from user session
|
||
$queuedFlashMessagesFromSession = self::getFlashMessagesFromSession();
|
||
$queuedFlashMessages = array_merge($queuedFlashMessagesFromSession, self::$messages);
|
||
return $queuedFlashMessages;
|
||
}
|
||
/**
|
||
* Returns all messages from the current PHP session and from the current request.
|
||
* After fetching the messages the internal queue and the message queue in the session
|
||
* will be emptied.
|
||
*
|
||
* @return array array of t3lib_FlashMessage objects
|
||
*/
|
||
public static function getAllMessagesAndFlush() {
|
||
// get messages from user session
|
||
$queuedFlashMessagesFromSession = self::getFlashMessagesFromSession();
|
||
if (!empty($queuedFlashMessagesFromSession)) {
|
||
// reset messages in user session
|
||
$GLOBALS['BE_USER']->setAndSaveSessionData(
|
||
'core.template.flashMessages',
|
||
null
|
||
);
|
||
}
|
||
$queuedFlashMessages = self::getAllMessages();
|
||
$queuedFlashMessages = array_merge($queuedFlashMessagesFromSession, self::$messages);
|
||
// reset messages in user session
|
||
self::removeAllFlashMessagesFromSession();
|
||
// reset internal messages
|
||
self::$messages = array();
|
||
... | ... | |
}
|
||
/**
|
||
* Stores given flash messages in the session
|
||
*
|
||
* @param array array of t3lib_FlashMessage
|
||
* @return void
|
||
*/
|
||
protected static function storeFlashMessagesInSession(array $flashMessages) {
|
||
self::getUserByContext()->setAndSaveSessionData('core.template.flashMessages', $flashMessages);
|
||
}
|
||
/**
|
||
* Removes all flash messages from the session
|
||
*
|
||
* @return void
|
||
*/
|
||
protected static function removeAllFlashMessagesFromSession() {
|
||
self::getUserByContext()->setAndSaveSessionData('core.template.flashMessages', NULL);
|
||
}
|
||
/**
|
||
* 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');
|
||
$flashMessages = self::getUserByContext()->getSessionData('core.template.flashMessages');
|
||
return is_array($flashMessages) ? $flashMessages : array();
|
||
}
|
||
/**
|
||
* Gets user object by context
|
||
*
|
||
* @return object user object
|
||
*/
|
||
protected function getUserByContext() {
|
||
return TYPO3_MODE === 'BE' ? $GLOBALS['BE_USER'] : $GLOBALS['TSFE']->fe_user;
|
||
}
|
||
/**
|
||
* Fetches and renders all available flash messages from the queue.
|
||
*
|
||
* @return string All flash messages in the queue rendered as HTML.
|
typo3/sysext/cms/tslib/class.tslib_feuserauth.php (working copy) | ||
---|---|---|
}
|
||
/**
|
||
* Returns the session data stored for $key.
|
||
* The data will last only for this login session since it is stored in the session table.
|
||
*
|
||
* @param string $key
|
||
* @return mixed
|
||
*/
|
||
public function getSessionData($key) {
|
||
return $this->getKey('ses', $key);
|
||
}
|
||
/**
|
||
* Saves the tokens so that they can be used by a later incarnation of this class.
|
||
*
|
||
* @param string $key
|
||
* @param mixed $data
|
||
* @return void
|
||
*/
|
||
public function setAndSaveSessionData($key, $data) {
|
||
$this->setKey('ses', $key, $data);
|
||
$this->storeSessionData();
|
||
}
|
||
/**
|
||
* Registration of records/"shopping basket" in session data
|
||
* This will take the input array, $recs, and merge into the current "recs" array found in the session data.
|
||
* If a change in the recs storage happens (which it probably does) the function setKey() is called in order to store the array again.
|
- « Previous
- 1
- 2
- Next »