‪TYPO3CMS  9.5
StoragePermissionsAspect.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 
33 {
38 
43  'readFolder' => true,
44  'readFile' => true
45  ];
46 
50  public function ‪__construct(‪$backendUserAuthentication = null)
51  {
52  $this->backendUserAuthentication = ‪$backendUserAuthentication ?: ‪$GLOBALS['BE_USER'];
53  }
54 
61  public function ‪addUserPermissionsToStorage(‪ResourceFactory $resourceFactory, ‪ResourceStorage $storage)
62  {
63  if ((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && !$this->backendUserAuthentication->isAdmin()) {
64  $storage->‪setEvaluatePermissions(true);
65  if ($storage->‪getUid() > 0) {
66  $storage->‪setUserPermissions($this->backendUserAuthentication->getFilePermissionsForStorage($storage));
67  } else {
68  $storage->‪setEvaluatePermissions(false);
69  }
70  $this->‪addFileMountsToStorage($storage);
71  }
72  }
73 
79  protected function ‪addFileMountsToStorage(‪ResourceStorage $storage)
80  {
81  foreach ($this->backendUserAuthentication->getFileMountRecords() as $fileMountRow) {
82  if ((int)$fileMountRow['base'] === (int)$storage->‪getUid()) {
83  try {
84  $storage->‪addFileMount($fileMountRow['path'], $fileMountRow);
85  } catch (‪FolderDoesNotExistException $e) {
86  // That file mount does not seem to be valid, fail silently
87  }
88  }
89  }
90  }
91 }
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:271
‪TYPO3\CMS\Core\Resource\ResourceStorage\setUserPermissions
‪setUserPermissions(array $userPermissions)
Definition: ResourceStorage.php:600
‪TYPO3\CMS\Core\Resource\Security
Definition: FileMetadataPermissionsAspect.php:2
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount
‪addFileMount($folderIdentifier, $additionalData=[])
Definition: ResourceStorage.php:483
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\__construct
‪__construct($backendUserAuthentication=null)
Definition: StoragePermissionsAspect.php:48
‪TYPO3\CMS\Core\Resource\ResourceStorage\setEvaluatePermissions
‪setEvaluatePermissions($evaluatePermissions)
Definition: ResourceStorage.php:579
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\addUserPermissionsToStorage
‪addUserPermissionsToStorage(ResourceFactory $resourceFactory, ResourceStorage $storage)
Definition: StoragePermissionsAspect.php:59
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:33
‪TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException
Definition: FolderDoesNotExistException.php:21
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\$backendUserAuthentication
‪BackendUserAuthentication $backendUserAuthentication
Definition: StoragePermissionsAspect.php:36
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:74
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect
Definition: StoragePermissionsAspect.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\addFileMountsToStorage
‪addFileMountsToStorage(ResourceStorage $storage)
Definition: StoragePermissionsAspect.php:77
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\$defaultStorageZeroPermissions
‪array $defaultStorageZeroPermissions
Definition: StoragePermissionsAspect.php:40