Commit 12fbff0a authored by Carsten  Rose's avatar Carsten Rose
Browse files

STORE_TYPO3: provide feUserGroup during API access

Session.php: save feUserGroup through init auf session.
Store.php: During API access restore feUserGroup from SESSION
parent 419b692b
...@@ -15,10 +15,10 @@ const API_DIR = 'typo3conf/ext/qfq/qfq/api'; ...@@ -15,10 +15,10 @@ const API_DIR = 'typo3conf/ext/qfq/qfq/api';
const QFQ_LOG = 'qfq.log'; const QFQ_LOG = 'qfq.log';
const SESSION_LIFETIME_SECONDS = 86400; const SESSION_LIFETIME_SECONDS = 86400;
const SESSION_FE_USER_UID = 'fe_user_uid';
const SESSION_FE_USER = 'fe_user';
const SESSION_NAME = 'qfq'; const SESSION_NAME = 'qfq';
const SESSION_FE_USER_UID = 'feUserUid';
const SESSION_FE_USER = 'feUser';
const SESSION_FE_USER_GROUP = 'feUserGroup';
const FORM_LOAD = 'form_load'; const FORM_LOAD = 'form_load';
const FORM_SAVE = 'form_save'; const FORM_SAVE = 'form_save';
...@@ -513,6 +513,7 @@ const DB_AFFECTED_ROWS = 'affectedRows'; ...@@ -513,6 +513,7 @@ const DB_AFFECTED_ROWS = 'affectedRows';
const DB_INSERT_ID = 'insertId'; const DB_INSERT_ID = 'insertId';
const COLUMN_CREATED = 'created'; const COLUMN_CREATED = 'created';
const COLUMN_MODIFIED = 'modified';
const INDEX_PHP = 'index.php'; const INDEX_PHP = 'index.php';
......
...@@ -52,6 +52,7 @@ class Session { ...@@ -52,6 +52,7 @@ class Session {
// if noone is logged in: 0 // if noone is logged in: 0
$feUidLoggedIn = isset($GLOBALS["TSFE"]->fe_user->user["uid"]) ? $GLOBALS["TSFE"]->fe_user->user["uid"] : false; $feUidLoggedIn = isset($GLOBALS["TSFE"]->fe_user->user["uid"]) ? $GLOBALS["TSFE"]->fe_user->user["uid"] : false;
$feUserSession = isset($GLOBALS["TSFE"]->fe_user->user["username"]) ? $GLOBALS["TSFE"]->fe_user->user["username"] : false; $feUserSession = isset($GLOBALS["TSFE"]->fe_user->user["username"]) ? $GLOBALS["TSFE"]->fe_user->user["username"] : false;
$feUserGroup = isset($GLOBALS["TSFE"]->fe_user->user["usergroup"]) ? $GLOBALS["TSFE"]->fe_user->user["usergroup"] : false;
} else { } else {
// If we are called through API there is no T3 environment. Assume nothing has changed, and fake the following check to always 'no change'. // If we are called through API there is no T3 environment. Assume nothing has changed, and fake the following check to always 'no change'.
$feUidLoggedIn = $feUserUidSession; $feUidLoggedIn = $feUserUidSession;
...@@ -64,6 +65,7 @@ class Session { ...@@ -64,6 +65,7 @@ class Session {
// save new feUserUid, feUserName // save new feUserUid, feUserName
Session::set(SESSION_FE_USER_UID, $feUidLoggedIn); Session::set(SESSION_FE_USER_UID, $feUidLoggedIn);
Session::set(SESSION_FE_USER, $feUserSession); Session::set(SESSION_FE_USER, $feUserSession);
Session::set(SESSION_FE_USER_GROUP, $feUserGroup);
// throw new UserFormException("FYI: Session has been cleared. Reload this page. ". // throw new UserFormException("FYI: Session has been cleared. Reload this page. ".
// "feUserUidSession:'$feUserUidSession', feUserSession:'$feUserSession' isset(TSFE):'" . isset($GLOBALS["TSFE"]) ? 'true' : 'false' ); // "feUserUidSession:'$feUserUidSession', feUserSession:'$feUserSession' isset(TSFE):'" . isset($GLOBALS["TSFE"]) ? 'true' : 'false' );
......
...@@ -289,13 +289,14 @@ class Store { ...@@ -289,13 +289,14 @@ class Store {
if (isset($GLOBALS["TSFE"]->sys_language_uid)) { if (isset($GLOBALS["TSFE"]->sys_language_uid)) {
$arr[TYPO3_PAGE_LANGUAGE] = $GLOBALS["TSFE"]->sys_language_uid; $arr[TYPO3_PAGE_LANGUAGE] = $GLOBALS["TSFE"]->sys_language_uid;
} }
} else { } else {
// NO T3 environment (called by API): restore from SESSION // NO T3 environment (called by API): restore from SESSION
if (isset($_SESSION[SESSION_NAME][SESSION_FE_USER])) { foreach([ SESSION_FE_USER, SESSION_FE_USER_UID, SESSION_FE_USER_GROUP ] as $key) {
$arr[TYPO3_FE_USER] = $_SESSION[SESSION_NAME][SESSION_FE_USER]; if (isset($_SESSION[SESSION_NAME][$key])) {
} $arr[$key] = $_SESSION[SESSION_NAME][$key];
if (isset($_SESSION[SESSION_NAME][SESSION_FE_USER_UID])) { }
$arr[TYPO3_FE_USER_UID] = $_SESSION[SESSION_NAME][SESSION_FE_USER_UID];
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment