TYPO3 CMS  TYPO3_8-7
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 }
addFileMount($folderIdentifier, $additionalData=[])
setUserPermissions(array $userPermissions)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
addUserPermissionsToStorage(ResourceFactory $resourceFactory, ResourceStorage $storage)