Ejemplo n.º 1
0
 /**
  * @param \TYPO3\CMS\Core\Resource\ResourceStorage $resourceStorage
  * @param \TYPO3\CMS\Core\Resource\Driver\DriverInterface $driver
  * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resourceObject
  * @param boolean $relativeToCurrentScript
  * @param string $urlData
  */
 public function getCdnPublicUrl($resourceStorage, $driver, $resourceObject, $relativeToCurrentScript, $urlData)
 {
     if (!$driver instanceof LocalDriver || $this->environmentService->isEnvironmentInBackendMode()) {
         return;
     }
     if (($resourceObject instanceof File || $resourceObject instanceof ProcessedFile) && ($resourceStorage->getCapabilities() & ResourceStorageInterface::CAPABILITY_PUBLIC) == ResourceStorageInterface::CAPABILITY_PUBLIC) {
         $publicUrl = $driver->getPublicUrl($resourceObject->getIdentifier());
         $urlData['publicUrl'] = $GLOBALS['TSFE']->config['config']['cdnBaseUrl'] . $publicUrl;
         if ($resourceObject instanceof File) {
             $urlData['publicUrl'] .= '?' . $resourceObject->getModificationTime();
         } else {
             if ($resourceObject instanceof ProcessedFile) {
                 $urlData['publicUrl'] .= '?' . $resourceObject->getProperty('tstamp');
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource
  * @param $iconName
  * @param array $options
  * @param array $overlays
  */
 public function overrideResourceIcon(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, &$iconName, array &$options, array &$overlays)
 {
     if (!$resource->getStorage()->isPublic()) {
         /** @var $checkPermissionsService \BeechIt\FalSecuredownload\Security\CheckPermissions */
         $checkPermissionsService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('BeechIt\\FalSecuredownload\\Security\\CheckPermissions');
         $currentPermissionsCheck = $resource->getStorage()->getEvaluatePermissions();
         $resource->getStorage()->setEvaluatePermissions(false);
         if ($resource instanceof \TYPO3\CMS\Core\Resource\Folder) {
             $folder = $resource;
         } else {
             $folder = $resource->getParentFolder();
         }
         if ($resource instanceof \TYPO3\CMS\Core\Resource\File && $resource->getProperty('fe_groups')) {
             $overlays['status-overlay-access-restricted'] = array();
             // check if there are permissions set on this specific folder
         } elseif ($folder === $resource && $checkPermissionsService->getFolderPermissions($folder) !== false) {
             $overlays['status-overlay-access-restricted'] = array();
             // check if there are access restrictions in the root line of this folder
         } elseif (!$checkPermissionsService->checkFolderRootLineAccess($folder, false)) {
             $overlays['extensions-fal_securedownload-overlay-permissions'] = array();
         }
         $resource->getStorage()->setEvaluatePermissions($currentPermissionsCheck);
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns the public URL to a file.
  *
  * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource
  * @param bool  $relativeToCurrentScript    Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
  * @return string
  */
 public function getPublicUrl(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $relativeToCurrentScript = false)
 {
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($resource->getIdentifier(), '/_processed_/')) {
         $publicUrl = '../typo3temp/yag' . $resource->getIdentifier();
         // TODO: ....!!!!
     } else {
         $item = $resource->getProperty('yagItem');
         if (!$item instanceof \Tx_Yag_Domain_Model_Item) {
             $pathInfo = new PathInfo($resource->getIdentifier());
             $item = $this->getItem($pathInfo);
         }
         $publicUrl = $this->yagFileSystemDiv->getFileRelFileName($item->getSourceuri());
     }
     if ($relativeToCurrentScript) {
         $publicUrl = PathUtility::getRelativePathTo(PathUtility::dirname(PATH_site . $publicUrl)) . PathUtility::basename($publicUrl);
     }
     return $publicUrl;
 }
 /**
  * Get FeGroups that are allowed to view a file/folder (checks full rootline)
  *
  * @param ResourceInterface $resource
  * @return string
  */
 public function getPermissions(ResourceInterface $resource)
 {
     $currentPermissionsCheck = $resource->getStorage()->getEvaluatePermissions();
     $resource->getStorage()->setEvaluatePermissions(false);
     $feGroups = array();
     // loop trough the root line of an folder and check the permissions of every folder
     foreach ($this->getFolderRootLine($resource->getParentFolder()) as $folder) {
         // fetch folder permissions record
         $folderRecord = $this->utilityService->getFolderRecord($folder);
         // if record found check permissions
         if ($folderRecord) {
             if ($feGroups === array()) {
                 $feGroups = GeneralUtility::trimExplode(',', $folderRecord['fe_groups'], true);
             }
             if ($folderRecord['fe_groups']) {
                 $feGroups = GeneralUtility::keepItemsInArray($feGroups, $folderRecord['fe_groups']);
             }
             break;
         }
     }
     if ($resource instanceof File && $resource->getProperty('fe_groups')) {
         $feGroups = GeneralUtility::keepItemsInArray($feGroups, $resource->getProperty('fe_groups'));
     }
     $resource->getStorage()->setEvaluatePermissions($currentPermissionsCheck);
     return implode(',', $feGroups);
 }