You are here

function social_group_get_all_group_members in Open Social 8.9

Same name and namespace in other branches
  1. 8 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  2. 8.2 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  3. 8.3 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  4. 8.4 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  5. 8.5 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  6. 8.6 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  7. 8.7 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  8. 8.8 modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  9. 10.3.x modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  10. 10.0.x modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  11. 10.1.x modules/social_features/social_group/social_group.module \social_group_get_all_group_members()
  12. 10.2.x modules/social_features/social_group/social_group.module \social_group_get_all_group_members()

Get all group memberships for a certain user.

Parameters

int $uid: The UID for which we fetch the groups it is member of.

Return value

array List of group IDs the user is member of.

Deprecated

in Open Social 4.2 and will be removed in one of the next major updates. This function is moved to the service social_group.helper_service, use getAllGroupsForUser() instead.

See also

https://www.drupal.org/node/3026220

2 calls to social_group_get_all_group_members()
ActivityFilterPersonalisedHomepage::query in modules/custom/activity_viewer/src/Plugin/views/filter/ActivityFilterPersonalisedHomepage.php
Filters out activity items the user is not allowed to see.
ActivityPostVisibilityAccess::query in modules/custom/activity_viewer/src/Plugin/views/filter/ActivityPostVisibilityAccess.php
Filters out activity items the user is not allowed to see.

File

modules/social_features/social_group/social_group.module, line 1582
The Social group module.

Code

function social_group_get_all_group_members($uid) {
  @trigger_error('social_group_get_all_group_members() is deprecated in Open Social 4.2 and will be removed in
  one of the next major updates. This function is moved to the service social_group.helper_service, use
  getAllGroupsForUser() instead. See https://www.drupal.org/node/3026220.', E_USER_DEPRECATED);
  $groups =& drupal_static(__FUNCTION__);

  // Get the memberships for the user if they aren't known yet.
  if (!isset($groups[$uid])) {
    $group_content_types = GroupContentType::loadByEntityTypeId('user');
    $group_content_types = array_keys($group_content_types);
    $query = \Drupal::database()
      ->select('group_content_field_data', 'gcfd');
    $query
      ->addField('gcfd', 'gid');
    $query
      ->condition('gcfd.entity_id', $uid);
    $query
      ->condition('gcfd.type', $group_content_types, 'IN');
    $query
      ->execute()
      ->fetchAll();
    $group_ids = $query
      ->execute()
      ->fetchAllAssoc('gid');
    $groups[$uid] = array_keys($group_ids);
  }
  return $groups[$uid];
}