‪TYPO3CMS  11.5
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 
18 use Psr\Http\Message\ServerRequestInterface;
23 
34 {
40  {
41  $storage = $event->‪getStorage();
42  if ((‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
43  && ‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isBackend()
44  && !‪$GLOBALS['BE_USER']->isAdmin()
45  && !$storage->isFallbackStorage()
46  ) {
47  $storage->setEvaluatePermissions(true);
48  $storage->setUserPermissions(‪$GLOBALS['BE_USER']->getFilePermissionsForStorage($storage));
49  $this->‪addFileMountsToStorage($storage);
50  }
51  }
52 
58  private function ‪addFileMountsToStorage(‪ResourceStorage $storage)
59  {
60  foreach (‪$GLOBALS['BE_USER']->getFileMountRecords() as $fileMountRow) {
61  if ((int)$fileMountRow['base'] === (int)$storage->‪getUid()) {
62  try {
63  $storage->‪addFileMount($fileMountRow['path'], $fileMountRow);
64  } catch (‪FolderDoesNotExistException $e) {
65  // That file mount does not seem to be valid, fail silently
66  }
67  }
68  }
69  }
70 }
‪TYPO3\CMS\Core\Http\ApplicationType\fromRequest
‪static static fromRequest(ServerRequestInterface $request)
Definition: ApplicationType.php:62
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\addUserPermissionsToStorage
‪addUserPermissionsToStorage(AfterResourceStorageInitializationEvent $event)
Definition: StoragePermissionsAspect.php:39
‪TYPO3\CMS\Core\Resource\ResourceStorage\getUid
‪int getUid()
Definition: ResourceStorage.php:330
‪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:558
‪TYPO3\CMS\Core\Http\ApplicationType
Definition: ApplicationType.php:52
‪TYPO3\CMS\Core\Resource\Event\AfterResourceStorageInitializationEvent
Definition: AfterResourceStorageInitializationEvent.php:28
‪TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException
Definition: FolderDoesNotExistException.php:21
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:125
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect
Definition: StoragePermissionsAspect.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Resource\Security\StoragePermissionsAspect\addFileMountsToStorage
‪addFileMountsToStorage(ResourceStorage $storage)
Definition: StoragePermissionsAspect.php:58