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