How to store entities in a group correctly?

I developed a plugin which integrates in groups in elgg. I store the objects of my plugin with

  1. owner_guid set to the logged in user id of the creator
  2. container_guid set to the groups id
  3. access_id set to the group in the access list

Now if I list the entities logged in as administrator it works fine. All entities of this group are shown. If I list the entities as a "normal" user I can only see the entities created by that user not all entities in that group. Regardless of using get_objects_in_group(), get_entities('object', 'myplugin', page_owner()), etc. pp. What am I doing wrong?

Peter

  • The group entity guid is not the same as the group access id. I think it is stored as metadata on the group object: $group->group_acl

  • Thanks for the answer. So, I use a form including the view input/access to output the selector of available access id's. The user selects the group from that list and I store the selection in the access_id of my entity. But perhaps I miss something, like the group_acl?! Do I have to store that in my entity?

  • I just searched all files for 'group_acl' but could only find it in mod/group/start.php So, it seems none of the group aware plugins like Blog/File/Page use it?

    We created a new group aware plugin and that one seems to work just fine. Of course, users that create an object for a group should have an access right allowing the group members to see it... A little dirty (or wrong even?) maybe , but we set all access rights of the new objects to Public and use a separate metadata object that contains the access rights and users can set explicitly.  

  • I had another try with my plugin today. It seems to work allright now. So, I mainly do what I did before. Setting the access_id of my entity to the group (not the group_id, but the group ACL or how it is called) and using the group_id as container_id seems to do all the magic I need. Tom, why do you set the access_id to Public?

  • The plugins like blog do not need to use group_acl because it is used to in the creation of the access dropdown list. The only time you need to use it is when you are hard coding something to be group only.