Working with d8

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
matslats's picture

I need to integrate my project quite deeply with og in drupal 8 but I'm struggling with some of the concepts, and very little progress has been made with the code recently.
Could somebody clarify for me, to save me time,
What does it mean for an entity to be a member of a group, when a row is created in og_members table. Is this intended for users only?
and what does it mean for an entity to have a group as an audience, with its own field? Is this for content and access control?
It seems like 2 separate systems for relating an entity to a group, and for my use-case I'm not sure which is which.
Will there be differences between 7 and 8 in this respect?
Thanks

Comments

Answers

paulovg12's picture

I believe you are grappling with basic OG concepts.

Question 1

People become members of a Group / An object can also be a Group once created - for example a create a content structure called Club - with a few fields (motto, etc) in the OG options I can specify that I want it to be a group - at the same time - I can define permissions for this group type including which object types members in specific roles it can access, If setup properly - a panel can be produced - some sort of landing page for the group where all contents whose OG Audience includes the group are published.

Question 2 - Group Audience - Any content type (whether group or not a group) - I can specify which groups a particular page can be visible in. If I don't specify anything it becomes available to all users with drupal permission for that object.

There are other settings including enabling basic content types like Pages etc. to belong to a group. It becomes complicated but all of them work together to ensure maximum flexibility in creating these OG / security subgroups with as much flexibility as required.

I am stil in d7 - I do not think these concepts will change with d8. - but double check with drupal.org/modules/ Organic_groups to be certain.

Thanks a lot paul

matslats's picture

Some of this answer was heavy going, but I take away at least this:
That the og_membership concept is not just a reverse lookup for the Audience.
Therefore that membership of a group concerns users and roles while the group audience field concerns content or any entity which is accessible to group members.
What puzzles me then, is why the og_memberhip table in d8 contains a column for entity_type (in fact it looks very similar to a fieldAPI table but without the bundle column) when you seem to say that 'People' i.e. user entities become members of a group, no other entities.
Can entities other than users be group members?
I see that group content has an audience field added, which is intuitive, but are group member entities modified or augmented in any way or is the membership a completely separate entity?
Perhaps the early version of OG for d8 is not the best learning ground...

Any custom content type can

paulovg12's picture

Any custom content type can be a group - I can't say for certain but that is probably why you have that field entity_type in the group member table. .... A better approach would probably be to start using it first then look at the schema later. There are a number of instructional video available in the organic group page in drupal.org that explains the capabilities of the OG maybe you should watch them. Its not really that complicated once you get to use it and it will make a lot of sense once you have 2-3 content types defined as groups and people that are members across them.

'A better approach would

paean99's picture

'A better approach would probably be to start using it first then look at the schema later.'
Yes I agree, it is often the best approach.
In the meanwhile, here is some thoughts about organic groups structure.
Since version 2 of organic group, any entities can be a group or a member of it. Even a user can be a group, which could be used to make a site like facebook or similar, controlling the access to the content of the user.
Each relation in that structure is created and controlled by the 'og_fields' (og_group_ref, group_group, ...).

  • Boolean group_group for enabling an entity as a group.
  • Entity reference og_group_ref for selecting a content (audience) of a group.
  • Entity reference og_user_node for selecting a user (member) of a content group.
  • Entity reference og_user_user for selecting a user (member) of a user group.

The membership is a separate entity that is used to control all of the organic groups structure. When you create a group, it must have to types of entities with membership to it: members (og_user_...) of user entities and audience (og_group_ref) of any entities (included users).

For the og_memberhip table it collect the different memberships of each group. So for ex.

id etid entity_type gid group_type field_name
1 1 user 28 node og_user_node
2 29 node 28 node og_group_ref
3 36 user 28 node og_user_node
4 36 user 36 user og_user_user
5 33 node 36 user og_group_ref
6 37 user 36 user og_user_user

In this table we have 3 groups.
First 3 rows for group 28 of type node (node 28) with two members (users 1 and 36) and one audience node (29).
Row from 4 to 6, we have group 36 of type user (user 36) with 2 members (users 36 and 37) and one audience node (33). As we can see here, user 36 is the group and also a member of itself.

Of great help is this conference by Amitai Burstein (amitaibu) the maintainer of Organic groups. There are some very interesting details in there, but try not to laugh to much with the beginning (its conferences are always very challenging in some way)
DrupalCon Portland 2013 - Amitai Burstein - Organic Groups \ Message

thanks

matslats's picture

That's just the kind of explanation I needed.

Answers

paulovg12's picture

I believe you are grappling with basic OG concepts.

Question 1

People become members of a Group / An object can also be a Group once created - for example a create a content structure called Club - with a few fields (motto, etc) in the OG options I can specify that I want it to be a group - at the same time - I can define permissions for this group type including which object types members in specific roles it can access, If setup properly - a panel can be produced - some sort of landing page for the group where all contents whose OG Audience includes the group are published.

Question 2 - Group Audience - Any content type (whether group or not a group) - I can specify which groups a particular page can be visible in. If I don't specify anything it becomes available to all users with drupal permission for that object.

There are other settings including enabling basic content types like Pages etc. to belong to a group. It becomes complicated but all of them work together to ensure maximum flexibility in creating these OG / security subgroups with as much flexibility as required.

I am stil in d7 - I do not think these concepts will change with d8. - but double check with drupal.org/modules/ Organic_groups to be certain.

Organic groups

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week