• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/Configuration/Notification.php
  • Класс: BitrixImConfigurationNotification
  • Вызов: Notification::getValue
public function getValue(int $userId, string $type): bool
{
	$encodedName = self::encodeName($this->module, $this->name, $type);

	if (!$encodedName)
	{
		return false;
	}

	$defaultSettings = self::encodeSettings(self::getDefaultSettings());

	$cachedPreset = Configuration::getUserPresetFromCache($userId);
	if (
		!empty($cachedPreset)
		&& isset($cachedPreset[Configuration::NOTIFY_GROUP])
		&& is_array($cachedPreset[Configuration::NOTIFY_GROUP])
	)
	{
		$notifySettings = $cachedPreset[Configuration::NOTIFY_GROUP]['settings'];

		if (!$notifySettings)
		{
			return $defaultSettings[$encodedName];
		}

		$notifySettings = self::encodeSettings($notifySettings);

		if (is_null($notifySettings[$encodedName]))
		{
			return $defaultSettings[$encodedName] === 'Y';
		}

		return $notifySettings[$encodedName] === 'Y';
	}

	$query =
		OptionStateTable::query()
			->addSelect('VALUE')
			->registerRuntimeField(
				'OPTION_USER',
				new Reference(
					'OPTION_USER',
					OptionUserTable::class,
					Join::on('this.GROUP_ID', 'ref.NOTIFY_GROUP_ID'),
					['join_type' => Join::TYPE_INNER]
				)
			)
			->where('OPTION_USER.USER_ID', $userId)
			->where('NAME', $encodedName)
	;

	$value = $query->fetch()['VALUE'];

	if (!$value)
	{
		return $defaultSettings[$encodedName] === 'Y';
	}

	return $value === 'Y';
}