39 'initializeView' =>
'Using BackendUserController::initializeView() is deprecated and will not be possible anymore in TYPO3 v10.0.',
113 $this->moduleData = $this->moduleDataStorageService->loadModuleData();
117 $this->moduleDataStorageService->persistModuleData($this->moduleData);
118 }
catch (\
TYPO3\CMS\
Extbase\Mvc\Exception\StopActionException $e) {
119 $this->moduleDataStorageService->persistModuleData($this->moduleData);
131 'shortcutLabel' =>
'backendUsers',
132 'dateFormat' =>
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'],
133 'timeFormat' =>
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'hhmm'],
145 if ($demand ===
null) {
146 $demand = $this->moduleData->getDemand();
148 $this->moduleData->setDemand($demand);
151 $switchUser = (int)GeneralUtility::_GP(
'SwitchUser');
152 if ($switchUser > 0) {
155 $compareUserList = $this->moduleData->getCompareUserList();
158 $onlineUsers = $this->backendUserSessionRepository->findAllActive();
159 $onlineBackendUsers = [];
160 if (is_array($onlineUsers)) {
161 foreach ($onlineUsers as $onlineUser) {
162 $onlineBackendUsers[$onlineUser[
'ses_userid']] =
true;
166 $this->view->assignMultiple([
167 'onlineBackendUsers' => $onlineBackendUsers,
169 'backendUsers' => $this->backendUserRepository->findDemanded($demand),
170 'backendUserGroups' => array_merge([
''], $this->backendUserGroupRepository->findAll()->toArray()),
171 'compareUserUidList' => array_combine($compareUserList, $compareUserList),
173 'compareUserList' => !empty($compareUserList) ? $this->backendUserRepository->findByUidList($compareUserList) :
'',
182 $onlineUsersAndSessions = [];
183 $onlineUsers = $this->backendUserRepository->findOnline();
184 foreach ($onlineUsers as $onlineUser) {
185 $onlineUsersAndSessions[] = [
186 'backendUser' => $onlineUser,
187 'sessions' => $this->backendUserSessionRepository->findByBackendUser($onlineUser)
193 if ($sessionBackend instanceof HashableSessionBackendInterface) {
194 $currentSessionId = $sessionBackend->hash($currentSessionId);
196 $this->view->assignMultiple([
197 'shortcutLabel' =>
'onlineUsers',
198 'onlineUsersAndSessions' => $onlineUsersAndSessions,
199 'currentSessionId' => $currentSessionId,
208 $compareUserList = $this->moduleData->getCompareUserList();
209 if (empty($compareUserList)) {
213 $this->view->assignMultiple([
214 'shortcutLabel' =>
'compareUsers',
215 'compareUserList' => $this->backendUserRepository->findByUidList($compareUserList),
226 $this->moduleData->attachUidCompareUser($uid);
227 $this->moduleDataStorageService->persistModuleData($this->moduleData);
238 $this->moduleData->detachUidCompareUser($uid);
239 $this->moduleDataStorageService->persistModuleData($this->moduleData);
254 $success = $sessionBackend->remove($sessionId);
279 'ses_userid' => (
int)$targetUser[
'uid'],
286 $redirectUrl =
'index.php' . (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'interfaces'] ?
'' :
'?commandLI=1');
299 $latestUserUids = [];
302 if (isset($backendUser->uc[
'recentSwitchedToUsers']) && is_array($backendUser->uc[
'recentSwitchedToUsers'])) {
303 $latestUserUids = $backendUser->uc[
'recentSwitchedToUsers'];
307 $index = array_search($targetUserUid, $latestUserUids,
true);
308 if ($index !==
false) {
309 unset($latestUserUids[$index]);
312 array_unshift($latestUserUids, $targetUserUid);
313 $latestUserUids = array_slice($latestUserUids, 0, static::RECENT_USERS_LIMIT);
315 return $latestUserUids;
325 $this->signalSlotDispatcher->dispatch(__CLASS__,
'switchUser', [$targetUser]);
342 return GeneralUtility::makeInstance(SessionManager::class)->getSessionBackend($loginType);