- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/Configuration/Configuration.php
- Класс: BitrixImConfigurationConfiguration
- Вызов: Configuration::createSharedPreset
static function createSharedPreset(
array $accessCodes,
string $presetName,
int $creatorId,
array $settings = [],
int $sort = self::DEFAULT_SORT,
bool $force = false
): ?int
{
if ($sort >= self::USER_PRESET_SORT)
{
return null;
}
$newGroupId = self::createSharedGroup($presetName, $accessCodes, $creatorId, $sort);
if (empty($settings))
{
return $newGroupId;
}
Notification::setSettings($newGroupId, $settings['notify']);
General::setSettings($newGroupId, $settings['general']);
$rowCandidates =
UserAccessTable::query()
->addSelect('USER_ID')
->registerRuntimeField(
'OPTION_USER_TABLE',
new Reference(
'OPTION_USER_TABLE',
OptionUserTable::class,
Join::on('this.USER_ID', 'ref.USER_ID'),
['join_type' => Join::TYPE_INNER]
)
)
->whereIn('ACCESS_CODE', $accessCodes)
;
$candidates = [];
foreach ($rowCandidates->exec() as $rowCandidate)
{
$candidates[] = $rowCandidate['USER_ID'];
}
if ($force)
{
OptionUserTable::updateMulti(
$candidates,
[
'NOTIFY_GROUP_ID' => $newGroupId,
'GENERAL_GROUP_ID' => $newGroupId
],
true
);
return $newGroupId;
}
//the priority of the group must be taken into account
self::updateGroupForUsers($newGroupId, $candidates, $sort, self::NOTIFY_GROUP);
self::updateGroupForUsers($newGroupId, $candidates, $sort, self::GENERAL_GROUP);
self::cleanUsersCache($candidates);
return $newGroupId;
}