From 0bbf489ffa683d47e169f63117441714ba42a523 Mon Sep 17 00:00:00 2001 From: Daniel Goerz <daniel.goerz@posteo.de> Date: Sat, 22 Feb 2020 14:50:25 +0100 Subject: [PATCH] [BUGFIX] Restore enable/disable functionality in beuser compare This patch restores the possibility to enable backend users in the compare view again. It also reinstalls the check for online users to prevent disabling a currently logged in user. Resolves: #90488 Relates: #90298 Releases: master Change-Id: I0919403a41de136c7461e0d9367b3795bbf68358 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63371 Tested-by: Susanne Moog <look@susi.dev> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Susanne Moog <look@susi.dev> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> --- .../Controller/BackendUserController.php | 34 +++++++++++++------ .../Partials/BackendUser/IndexListRow.html | 2 +- .../Templates/BackendUser/Compare.html | 22 +++++++----- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/typo3/sysext/beuser/Classes/Controller/BackendUserController.php b/typo3/sysext/beuser/Classes/Controller/BackendUserController.php index 98807c9a2d9b..126bf8b70318 100644 --- a/typo3/sysext/beuser/Classes/Controller/BackendUserController.php +++ b/typo3/sysext/beuser/Classes/Controller/BackendUserController.php @@ -138,17 +138,8 @@ class BackendUserController extends ActionController } $compareUserList = $this->moduleData->getCompareUserList(); - // Create online user list for easy parsing - $onlineUsers = $this->backendUserSessionRepository->findAllActive(); - $onlineBackendUsers = []; - if (is_array($onlineUsers)) { - foreach ($onlineUsers as $onlineUser) { - $onlineBackendUsers[$onlineUser['ses_userid']] = true; - } - } - $this->view->assignMultiple([ - 'onlineBackendUsers' => $onlineBackendUsers, + 'onlineBackendUsers' => $this->getOnlineBackendUsers(), 'demand' => $demand, 'backendUsers' => $this->backendUserRepository->findDemanded($demand), 'backendUserGroups' => array_merge([''], $this->backendUserGroupRepository->findAll()->toArray()), @@ -208,7 +199,8 @@ class BackendUserController extends ActionController $this->view->assignMultiple([ 'shortcutLabel' => 'compareUsers', - 'compareUserList' => $compareData + 'compareUserList' => $compareData, + 'onlineBackendUsers' => $this->getOnlineBackendUsers() ]); } @@ -346,4 +338,24 @@ class BackendUserController extends ActionController $loginType = $this->getBackendUserAuthentication()->getLoginType(); return GeneralUtility::makeInstance(SessionManager::class)->getSessionBackend($loginType); } + + /** + * Create an array with the uids of online users as the keys + * [ + * 1 => true, + * 5 => true + * ] + * @return array + */ + protected function getOnlineBackendUsers(): array + { + $onlineUsers = $this->backendUserSessionRepository->findAllActive(); + $onlineBackendUsers = []; + if (is_array($onlineUsers)) { + foreach ($onlineUsers as $onlineUser) { + $onlineBackendUsers[$onlineUser['ses_userid']] = true; + } + } + return $onlineBackendUsers; + } } diff --git a/typo3/sysext/beuser/Resources/Private/Partials/BackendUser/IndexListRow.html b/typo3/sysext/beuser/Resources/Private/Partials/BackendUser/IndexListRow.html index 047966345a4c..934b0a3dd554 100644 --- a/typo3/sysext/beuser/Resources/Private/Partials/BackendUser/IndexListRow.html +++ b/typo3/sysext/beuser/Resources/Private/Partials/BackendUser/IndexListRow.html @@ -14,7 +14,7 @@ <be:link.editRecord table="be_users" uid="{backendUser.uid}" title="edit"> <b>{backendUser.userName}</b> </be:link.editRecord> - <f:if condition="{bu:arrayElement(array: onlineBackendUsers, key: backendUser.uid)}"> + <f:if condition="{onlineBackendUsers.{backendUser.uid}}"> <span class="label label-success"><f:translate key="online" /></span> </f:if> <br /> diff --git a/typo3/sysext/beuser/Resources/Private/Templates/BackendUser/Compare.html b/typo3/sysext/beuser/Resources/Private/Templates/BackendUser/Compare.html index 4cfc6fbd955d..41b2241450eb 100644 --- a/typo3/sysext/beuser/Resources/Private/Templates/BackendUser/Compare.html +++ b/typo3/sysext/beuser/Resources/Private/Templates/BackendUser/Compare.html @@ -57,16 +57,20 @@ <th><f:translate key="disable_compare" /></th> <f:for each="{compareUserList}" as="compareUser"> <td> - <f:if condition="{compareUser.disable}"> - <f:then> - <a class="btn btn-default" href="{be:moduleLink(route:'tce_db', query:'data[be_users][{compareUser.user.uid}][disable]=0', currentUrlParameterName:'redirect')}" title="{f:translate(key: 'visibility.unhide')}"> - <core:icon identifier="actions-edit-unhide" /> - </a> - </f:then> + <f:if condition="{onlineBackendUsers.{compareUser.user.uid}}"> <f:else> - <a class="btn btn-default" href="{be:moduleLink(route:'tce_db', query:'data[be_users][{compareUser.user.uid}][disable]=1', currentUrlParameterName:'redirect')}" title="{f:translate(key: 'visibility.hide')}"> - <core:icon identifier="actions-edit-hide" /> - </a> + <f:if condition="{compareUser.user.disable}"> + <f:then> + <a class="btn btn-default" href="{be:moduleLink(route:'tce_db', query:'data[be_users][{compareUser.user.uid}][disable]=0', currentUrlParameterName:'redirect')}" title="{f:translate(key: 'visibility.unhide')}"> + <core:icon identifier="actions-edit-unhide" /> + </a> + </f:then> + <f:else> + <a class="btn btn-default" href="{be:moduleLink(route:'tce_db', query:'data[be_users][{compareUser.user.uid}][disable]=1', currentUrlParameterName:'redirect')}" title="{f:translate(key: 'visibility.hide')}"> + <core:icon identifier="actions-edit-hide" /> + </a> + </f:else> + </f:if> </f:else> </f:if> </td> -- GitLab