CCrmExternalSaleImport::Notify

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmExternalSaleImport
  4. Notify
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_external_sale_import.php
  • Класс: \CCrmExternalSaleImport
  • Вызов: CCrmExternalSaleImport::Notify
private function Notify()
{
	if ($this->arExternalSale == null)
		$this->arExternalSale = CCrmExternalSale::GetDefaultSettings($this->externalSaleId);

	if (intval($this->arExternalSale["GROUP_ID"]) <= 0)
		return true;

	static $isSNIncluded = null;
	if ($isSNIncluded === null)
		$isSNIncluded = CModule::IncludeModule("socialnetwork");
	if (!$isSNIncluded)
		return;

	$ar = array("#NAME#" => $this->arExternalSale["NAME"]);
	foreach ($this->arImportResult->ToArray() as $k => $v)
		$ar["#".mb_strtoupper($k)."#"] = $v;

	$message = str_replace(
		array("#DEAL_URL#", "#CONTACT_URL#", "#COMPANY_URL#"),
		array(
			"/crm/deal/list/?ORIGINATOR_ID=".$this->externalSaleId."&filter=%CD%E0%E9%F2%E8&clear_filter=&by=date_modify&order=desc",
			"/crm/contact/list/?ORIGINATOR_ID=".$this->externalSaleId."&filter=%CD%E0%E9%F2%E8&clear_filter=&by=date_modify&order=desc",
			"/crm/company/list/?ORIGINATOR_ID=".$this->externalSaleId."&filter=%CD%E0%E9%F2%E8&clear_filter=&by=date_modify&order=desc",
		),
		GetMessage("CRM_GCES_NOTIFY_MESSAGE", $ar)
	);

	$arFields = Array(
		"EVENT_ID" => "crm_new_deals",
		"=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
		"TITLE_TEMPLATE" => "SYSTEM MESSAGE",
		"TITLE" => GetMessage("CRM_GCES_NOTIFY_TITLE", array("#NAME#" => $this->arExternalSale["NAME"])),
		"MESSAGE" => $message,
		"TEXT_MESSAGE" => HTMLToTxt($message),
		"MODULE_ID" => "crm_shared",
		"CALLBACK_FUNC" => false,
		"SOURCE_ID" => false,
		"ENABLE_COMMENTS" => "Y",
		"ENTITY_TYPE" => SONET_ENTITY_GROUP,
		"ENTITY_ID" => $this->arExternalSale["GROUP_ID"],
		"URL" => "",
	);

	$logId = CSocNetLog::Add($arFields, false);

	if (intval($logId) > 0)
	{
		$arPerms = array(
			"SG".$this->arExternalSale["GROUP_ID"],
			"SG".$this->arExternalSale["GROUP_ID"]."_A",
			"SG".$this->arExternalSale["GROUP_ID"]."_E",
			"SG".$this->arExternalSale["GROUP_ID"]."_K"
		);

		CSocNetLog::Update($logId, array("TMP_ID" => $logId));
		CSocNetLogRights::Add($logId, $arPerms);
		if (COption::GetOptionString('crm', 'enable_livefeed_merge', 'N') === 'Y')
		{
			CSocNetLog::SendEvent($logId, 'SONET_NEW_EVENT', $logId);
		}

		return $logId;
	}

	if (($ex = $GLOBALS["APPLICATION"]->GetException()) !== false)
		$this->AddError($ex->GetID(), $ex->GetString());
	else
		$this->AddError("CDA", "Notify error");

	return false;
}

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