• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/helper/workgroup.php
  • Класс: BitrixSocialnetworkHelperWorkgroup
  • Вызов: Workgroup::getUserRelations
static function getUserRelations(int $groupId, array $userIds): array
{
	$ownerRelations = [];
	$memberRelations = [];
	$otherRelations = [];

	$relationResult = UserToGroupTable::getList([
		'select' => ['ID', 'USER_ID', 'ROLE'],
		'filter' => [
			'GROUP_ID' => $groupId,
			'@USER_ID' => $userIds,
		],
	]);
	while ($relation = $relationResult->fetch())
	{
		$id = $relation['ID'];
		$userId = $relation['USER_ID'];

		switch ($relation['ROLE'])
		{
			case UserToGroupTable::ROLE_OWNER:
				$ownerRelations[$userId] = $id;
				break;

			case UserToGroupTable::ROLE_USER:
				$memberRelations[$userId] = $id;
				break;

			default:
				$otherRelations[$userId] = $id;
				break;
		}
	}

	return [$ownerRelations, $memberRelations, $otherRelations];
}