/** * Check if a folder operation (= action) is allowed on a Folder * * This method, by design, does not throw exceptions or do logging. * See the checkFileActionPermission() method above for the reasons. * * @param string $action * @param \TYPO3\CMS\Core\Resource\Folder $folder * @return boolean */ public function checkFolderActionPermission($action, \TYPO3\CMS\Core\Resource\Folder $folder = NULL) { // Check 1: Does the user have permission to perform the action? e.g. "writeFolder" if ($this->checkUserActionPermission($action, 'Folder') === FALSE) { return FALSE; } // Check 2: Does the user has the right to perform the action? // (= is he within the file mount borders) if (is_array($this->fileMounts) && count($this->fileMounts) && !$this->isWithinFileMountBoundaries($folder)) { return FALSE; } $isReadCheck = FALSE; if ($action === 'read') { $isReadCheck = TRUE; } $isWriteCheck = FALSE; if (in_array($action, array('write', 'delete', 'deleteRecursive'))) { $isWriteCheck = TRUE; } // Check 3: Check the capabilities of the storage (and the driver) if ($isReadCheck && !$this->isBrowsable()) { return FALSE; } if ($isWriteCheck && !$this->isWritable()) { return FALSE; } // Check 4: "Folder permissions" of the driver $folderPermissions = $this->driver->getFolderPermissions($folder); if ($isReadCheck && !$folderPermissions['r']) { return FALSE; } if ($isWriteCheck && !$folderPermissions['w']) { return FALSE; } return TRUE; }