FileManagerBundle icon indicating copy to clipboard operation
FileManagerBundle copied to clipboard

Prevent deletion of predefined folders

Open TheAFOGroup opened this issue 1 year ago • 2 comments

Hello,

Thank you for this amazing library. Would it be possible to prevent users from deleting some "main" folders? For example,

uploads
  --> folder 1
  --> folder 2
  --> folder 2

From reading the documentation this would be possible using custom service; if this is correct, could you provide a small example?

TheAFOGroup avatar May 31 '23 06:05 TheAFOGroup

Essentially ACLs are needed... who can upload, who cannot... when you have a basic user system with Symfony.

TheAFOGroup avatar Jun 01 '23 16:06 TheAFOGroup

We managed to do ACLs using the following method:

  1. Inject user roles via CustomService (however your documentation is a bit wrong, it should be using TokenStorageInterface)
  2. Subscribe to events and check user roles

However, there are still some things lacking:

  1. You need to put a try/catch here https://github.com/artgris/FileManagerBundle/blob/683f1a349db2b28afdd88bdabe115e5e71e096ca/Controller/ManagerController.php#L238 because otherwise the custom message is now shown. We also recommend renaming this even to PRE_FILE_UPLOAD for consistency.
  2. There is no event for creating folders; just plain POST so this cannot be restricted.
  3. Folders are not listed, only on the left navigation menu.

Thank you

TheAFOGroup avatar Jun 02 '23 05:06 TheAFOGroup