Presentation by Kyle Einecker
kristiaanvandeneynde
Been around since 2013
~700 installs
Based on nodes
UX
DX
Top level menu
Define group types
Fieldable
ExamplesGroups
Group memberships
Group roles
Groups
Group memberships
Group roles
OG
global $user; $group = node_load($gid); if (!$group_type) { $group_type = 'node'; } if (!$membership_type) { $membership_type = OG_MEMBERSHIP_TYPE_DEFAULT; } $is_a_group = $group->group_group[$group->language][0]['value']; if ($is_a_group && $user) { $values = array( 'entity_type' => 'user', 'entity' => $user, 'state' => OG_STATE_ACTIVE, 'membership_type' => $membership_type ); og_group($group_type, $gid, $values);
Group
global $user; $group = group_load($gid); $group->addMember($user->uid);
OG
$group = node_load($gid); og_get_group_members_properties($group, array(), 'members', 'node');
Group
$group = group_load($gid); $members = $group->getMembers();
Get all group members of all subgroups
$group = group_load($gid); $members = $group->getMembersRecursive();
Any entity can easily be made a child of a group
/** * Implements hook_entity_info_alter(). */ function gnode_entity_info_alter(&$entity_info) { // Nodes can only have one group parent. $entity_info['node']['group entity'] = 'single'; }
OG
I couldn't find a good answer
Group
$group = group_load($gid); $nodes = $group->getEntitiesOfType('node');
Get all entities in group
$group = group_load($gid); $entities = $group->getEntities();
/** * Add a user to a group. * * If the user is anonymous or already a member, nothing changes. * * @param int $uid * The uid of the member. * @param array $values * (optional) Extra values to add to the GroupMembership entity, like the * 'roles' property. You cannot overwrite the group id (gid) or user id * (uid) with this method. Leave blank to make the user 'just a member'. */ public function addMember($uid, array $values = array()) {
/** * Get all members of a group. * * @return array * An array of GroupMembership entities. */ public function getMembers() {
/** * Get all members of a group, including subgroup members. * * @return array * An array of GroupMembership entities. */ public function getMembersRecursive() {
/** * Get all child entities. * * @param bool $flat * (optional) Whether or not to flatten the result array. * @param bool $reset * (optional) Whether to reset the internal cache. * * @return array * An array of child entities, keyed by their type, bundle and entity id. * When $flat is set to TRUE, the return value is one big array of * entities, which are keyed numerically and not by their entity id! */ public function getEntities($flat = FALSE, $reset = FALSE) {
/** * Get all child entities of a certain type. * * @param string $entity_type * The type of child entities. * @param string $bundle * (optional) The bundle of the entity type. * * @return array * An array of child entities of a certain type and optionally bundle, * keyed by their entity id. */ public function getEntitiesOfType($entity_type, $bundle = NULL) {
Views
Panels
Features
Rules
Anything else an entity integrates with
If OG can integrate with it then so can Group
D8 alpha just released
https://www.drupal.org/project/group