/** * Saves a value (objects and arrays will be serialized before) into a session key of FE _browser_ session or a BE user session *immediately* (does not wait for complete script execution) * * @param string $key name of session key to save value into * @param string $val value to be saved with session key * @param bool $allowSerializing (optional) allow automatic serializing of objects within this method * @param string $foreignSessionId ID of foreign session (other than session currently used for request) * @throws Exception if no valid frontend user and no valid backend user found */ public function store($key, $val, $allowSerializing = true, $foreignSessionId = null) { // TYPO3 Frontend mode if (TYPO3_MODE == 'FE' && $GLOBALS['TSFE']->fe_user instanceof \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication) { if ($allowSerializing == true && (is_object($val) || is_array($val))) { $val = serialize($val); } if (is_null($foreignSessionId)) { $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $val); $GLOBALS['TSFE']->fe_user->sesData_change = 1; $GLOBALS['TSFE']->fe_user->storeSessionData(); if (TYPO3_DLOG) { GeneralUtility::devLog(sprintf('Storing "%s" into FE browser session using "$GLOBALS[\'TSFE\']->fe_user"', $key), 'pt_extbase'); } } else { Tx_PtExtbase_Assertions_Assert::isString($foreignSessionId); // read current foreign session data $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'fe_session_data', 'hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($foreignSessionId, 'fe_session_data')); $sessionData = unserialize($rows[0]['content']); // update sessionData $sessionData[$key] = $val; // write sessionData back to database $insertFields = array('hash' => $foreignSessionId, 'content' => serialize($sessionData), 'tstamp' => time()); $GLOBALS['TYPO3_DB']->exec_DELETEquery('fe_session_data', 'hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($foreignSessionId, 'fe_session_data')); $GLOBALS['TYPO3_DB']->exec_INSERTquery('fe_session_data', $insertFields); if (TYPO3_DLOG) { GeneralUtility::devLog(sprintf('Storing "%s" into foreign FE browser session "%s"', $key, $foreignSessionId), 'pt_extbase'); } } // TYPO3 Backend mode } else { Tx_PtExtbase_Assertions_Assert::isInstanceOf($GLOBALS['BE_USER'], '\\TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array('message' => 'No valid backend user found!')); $GLOBALS['BE_USER']->setAndSaveSessionData($key, $val); if (TYPO3_DLOG) { GeneralUtility::devLog(sprintf('Storing "%s" into BE user session using "$GLOBALS[\'BE_USER\']"', $key), 'pt_extbase'); } } }
/** * Set generic config variables that exist for all filters * */ protected function initGenericFilterByTSConfig() { Tx_PtExtbase_Assertions_Assert::isString($this->filterConfig->getSettings('dbTimeFormat'), array('message' => 'No dbTimeFormat defined for filter ' . $this->filterIdentifier . ' 1314579114')); $this->dbTimeFormat = $this->filterConfig->getSettings('dbTimeFormat'); $this->invert = $this->filterConfig->getInvert(); $this->buildDateFieldConfigArray(); }