- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integration/im/chat.php
- Класс: Bitrix\Crm\Integration\Im\Chat
- Вызов: Chat::transferOwnership
static function transferOwnership($oldEntityTypeID, $oldEntityID, $newEntityTypeID, $newEntityID)
{
if (!Main\Loader::includeModule('im'))
{
return;
}
if(!is_int($oldEntityTypeID))
{
$oldEntityTypeID = (int)$oldEntityTypeID;
}
if($oldEntityTypeID <= 0)
{
throw new Main\ArgumentException('Must be greater than zero.', 'oldEntityTypeID');
}
if(!is_int($oldEntityID))
{
$oldEntityID = (int)$oldEntityID;
}
if($oldEntityID <= 0)
{
throw new Main\ArgumentException('Must be greater than zero.', 'oldEntityID');
}
if(!is_int($newEntityTypeID))
{
$newEntityTypeID = (int)$newEntityTypeID;
}
if($newEntityTypeID <= 0)
{
throw new Main\ArgumentException('Must be greater than zero.', 'newEntityTypeID');
}
if(!is_int($newEntityID))
{
$newEntityID = (int)$newEntityID;
}
if($newEntityID <= 0)
{
throw new Main\ArgumentException('Must be greater than zero.', 'newEntityID');
}
$chatData = Im\Model\ChatTable::getList(
[
'select' => ['ID'],
'filter' =>
[
'=ENTITY_TYPE' => self::CHAT_ENTITY_TYPE,
'=ENTITY_ID' => \CCrmOwnerType::ResolveName($oldEntityTypeID).'|'.$oldEntityID
],
]
)->fetch();
if(is_array($chatData) && isset($chatData['ID']))
{
Im\Model\ChatTable::update(
$chatData['ID'],
[ 'ENTITY_ID' => \CCrmOwnerType::ResolveName($newEntityTypeID).'|'.$newEntityID ]
);
}
}