• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/activity/todo.php
  • Класс: Bitrix\Crm\Controller\Activity\ToDo
  • Вызов: ToDo::createNotificationMessages
private function createNotificationMessages(int $activityId, int $ownerTypeId, int $ownerId, string $subject, int $options): array
{
	$url = Container::getInstance()->getRouter()->getItemDetailUrl($ownerTypeId, $ownerId);
	if (!isset($url))
	{
		return [];
	}

	// get phase code by input parameters
	$phaseCodeSuffix = '';
	if ($options & self::NOTIFY_BECOME_RESPONSIBLE)
	{
		$phaseCodeSuffix = 'BECOME';
	}
	elseif ($options & self::NOTIFY_NO_LONGER_RESPONSIBLE)
	{
		$phaseCodeSuffix = 'NO_LONGER';
	}

	if ($subject === '')
	{
		// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE
		// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE
		return [
			Loc::getMessage('CRM_ACTIVITY_TODO_' . $phaseCodeSuffix . '_RESPONSIBLE', [
				'#todoId#' =>  '' . $activityId . ''
			]),
			Loc::getMessage('CRM_ACTIVITY_TODO_' . $phaseCodeSuffix . '_RESPONSIBLE', [
				'#todoId#' => $activityId
			])
		];
	}

	$entityName = '';
	if (CCrmOwnerType::isUseFactoryBasedApproach($ownerTypeId))
	{
		$factory = Container::getInstance()->getFactory($ownerTypeId);
		if ($factory)
		{
			$item = $factory->getItem($ownerId);
			if ($item)
			{
				$entityName = trim($item->getHeading());
			}
		}
	}
	
	if ($entityName === '')
	{
		// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_EX
		// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_EX
		return [
			Loc::getMessage('CRM_ACTIVITY_TODO_' . $phaseCodeSuffix . '_RESPONSIBLE_EX', [
				'#subject#' =>  '' . htmlspecialcharsbx($subject) . ''
			]),
			Loc::getMessage('CRM_ACTIVITY_TODO_' . $phaseCodeSuffix . '_RESPONSIBLE_EX', [
				'#subject#' => htmlspecialcharsbx($subject)
			])
		];
	}

	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_LEAD
	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_DEAL
	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_CONTACT
	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_COMPANY
	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_QUOTE_MSGVER_1
	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_ORDER
	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_SMART_INVOICE
	// CRM_ACTIVITY_TODO_BECOME_RESPONSIBLE_DYNAMIC
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_LEAD
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_DEAL
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_CONTACT
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_COMPANY
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_QUOTE_MSGVER_1
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_ORDER
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_SMART_INVOICE
	// CRM_ACTIVITY_TODO_NO_LONGER_RESPONSIBLE_DYNAMIC

	$phaseCodeEnd = CCrmOwnerType::isPossibleDynamicTypeId($ownerTypeId)
		? CCrmOwnerType::CommonDynamicName
		: CCrmOwnerType::ResolveName($ownerTypeId);

	if ($phaseCodeEnd === 'QUOTE')
	{
		$phaseCodeEnd = 'QUOTE_MSGVER_1';
	}

	return [
		Loc::getMessage('CRM_ACTIVITY_TODO_' . $phaseCodeSuffix . '_RESPONSIBLE_' . $phaseCodeEnd, [
			'#subject#' => htmlspecialcharsbx($subject),
			'#entityName#' => '' . htmlspecialcharsbx($entityName) . '',
		]),
		Loc::getMessage('CRM_ACTIVITY_TODO_' . $phaseCodeSuffix . '_RESPONSIBLE_' . $phaseCodeEnd, [
			'#subject#' => htmlspecialcharsbx($subject),
			'#entityName#' => htmlspecialcharsbx($entityName),
		])
	];
}