CAllCrmActivity::Notify

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmActivity
  4. Notify
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity.php
  • Класс: \CAllCrmActivity
  • Вызов: CAllCrmActivity::Notify
static function Notify($fields, $schemeTypeID, $tag = '', $isForced = false, $doNotInformUsers = [])
{
	if(!is_array($fields))
	{
		return false;
	}

	$responsibleID = $fields['RESPONSIBLE_ID'] ? (int) $fields['RESPONSIBLE_ID'] : 0;

	if($responsibleID <= 0)
	{
		return false;
	}

	if (in_array($responsibleID, $doNotInformUsers))
	{
		return false;
	}

	if ($isForced)
	{
		global $USER;
		if ($responsibleID == $USER->getId())
		{
			return false;
		};
	}

	if($schemeTypeID === CCrmNotifierSchemeType::IncomingEmail)
	{
		$communicationEntityTypeId = $fields['OWNER_TYPE_ID'] ? intval($fields['OWNER_TYPE_ID']) : 0;
		$communicationEntityId = $fields['OWNER_ID'] ? intval($fields['OWNER_ID']) : 0;

		$url = htmlspecialcharsbx(
			CCrmOwnerType::GetEntityShowPath(
				$communicationEntityTypeId,
				$communicationEntityId
			)
		);

		$entityTitle = self::GetCommunicationTitle([
			'ENTITY_TYPE_ID' => $communicationEntityTypeId,
			'ENTITY_ID' => $communicationEntityId,
		],
			true
		);

		if($url === '')
		{
			return false;
		}

		$uri = new Uri($url);
		$absoluteUrl = $uri->toAbsolute()->getLocator();

		if ($tag == '')
		{
			$tag = sprintf('crm_email_%s', md5($url));
		}

		if ($fields['SUBJECT'])
		{
			$messageTemplate = getMessage(
				'CRM_ACTIVITY_NOTIFY_MESSAGE_INCOMING_1',
				[
					'#ENTITY_TITLE#' => $entityTitle,
					'#SUBJECT#' => $fields['SUBJECT'],
				],
			);
		}
		else
		{
			$messageTemplate = getMessage(
				'CRM_ACTIVITY_NOTIFY_MESSAGE_INCOMING_EMPTY_SUBJECT_1',
				[
					'#ENTITY_TITLE#' => $entityTitle,
				],
			);
		}

		return CCrmNotifier::Notify(
			$responsibleID,
			str_replace(
				'#VIEW_URL#',
				$url,
				$messageTemplate
			),
			str_replace(
				'#VIEW_URL#',
				$absoluteUrl,
				$messageTemplate
			),
			$schemeTypeID,
			$tag
		);
	}

	return false;
}

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