Reference Counting Permissions

12 views
Skip to first unread message

swaiba

unread,
May 24, 2015, 11:14:16 AM5/24/15
to silverst...@googlegroups.com
Hi All,

When creating and giving permissions to DataObjects to users there is always the case where users make bad decisions to delete Objects referenced by others - however it isn't like there is anything to help them know that.

Is there a module with this in that I can try out?  If not any high level comments on how to implement?
Or should this be raised elsewhere?

Best Regards,
Barry

Patrick Nelson

unread,
May 24, 2015, 1:53:27 PM5/24/15
to silverst...@googlegroups.com
I've built a feature which prevents a user in the CMS from deleting a file (only u linking it) if that file is in use elsewhere within the system, but it isn't very efficient. The idea you propose is I think very much needed. My solution was to setup a FileUploadField data extension which then did a quick lookup for each file in a field (one or multiple) and went through the entire system looking for references to that File's ID (as long as thenDataObject was defined to have a relation of some sort) and it would reference the table directly instead of hitting the ORM. I really don't think files and DB relations should be orphaned like that if user accidentally deleted it under one specific data object. Then to fix the issue they have to reupload all the orphaned references to the deleted file. 

A better solution may be to add a method (either directly in API or via DataExtension) to facilitate a simple ->getReferences() and  ->getReferenceCount() which you could check to see if it has more than one reference and then allow deletion if it's is < 2. 

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages