CCrmNotifier::Notify

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmNotifier
  4. Notify
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_notifier.php
  • Класс: \CCrmNotifier
  • Вызов: CCrmNotifier::Notify
static function Notify($addresseeID, $internalMessage, $externalMessage, $schemeTypeID, $tag = ''): bool
{
	self::ClearErrors();

	if (!(IsModuleInstalled('im') && CModule::IncludeModule('im')))
	{
		self::RegisterError('IM module is not installed.');

		return false;
	}

	if ($addresseeID <= 0)
	{
		self::RegisterError('Addressee is not assigned.');

		return false;
	}

	$arMessage = [
		'NOTIFY_TITLE' => Loc::getMessage('CRM_NOTIFY_TITLE'),
		'TO_USER_ID' => $addresseeID,
		'FROM_USER_ID' => 0,
		'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM,
		'NOTIFY_MODULE' => 'crm',
		'NOTIFY_MESSAGE' => (string)$internalMessage,
		'NOTIFY_MESSAGE_OUT' => (string)$externalMessage,
	];

	$schemeTypeName = CCrmNotifierSchemeType::ResolveName($schemeTypeID);
	if ($schemeTypeName !== '')
	{
		$arMessage['NOTIFY_EVENT'] = $schemeTypeName;
	}

	$tag = (string)$tag;
	if ($tag !== '')
	{
		$arMessage['NOTIFY_TAG'] = $tag;
	}

	$msgID = CIMNotify::Add($arMessage);
	if (!$msgID)
	{
		$exception = $GLOBALS['APPLICATION']->GetException();
		$errorMessage = $exception
			? $exception->GetString()
			: 'Unknown sending error. message not send.';

		self::RegisterError($errorMessage);
		
		return false;
	}

	return true;
}

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