• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/Configuration/Configuration.php
  • Класс: BitrixImConfigurationConfiguration
  • Вызов: Configuration::setExistingPresetToUsers
static function setExistingPresetToUsers(int $presetId, array $userList, bool $force = false): void
{
	//the priority of the group must be taken into account
	if (!$force)
	{
		$sort =
			OptionGroupTable::query()
				->addSelect('SORT')
				->where('ID', $presetId)
				->fetch()['SORT'];

		$query =
			OptionUserTable::query()
				->addSelect('USER_ID')
				->registerRuntimeField(
					'OPTION_GROUP',
					new Reference(
						'OPTION_GROUP',
						OptionGroupTable::class,
						Join::on('this.GROUP_ID', 'ref.ID'),
						['join_type' => Join::TYPE_INNER]
					)
				)
				->whereIn('USER_ID', $userList)
				->where('OPTION_GROUP.SORT', '>=', (int)$sort)
		;

		$users = [];
		foreach ($query->exec() as $user)
		{
			$users = $user['USER_ID'];
		}
		$userList = $users;
	}

	OptionUserTable::updateMulti(
		$userList,
		[
			'NOTIFY_GROUP_ID' => $presetId,
			'GENERAL_GROUP_ID' => $presetId
		],
		true
	);

	self::cleanUsersCache($userList);
}