‪TYPO3CMS  10.4
PreviewUserAuthentication.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 
45 {
46  public function ‪__construct()
47  {
48  parent::__construct();
49  $this->name = 'ADMCMD_prev';
50  }
51 
60  public function ‪checkWorkspace($wsRec, ‪$fields = '*')
61  {
62  // If not array, look up workspace record:
63  if (!is_array($wsRec)) {
64  switch ((int)$wsRec) {
65  case '0':
66  $wsRec = ['uid' => (int)$wsRec];
67  break;
68  default:
69  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_workspace');
70  $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(RootLevelRestriction::class));
71  $wsRec = $queryBuilder->select(...‪GeneralUtility::trimExplode(',', ‪$fields))
72  ->from('sys_workspace')
73  ->where($queryBuilder->expr()->eq(
74  'uid',
75  $queryBuilder->createNamedParameter($wsRec, \PDO::PARAM_INT)
76  ))
77  ->orderBy('title')
78  ->setMaxResults(1)
79  ->execute()
80  ->fetch(\PDO::FETCH_ASSOC);
81  }
82  }
83  // If the workspace exists in the database, the preview user is automatically a member to that workspace
84  if (is_array($wsRec)) {
85  return array_merge($wsRec, ['_ACCESS' => 'member']);
86  }
87  return false;
88  }
89 
96  public function ‪getPagePermsClause($perms)
97  {
98  if ($perms === ‪Permission::PAGE_SHOW) {
99  return '1=1';
100  }
101  return '0=1';
102  }
103 
110  public function ‪calcPerms($row)
111  {
113  }
114 }
‪TYPO3\CMS\Workspaces\Authentication
Definition: PreviewUserAuthentication.php:18
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\checkWorkspace
‪array bool checkWorkspace($wsRec, $fields=' *')
Definition: PreviewUserAuthentication.php:60
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\calcPerms
‪int calcPerms($row)
Definition: PreviewUserAuthentication.php:110
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\__construct
‪__construct()
Definition: PreviewUserAuthentication.php:46
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication
Definition: PreviewUserAuthentication.php:45
‪$fields
‪$fields
Definition: pages.php:5
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:24
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\getPagePermsClause
‪string getPagePermsClause($perms)
Definition: PreviewUserAuthentication.php:96
‪TYPO3\CMS\Core\Database\Query\Restriction\RootLevelRestriction
Definition: RootLevelRestriction.php:27
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:33
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:1059
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46