‪TYPO3CMS  ‪main
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 
26 
46 {
47  public function ‪__construct()
48  {
49  parent::__construct();
50  $this->name = 'ADMCMD_prev';
51  }
52 
60  public function ‪checkWorkspace(int|array $wsRec): array|false
61  {
62  // If not array, look up workspace record:
63  if (!is_array($wsRec)) {
64  if ($wsRec === 0) {
65  return ['uid' => 0, '_ACCESS' => 'member'];
66  }
67  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_workspace');
68  $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(RootLevelRestriction::class));
69  $wsRec = $queryBuilder
70  ->select('*')
71  ->from('sys_workspace')
72  ->where($queryBuilder->expr()->eq(
73  'uid',
74  $queryBuilder->createNamedParameter($wsRec, ‪Connection::PARAM_INT)
75  ))
76  ->executeQuery()
77  ->fetchAssociative();
78  }
79  // If the workspace exists in the database, the preview user is automatically a member to that workspace
80  if (is_array($wsRec)) {
81  return array_merge($wsRec, ['_ACCESS' => 'member']);
82  }
83  return false;
84  }
85 
92  public function ‪getPagePermsClause($perms)
93  {
94  if ($perms === ‪Permission::PAGE_SHOW) {
95  return '1=1';
96  }
97  return '0=1';
98  }
99 
106  public function ‪calcPerms($row)
107  {
109  }
110 }
‪TYPO3\CMS\Workspaces\Authentication
Definition: PreviewUserAuthentication.php:18
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:52
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\calcPerms
‪int calcPerms($row)
Definition: PreviewUserAuthentication.php:106
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\__construct
‪__construct()
Definition: PreviewUserAuthentication.php:47
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication
Definition: PreviewUserAuthentication.php:46
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\checkWorkspace
‪array false checkWorkspace(int|array $wsRec)
Definition: PreviewUserAuthentication.php:60
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication\getPagePermsClause
‪string getPagePermsClause($perms)
Definition: PreviewUserAuthentication.php:92
‪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:35
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:41
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52