• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/Configuration/General.php
  • Класс: BitrixImConfigurationGeneral
  • Вызов: General::filterUsersWithSimpleNotifyScheme
static function filterUsersWithSimpleNotifyScheme(array $userList, string $settingName): array
{
	if (empty($userList))
	{
		return [];
	}

	$encodedSettingName = static::encodeName($settingName);
	$defaultSettingValue = static::getDefaultSettings()[$settingName] ? 'Y' : 'N';
	$query =
		OptionUserTable::query()
			->addSelect('USER_ID')
			->registerRuntimeField(
				'USER',
				new Reference(
					'USER',
					UserTable::class,
					Join::on('this.USER_ID', 'ref.ID'),
					['join_type' => Join::TYPE_INNER]
				)
			)
			->registerRuntimeField(
				'OPTION_STATE',
				new Reference(
					'OPTION_STATE',
					OptionStateTable::class,
					Join::on('this.GENERAL_GROUP_ID', 'ref.GROUP_ID')
						->where('ref.NAME', $encodedSettingName),
					['join_type' => Join::TYPE_LEFT]
				)
			)
			->whereIn('USER_ID', $userList)
			->where('USER.ACTIVE', 'Y')
			->where('USER.IS_REAL_USER', 'Y')
			->whereExpr("IFNULL(%s, '$defaultSettingValue') = 'Y'", ['OPTION_STATE.VALUE'])
	;

	$filteredUserList = [];
	foreach ($query->exec() as $row)
	{
		$filteredUserList[] = (int)$row['USER_ID'];
	}

	return $filteredUserList;
}