Get the groups for the user.

@param userId
@return a map with the group path as the key and the Group entity as the
value
769920
public Map<String, Group> getGroupsForUser(String userId) {
        ApiResponse response = apiRequest(HttpMethod.GET, null, null,
                organizationId, applicationId, "users", userId, "groups");
        Map<String, Group> groupMap = new HashMap<String, Group>();
        if (response != null) {
            List<Group> groups = response.getEntities(Group.class);
            for (Group group : groups) {
                groupMap.put(group.getPath(), group);
            }
        }
        return groupMap;
    }
965287
@Override
    public Set<Node> getUsersForGroup(Node group) {
		Set<Node> users = new TreeSet<>();
		try {
			String query = "(" + groupIdentifyer + "=" + group.getName() + ")";
			SearchResult searchResult;
			Attributes attributes;
			SearchControls controls = new SearchControls();
			controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
			NamingEnumeration<SearchResult> results = ctx.search("", query, controls);
			Node user;
			while (results.hasMore()) {
				searchResult = results.next();
				attributes = searchResult.getAttributes();
				NamingEnumeration<?> members = attributes.get(groupMemberAttribut).getAll();
				while (members.hasMoreElements()) {
					String memberDN = (String) members.nextElement();
					String uid = getIdentifyerValueFromDN(memberDN);
					user = getUser(uid);
					user.setDn(memberDN);
					users.add(user);
				}
			}
		} catch (NamingException ex) {
			handleNamingException(group, ex);
		}
		return users;
	}
1171565
public List<String> getGroups(String user) throws IOException {
    if (!mCacheEnabled) {
      return mService.getGroups(user);
    }
    try {
      return mCache.get(user);
    } catch (ExecutionException e) {
      throw new IOException(e);
    }
  }
255301
public Group findGroupById(String groupId) {
    return createGroupQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext())
      .groupId(groupId)
      .singleResult();
  }
918421
private Promise<UserKeys> fetchUserGroups(final int uid) {

        User user = users().getValue(uid);
        if (user == null) {
            throw new RuntimeException("Unable to find user #" + uid);
        }

        final UserKeys userKeys = getCachedUserKeys(uid);
        if (userKeys != null) {
            return Promise.success(userKeys);
        }

        return api(new RequestLoadPublicKeyGroups(new ApiUserOutPeer(uid, user.getAccessHash())))
                .map(new Function<ResponsePublicKeyGroups, ArrayList<UserKeysGroup>>() {
                    @Override
                    public ArrayList<UserKeysGroup> apply(ResponsePublicKeyGroups response) {
                        ArrayList<UserKeysGroup> keysGroups = new ArrayList<>();
                        for (ApiEncryptionKeyGroup keyGroup : response.getPublicKeyGroups()) {
                            UserKeysGroup validatedKeysGroup = validateUserKeysGroup(uid, keyGroup);
                            if (validatedKeysGroup != null) {
                                keysGroups.add(validatedKeysGroup);
                            }
                        }
                        return keysGroups;
                    }
                })
                .map(new Function<ArrayList<UserKeysGroup>, UserKeys>() {
                    @Override
                    public UserKeys apply(ArrayList<UserKeysGroup> userKeysGroups) {
                        UserKeys userKeys = new UserKeys(uid, userKeysGroups.toArray(new UserKeysGroup[userKeysGroups.size()]));
                        cacheUserKeys(userKeys);
                        return userKeys;
                    }
                });
    }
670135
@Override
	public CPInstance fetchCPInstanceByUuidAndGroupId(String uuid, long groupId) {
		return cpInstancePersistence.fetchByUUID_G(uuid, groupId);
	}
1236062
@Override
    public Set<IPortletEntity> getPortletEntitiesForUser(int userId) {
        final Set<IPortletEntity> portletEntities =
                this.delegatePortletEntityDao.getPortletEntitiesForUser(userId);
        return this.wrapEntities(portletEntities);
    }
410116
public ApiResponse addUserToGroup(String userId, String groupId) {
        return apiRequest(HttpMethod.POST, null, null, organizationId,  applicationId, "groups",
                groupId, "users", userId);
    }
215231
public function getUserGroups(string $userId = ''): array
    {
        // if not specified, get current user's id
        if (empty($userId)) {
            $userId = $this->Auth->user('id');
        }

        $groups = TableRegistry::get('Groups.Groups');

        $query = $groups->find('list', [
            'keyField' => 'id',
            'valueField' => 'name'
        ]);
        $query->matching('Users', function ($q) use ($userId) {
            return $q->where(['Users.id' => $userId]);
        });

        return $query->toArray();
    }
385427
@Nonnull
  @ReturnsMutableCopy
  public ICommonsList <IUserGroup> getAllUserGroupsWithAssignedUser (@Nullable final String sUserID)
  {
    if (StringHelper.hasNoText (sUserID))
      return new CommonsArrayList <> ();

    return getAll (aUserGroup -> aUserGroup.containsUserID (sUserID));
  }
485052
def user_group_memberships(self, user_id, **kwargs):
        ""
        api_path = "/api/v2/users/{user_id}/group_memberships.json"
        api_path = api_path.format(user_id=user_id)
        return self.call(api_path, **kwargs)
229692
@Nonnull
  @ReturnsMutableCopy
  public ICommonsList <String> getAllUserGroupIDsWithAssignedRole (@Nullable final String sRoleID)
  {
    if (StringHelper.hasNoText (sRoleID))
      return getNone ();

    return getAllMapped (aUserGroup -> aUserGroup.containsRoleID (sRoleID), IUserGroup::getID);
  }
466703
public Query queryUsersForGroup(String groupId) {
        Query q = queryEntitiesRequest(HttpMethod.GET, null, null, organizationId,
                applicationId, "groups", groupId, "users");
        return q;
    }
443180
public function get_all_groups($userid) {
        if (isset($this->usergroups[$userid])) {
            return $this->usergroups[$userid];
        }

        $grouping = $this->get_instance()->teamsubmissiongroupingid;
        $return = groups_get_all_groups($this->get_course()->id, $userid, $grouping);

        $this->usergroups[$userid] = $return;

        return $return;
    }
417365
public static List<CommerceWishList> findByG_U_D(long groupId, long userId,
		boolean defaultWishList) {
		return getPersistence().findByG_U_D(groupId, userId, defaultWishList);
	}
979257
public Map<String, Object> getUser() {
        Map<String, Object> userFields = DDPStateSingleton.getInstance()
                .getDocument("users", getUserId());
        if (userFields != null) {
            return userFields;
        }
        return null;
    }
113190
public static function get_contexts_for_userid(int $userid) : contextlist {
        $contextlist = new contextlist();
        $contextlist->add_from_sql("SELECT c.id
                  FROM {context} c
                  JOIN {tag} t ON t.userid = :userid
                 WHERE contextlevel = :contextlevel",
            ['userid' => $userid, 'contextlevel' => CONTEXT_SYSTEM]);
        return $contextlist;
    }