/** * @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); } }
/** * Like ->getHeader() but for files and folders * Returns the icon with the path of the file/folder set in the alt/title attribute. Shows the name after the icon. * * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title * @param bool $enableClickMenu If TRUE, render click menu code around icon image * @return string */ public function getResourceHeader(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $tWrap = array('', ''), $enableClickMenu = true) { try { $path = $resource->getStorage()->getName() . $resource->getParentFolder()->getIdentifier(); $iconImgTag = '<span title="' . htmlspecialchars($path) . '">' . $this->iconFactory->getIconForResource($resource, Icon::SIZE_SMALL)->render() . '</span>'; } catch (\TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException $e) { $iconImgTag = ''; } if ($enableClickMenu && $resource instanceof \TYPO3\CMS\Core\Resource\File) { $metaData = $resource->_getMetaData(); $iconImgTag = BackendUtility::wrapClickMenuOnIcon($iconImgTag, 'sys_file_metadata', $metaData['uid']); } return '<span class="typo3-moduleHeader">' . $iconImgTag . $tWrap[0] . htmlspecialchars(GeneralUtility::fixed_lgd_cs($resource->getName(), 45)) . $tWrap[1] . '</span>'; }
/** * 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); }
/** * Like ->getHeader() but for files and folders * Returns the icon with the path of the file/folder set in the alt/title attribute. Shows the name after the icon. * * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title * @param bool $enableClickMenu If TRUE, render click menu code around icon image * @return string */ public function getResourceHeader(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $tWrap = array('', ''), $enableClickMenu = TRUE) { $path = $resource->getStorage()->getName() . $resource->getParentFolder()->getIdentifier(); $iconImgTag = IconUtility::getSpriteIconForResource($resource, array('title' => htmlspecialchars($path))); if ($enableClickMenu && $resource instanceof \TYPO3\CMS\Core\Resource\File) { $metaData = $resource->_getMetaData(); $iconImgTag = $this->wrapClickMenuOnIcon($iconImgTag, 'sys_file_metadata', $metaData['uid']); } return '<span class="typo3-moduleHeader">' . $iconImgTag . $tWrap[0] . htmlspecialchars(GeneralUtility::fixed_lgd_cs($resource->getName(), 45)) . $tWrap[1] . '</span>'; }