‪TYPO3CMS  10.4
StoragePermissionsAspect.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
33 {
38 
42  public function ‪__construct(‪$backendUserAuthentication = null)
43  {
44  $this->backendUserAuthentication = ‪$backendUserAuthentication ?: ‪$GLOBALS['BE_USER'];
45  }
46 
52  {
53  $storage = $event->‪getStorage();
54  if ((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE) && !$this->backendUserAuthentication->isAdmin()) {
55  $storage->setEvaluatePermissions(true);
56  if ($storage->getUid() > 0) {
57  $storage->setUserPermissions($this->backendUserAuthentication->getFilePermissionsForStorage($storage));
58  } else {
59  $storage->setEvaluatePermissions(false);
60  }
61  $this->‪addFileMountsToStorage($storage);
62  }
63  }
64 
70  private function ‪addFileMountsToStorage(‪ResourceStorage $storage)
71  {
72  foreach ($this->backendUserAuthentication->getFileMountRecords() as $fileMountRow) {
73  if ((int)$fileMountRow['base'] === (int)$storage->‪getUid()) {
74  try {
75  $storage->‪addFileMount($fileMountRow['path'], $fileMountRow);
76  } catch (‪FolderDoesNotExistException $e) {
77  // That file mount does not seem to be valid, fail silently
78  }
79  }
80  }
81  }
82 }
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\addUserPermissionsToStorage
‪addUserPermissionsToStorage(AfterResourceStorageInitializationEvent $event)
Definition: StoragePermissionsAspect.php:50
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:321
‪TYPO3\CMS\Core\Resource\Event\AfterResourceStorageInitializationEvent\getStorage
‪getStorage()
Definition: AfterResourceStorageInitializationEvent.php:38
‪TYPO3\CMS\Core\Resource\Security
Definition: FileMetadataPermissionsAspect.php:16
‪TYPO3\CMS\Core\Resource\ResourceStorage\addFileMount
‪addFileMount($folderIdentifier, $additionalData=[])
Definition: ResourceStorage.php:536
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\__construct
‪__construct($backendUserAuthentication=null)
Definition: StoragePermissionsAspect.php:41
‪TYPO3\CMS\Core\Resource\Event\AfterResourceStorageInitializationEvent
Definition: AfterResourceStorageInitializationEvent.php:28
‪TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException
Definition: FolderDoesNotExistException.php:22
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\$backendUserAuthentication
‪BackendUserAuthentication $backendUserAuthentication
Definition: StoragePermissionsAspect.php:36
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:122
‪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:69