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