‪TYPO3CMS  ‪main
WorkspacePublishGate.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 
22 
29 {
37  public function ‪isGranted(‪BackendUserAuthentication $user, ...$conditions): bool
38  {
39  if ($user->‪isAdmin()) {
40  return true;
41  }
42  [$workspaceId] = $conditions;
43  $wsAccess = $user->‪checkWorkspace($workspaceId);
44  // If no access to workspace, of course you cannot publish!
45  if ($wsAccess === false) {
46  return false;
47  }
48  if ((int)$wsAccess['uid'] === 0) {
49  // If access to Live workspace, no problem.
50  return true;
51  }
52  // Custom workspaces
53  // 1. Owners can always publish
54  if ($wsAccess['_ACCESS'] === 'owner') {
55  return true;
56  }
57  // 2. User has access to online workspace which is OK as well as long as publishing
58  // access is not limited by workspace option.
60  }
61 }
‪TYPO3\CMS\Workspaces\Authorization\WorkspacePublishGate
Definition: WorkspacePublishGate.php:29
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\isAdmin
‪bool isAdmin()
Definition: BackendUserAuthentication.php:240
‪TYPO3\CMS\Workspaces\Service\WorkspaceService\LIVE_WORKSPACE_ID
‪const LIVE_WORKSPACE_ID
Definition: WorkspaceService.php:43
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\checkWorkspace
‪array false checkWorkspace(int|array $wsRec)
Definition: BackendUserAuthentication.php:1541
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:61
‪TYPO3\CMS\Workspaces\Service\WorkspaceService
Definition: WorkspaceService.php:38
‪TYPO3\CMS\Workspaces\Authorization
Definition: WorkspacePublishGate.php:18
‪TYPO3\CMS\Workspaces\Service\WorkspaceService\PUBLISH_ACCESS_ONLY_WORKSPACE_OWNERS
‪const PUBLISH_ACCESS_ONLY_WORKSPACE_OWNERS
Definition: WorkspaceService.php:46
‪TYPO3\CMS\Workspaces\Authorization\WorkspacePublishGate\isGranted
‪isGranted(BackendUserAuthentication $user,... $conditions)
Definition: WorkspacePublishGate.php:37