artgris / FileManagerBundle

FileManager is a simple Multilingual File Manager Bundle for Symfony
MIT License
171 stars 89 forks source link

Prevent deletion of predefined folders #120

Open WebDevM4DC opened 1 year ago

WebDevM4DC commented 1 year ago

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?

WebDevM4DC commented 1 year ago

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

WebDevM4DC commented 1 year ago

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