• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_destination.php
  • Класс: CSocNetLogDestination
  • Вызов: CSocNetLogDestination::getUsersByRole
static function getUsersByRole(int $groupId, $role, array $users, array $userIds): array
{
	$isScrumCustomRole = false;
	$scrumCustomRole = '';

	$availableRoles = [
		SONET_ROLES_USER,
		SONET_ROLES_MODERATOR,
		SONET_ROLES_OWNER,
	];

	// todo maybe remove 'M' role after new system the project roles.
	$customScrumRoles = ['M'];
	$availableRoles = array_merge($availableRoles, $customScrumRoles);

	$group = BitrixSocialnetworkItemWorkgroup::getById($groupId);

	$role = in_array($role, $availableRoles) ? $role : SONET_ROLES_USER;

	if (in_array($role, $customScrumRoles))
	{
		$isScrumCustomRole = true;
		$scrumCustomRole = $role;
		$role = SONET_ROLES_MODERATOR;
	}

	$dbMembers = CSocNetUserToGroup::GetList(
		["RAND" => "ASC"],
		[
			"GROUP_ID" => $groupId,
			"=ROLE" => $isScrumCustomRole ? [SONET_ROLES_OWNER, SONET_ROLES_MODERATOR] : $role,
			"USER_ACTIVE" => "Y"
		],
		false,
		false,
		[
			"ID",
			"USER_ID",
			"ROLE",
			"USER_NAME",
			"USER_LAST_NAME",
			"USER_SECOND_NAME",
			"USER_LOGIN",
			"USER_EMAIL",
			"USER_PERSONAL_PHOTO",
			"USER_WORK_POSITION",
		]
	);

	if ($dbMembers)
	{
		while ($user = $dbMembers->GetNext())
		{
			if ($group && $group->isScrumProject())
			{
				if ($role === SONET_ROLES_MODERATOR)
				{
					$scrumMasterId = $group->getScrumMaster();

					if ($isScrumCustomRole)
					{
						if ($scrumCustomRole === 'M' && $user["USER_ID"] != $scrumMasterId)
						{
							continue;
						}
					}
					else
					{
						if ($user["USER_ID"] == $scrumMasterId)
						{
							continue;
						}
					}
				}
			}

			if (!in_array($user["USER_ID"], $userIds))
			{
				$userIds[] = $user["USER_ID"];
				$users[] = [
					'ID' => $user["USER_ID"],
					'USER_ID' => $user["USER_ID"],
					'LOGIN' => $user["USER_LOGIN"],
					'NAME' => $user["USER_NAME"],
					'LAST_NAME' => $user["USER_LAST_NAME"],
					'SECOND_NAME' => $user["USER_SECOND_NAME"],
					'EMAIL' => $user["USER_EMAIL"],
					'PERSONAL_PHOTO' => $user["USER_PERSONAL_PHOTO"],
					'WORK_POSITION' => $user["USER_WORK_POSITION"]
				];
			}
		}
	}

	return [$users, $userIds];
}