threaded comments, cascading delete issue


I'm implementing a threaded commenting functionality to my site with only 2 levels of threading. For example:

User A: This is a message from User A!

  • User B: This is a message from User B!
  • User C: This is a message from User C!

I use relationships to relate sub comments to the main comment. The main comment is related to the owner of the profile page. The sub comments are related to the main comment.

The idea is that if user A deletes his comment, all sub comments are also deleted.

The problem I think is I don't know what to set the owner_guid and container_guid to for each elgg object. Setting the container_guid to to the parent comment or profile guid causes an issue if the poster doesnt own parent comment or profile. However, if I just set the container_guid to 0 I can't get cascading delete to work unless I use:


The line above seems like a hack...

What is the "proper" way to structure these objects? Thanks!