• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/Configuration/Notification.php
  • Класс: BitrixImConfigurationNotification
  • Вызов: Notification::setSettings
static function setSettings(int $groupId, array $settings = [], bool $forInitialize = false): void
{
	if (empty($settings) && !$forInitialize)
	{
		return;
	}

	$selectedSettings = [];
	$query =
		OptionStateTable::query()
			->setSelect(['NAME', 'VALUE'])
			->where('GROUP_ID', $groupId)
			->whereLike('NAME', self::ENTITY . '%')
	;
	foreach ($query->exec() as $row)
	{
		$selectedSettings[$row['NAME']] = $row['VALUE'];
	}
	$defaultSettings = self::encodeSettings(self::getDefaultSettings());
	$encodedSettings = self::encodeSettings($settings);
	$encodedSettings = array_merge($defaultSettings, $encodedSettings);

	$rows = [];
	foreach ($encodedSettings as $name => $value)
	{
		if (!array_key_exists($name, $defaultSettings) || isset($selectedSettings[$name]))
		{
			continue;
		}

		$rows[] = [
			'GROUP_ID' => $groupId,
			'NAME' => $name,
			'VALUE' => $value
		];
	}

	OptionStateTable::addMulti($rows, true);
}