CAllCrmActivity::OnBeforeIntantMessangerChatAdd

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmActivity
  4. OnBeforeIntantMessangerChatAdd
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity.php
  • Класс: \CAllCrmActivity
  • Вызов: CAllCrmActivity::OnBeforeIntantMessangerChatAdd
static function OnBeforeIntantMessangerChatAdd(\Bitrix\Main\Entity\Event $event)
{
	$result = new \Bitrix\Main\Entity\EventResult();

	$fields = $event->getParameter('fields');
	$entityType = isset($fields['ENTITY_TYPE']) ? $fields['ENTITY_TYPE'] : '';
	$m = null;
	if(preg_match('/^CRM_([A-Z]+)$/i', $entityType, $m) === 1)
	{
		$entityTypeName = isset($m[1]) ? $m[1] : '';
		$ownerTypeID = CCrmOwnerType::ResolveID($entityTypeName);
		$ownerID = isset($fields['ENTITY_ID']) ? intval($fields['ENTITY_ID']) : 0;
		$ownerInfo = null;
		if(CCrmOwnerType::IsDefined($ownerTypeID)
			&& $ownerID > 0
			&& CCrmOwnerType::TryGetInfo($ownerTypeID, $ownerID, $ownerInfo, false))
		{
			$changedFields['TITLE'] = $ownerInfo['CAPTION'];
			$changedFields['AVATAR'] = $ownerInfo['IMAGE_ID'];
			$result->modifyFields($changedFields);
		}
	}
	return $result;
}

Добавить комментарий