General developer forum

Disable delete in filemanager

Picture of Kais Abid
Disable delete in filemanager


I am working on a plugin that has a filemanager. I would like to restrict some users from deleting content within the file manager. I thought about disabling the delete button that shows up when you right click on a file/folder.

The approach I am considering is to use the $('.fp-file-delete').hide() on the delete button. The problem here is the file manager takes more time to load and my hide() function gets called before the element exists on the page and thus the button is still visible for all users. 

This is the url Moodle/lib/ajax/service.php after which the file manager actually loads.

1-Is there a different way of preventing users from using/pressing the delete button from the filemanager ?

2-If my only option is to hide the delete button, is there a way to know when the filemanager actually loads (Not the document/page, just the filemanager) ? Like a trigger of some sort ? (No events available, I checked.)

Any help is highly appreciated.

Thanks !

Average of ratings: -