TYPO3 CMS  TYPO3_7-6
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 
62  public function addUserPermissionsToStorage(ResourceFactory $resourceFactory, ResourceStorage $storage)
63  {
64  if (!$this->backendUserAuthentication->isAdmin()) {
65  $storage->setEvaluatePermissions(true);
66  if ($storage->getUid() > 0) {
67  $storage->setUserPermissions($this->backendUserAuthentication->getFilePermissionsForStorage($storage));
68  } else {
69  $storage->setEvaluatePermissions(false);
70  }
71  $this->addFileMountsToStorage($storage);
72  }
73  }
74 
81  protected function addFileMountsToStorage(ResourceStorage $storage)
82  {
83  foreach ($this->backendUserAuthentication->getFileMountRecords() as $fileMountRow) {
84  if ((int)$fileMountRow['base'] === (int)$storage->getUid()) {
85  try {
86  $storage->addFileMount($fileMountRow['path'], $fileMountRow);
87  } catch (FolderDoesNotExistException $e) {
88  // That file mount does not seem to be valid, fail silently
89  }
90  }
91  }
92  }
93 }
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)