‪TYPO3CMS  10.4
BackendUserGroupController.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
28 {
33 
38  {
39  $this->backendUserGroupRepository = ‪$backendUserGroupRepository;
40  }
41 
46 
47  public function ‪__construct(
49  ) {
50  $this->userInformationService = ‪$userInformationService;
51  }
52 
56  public function ‪indexAction(): void
57  {
58  $compareGroupUidList = array_keys($this->‪getBackendUser()->uc['beuser']['compareGroupUidList'] ?? []);
59  $this->view->assignMultiple(
60  [
61  'shortcutLabel' => 'backendUserGroupsMenu',
62  'backendUserGroups' => $this->backendUserGroupRepository->findAll(),
63  'compareGroupUidList' => array_map(static function ($value) { // uid as key and force value to 1
64  return 1;
65  }, array_flip($compareGroupUidList)),
66  'compareGroupList' => !empty($compareGroupUidList) ? $this->backendUserGroupRepository->findByUidList($compareGroupUidList) : [],
67  ]
68  );
69  }
70 
71  public function ‪compareAction(): void
72  {
73  $compareGroupUidList = array_keys($this->‪getBackendUser()->uc['beuser']['compareGroupUidList'] ?? []);
74 
75  $compareData = [];
76  foreach ($compareGroupUidList as $uid) {
77  if ($compareInformation = $this->userInformationService->getGroupInformation($uid)) {
78  $compareData[] = $compareInformation;
79  }
80  }
81  if (empty($compareData)) {
82  $this->‪redirect('index');
83  }
84 
85  $this->view->assignMultiple([
86  'shortcutLabel' => 'compareBackendUsersGroups',
87  'compareGroupList' => $compareData,
88  ]);
89  }
90 
96  public function ‪addToCompareListAction(int $uid): void
97  {
98  $list = $this->‪getBackendUser()->uc['beuser']['compareGroupUidList'] ?? [];
99  $list[$uid] = true;
100  $this->‪getBackendUser()->uc['beuser']['compareGroupUidList'] = $list;
101  $this->‪getBackendUser()->writeUC();
102 
103  $this->‪redirect('index');
104  }
105 
112  public function ‪removeFromCompareListAction(int $uid, int $redirectToCompare = 0): void
113  {
114  $list = $this->‪getBackendUser()->uc['beuser']['compareGroupUidList'] ?? [];
115  unset($list[$uid]);
116  $this->‪getBackendUser()->uc['beuser']['compareGroupUidList'] = $list;
117  $this->‪getBackendUser()->writeUC();
118 
119  if ($redirectToCompare) {
120  $this->‪redirect('compare');
121  } else {
122  $this->‪redirect('index');
123  }
124  }
125 
129  public function ‪removeAllFromCompareListAction(): void
130  {
131  $this->‪getBackendUser()->uc['beuser']['compareGroupUidList'] = [];
132  $this->‪getBackendUser()->writeUC();
133  $this->‪redirect('index');
134  }
135 
136  protected function ‪getBackendUser(): ‪BackendUserAuthentication
137  {
138  return ‪$GLOBALS['BE_USER'];
139  }
140 }
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\removeFromCompareListAction
‪removeFromCompareListAction(int $uid, int $redirectToCompare=0)
Definition: BackendUserGroupController.php:110
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\removeAllFromCompareListAction
‪removeAllFromCompareListAction()
Definition: BackendUserGroupController.php:127
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\addToCompareListAction
‪addToCompareListAction(int $uid)
Definition: BackendUserGroupController.php:94
‪TYPO3\CMS\Beuser\Controller
Definition: BackendUserController.php:16
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController
Definition: BackendUserGroupController.php:28
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\compareAction
‪compareAction()
Definition: BackendUserGroupController.php:69
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\redirect
‪redirect($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
Definition: ActionController.php:852
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\$backendUserGroupRepository
‪TYPO3 CMS Beuser Domain Repository BackendUserGroupRepository $backendUserGroupRepository
Definition: BackendUserGroupController.php:31
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\injectBackendUserGroupRepository
‪injectBackendUserGroupRepository(BackendUserGroupRepository $backendUserGroupRepository)
Definition: BackendUserGroupController.php:36
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\getBackendUser
‪getBackendUser()
Definition: BackendUserGroupController.php:134
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\indexAction
‪indexAction()
Definition: BackendUserGroupController.php:54
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController
Definition: ActionController.php:55
‪TYPO3\CMS\Beuser\Domain\Repository\BackendUserGroupRepository
Definition: BackendUserGroupRepository.php:26
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\__construct
‪__construct(UserInformationService $userInformationService)
Definition: BackendUserGroupController.php:45
‪TYPO3\CMS\Beuser\Service\UserInformationService
Definition: UserInformationService.php:31
‪TYPO3\CMS\Beuser\Controller\BackendUserGroupController\$userInformationService
‪UserInformationService $userInformationService
Definition: BackendUserGroupController.php:43