Skip to content
Snippets Groups Projects
Commit b333945e authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Make backend.user conditions in FE work

The TypoScript conditions "[backend.user.*]" are documented,
but were never implemented.

https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Conditions/Index.html#backend-user

This patch is now introducing the missing conditions.

Resolves: #90767
Releases: master, 9.5
Change-Id: If6db277f56a2ef3457deb027a676af62a3494151
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63752


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarSusanne Moog <look@susi.dev>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarJulian Mair <julian.mair94@gmail.com>
Reviewed-by: default avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent 62650559
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ class Typo3ConditionFunctionsProvider implements ExpressionFunctionProviderInter
return new ExpressionFunction('loginUser', function () {
// Not implemented, we only use the evaluator
}, function ($arguments, $str) {
$user = $arguments['backend']->user ?? $arguments['frontend']->user;
$user = $arguments['frontend']->user ?? $arguments['backend']->user;
if ($user->isLoggedIn) {
foreach (GeneralUtility::trimExplode(',', $str, true) as $test) {
if ($test === '*' || (string)$user->userId === (string)$test) {
......@@ -81,7 +81,7 @@ class Typo3ConditionFunctionsProvider implements ExpressionFunctionProviderInter
return new ExpressionFunction('usergroup', function () {
// Not implemented, we only use the evaluator
}, function ($arguments, $str) {
$user = $arguments['backend']->user ?? $arguments['frontend']->user;
$user = $arguments['frontend']->user ?? $arguments['backend']->user;
$groupList = $user->userGroupList ?? '';
// '0,-1' is the default usergroups string when not logged in!
if ($groupList !== '0,-1' && $groupList !== '') {
......
......@@ -60,6 +60,14 @@ class ConditionMatcher extends AbstractConditionMatcher
$frontend->user->userId = $frontendUserAspect->get('id');
$frontend->user->userGroupList = implode(',', $frontendUserAspect->get('groupIds'));
$backendUserAspect = $this->context->getAspect('backend.user');
$backend = new \stdClass();
$backend->user = new \stdClass();
$backend->user->isAdmin = $backendUserAspect->get('isAdmin');
$backend->user->isLoggedIn = $backendUserAspect->get('isLoggedIn');
$backend->user->userId = $backendUserAspect->get('id');
$backend->user->userGroupList = implode(',', $backendUserAspect->get('groupIds'));
$workspaceAspect = $this->context->getAspect('workspace');
$workspace = new \stdClass();
$workspace->workspaceId = $workspaceAspect->get('id');
......@@ -69,6 +77,7 @@ class ConditionMatcher extends AbstractConditionMatcher
$this->expressionLanguageResolverVariables = [
'tree' => $tree,
'frontend' => $frontend,
'backend' => $backend,
'workspace' => $workspace,
'page' => $GLOBALS['TSFE']->page ?? [],
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment