‪TYPO3CMS  10.4
FrontendGroupsRepository.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 
32 {
38  public function ‪getAvailableFrontendUserGroups(): array
39  {
40  $optionCount = $this->‪getUserGroupOptionCountByBackendUser($this->‪getBackendUser());
41 
42  $frontendGroups = [];
43  if ($optionCount > 0) {
44  $frontendGroups = $this->‪getUserGroupsForPagesByBackendUser($this->‪getBackendUser());
45  }
46 
47  return $frontendGroups;
48  }
49 
57  {
58  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
59  ->getQueryBuilderForTable('fe_groups');
60 
61  $queryBuilder->getRestrictions()
62  ->removeAll()
63  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
64 
65  $optionCount = $queryBuilder->count('fe_groups.uid')
66  ->from('fe_groups', 'fe_groups')
67  ->innerJoin(
68  'fe_groups',
69  'pages',
70  'pages',
71  $queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('fe_groups.pid'))
72  )
73  ->where(
75  )
76  ->execute()
77  ->fetchColumn(0);
78 
79  return (int)$optionCount;
80  }
81 
89  {
90  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
91  ->getQueryBuilderForTable('fe_groups');
92 
93  $queryBuilder->getRestrictions()
94  ->removeAll()
95  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
96 
97  return $queryBuilder->select('fe_groups.uid', 'fe_groups.title')
98  ->from('fe_groups')
99  ->innerJoin(
100  'fe_groups',
101  'pages',
102  'pages',
103  $queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('fe_groups.pid'))
104  )
105  ->where(
107  )
108  ->orderBy('fe_groups.title')
109  ->execute()
110  ->fetchAll();
111  }
112 
119  {
120  return ‪$GLOBALS['BE_USER'];
121  }
122 }
‪TYPO3\CMS\Adminpanel\Repositories\FrontendGroupsRepository\getUserGroupOptionCountByBackendUser
‪int getUserGroupOptionCountByBackendUser(FrontendBackendUserAuthentication $beUser)
Definition: FrontendGroupsRepository.php:56
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getPagePermsClause
‪string getPagePermsClause($perms)
Definition: BackendUserAuthentication.php:499
‪TYPO3\CMS\Backend\FrontendBackendUserAuthentication
Definition: FrontendBackendUserAuthentication.php:31
‪TYPO3\CMS\Adminpanel\Repositories\FrontendGroupsRepository\getAvailableFrontendUserGroups
‪array getAvailableFrontendUserGroups()
Definition: FrontendGroupsRepository.php:38
‪TYPO3\CMS\Adminpanel\Repositories\FrontendGroupsRepository
Definition: FrontendGroupsRepository.php:32
‪TYPO3\CMS\Adminpanel\Repositories
Definition: FrontendGroupsRepository.php:18
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:24
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:33
‪TYPO3\CMS\Adminpanel\Repositories\FrontendGroupsRepository\getBackendUser
‪FrontendBackendUserAuthentication getBackendUser()
Definition: FrontendGroupsRepository.php:118
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Adminpanel\Repositories\FrontendGroupsRepository\getUserGroupsForPagesByBackendUser
‪array getUserGroupsForPagesByBackendUser(FrontendBackendUserAuthentication $beUser)
Definition: FrontendGroupsRepository.php:88