public function getAllGroupsForUser($uid) {
    $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 = $this->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];
  }
public function getAllGroupsForUser($uid) {
    $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 = $this->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];
  }
public function getAllGroupsForUser ( $ uid ) { $ 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 = $ this -> 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 ] ; }
Get all group memberships for a certain user.

@param int $uid
The UID for which we fetch the groups he is member of.

@return array
List of group IDs the user is member of.
Get all group memberships for a certain user .