UserConsent::getDefaultAgreementId

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. UserConsent
  4. getDefaultAgreementId
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/userconsent.php
  • Класс: Bitrix\Crm\Integration\UserConsent
  • Вызов: UserConsent::getDefaultAgreementId
static function getDefaultAgreementId()
{
	if (Loader::includeModule('bitrix24'))
	{
		$lang = \CBitrix24::getPortalZone();
	}
	else
	{
		$lang = Context::getCurrent()->getLanguage();
	}

	if(!Policy::isRequired($lang) || !Policy::hasText($lang))
	{
		return null;
	}

	$code = 'crm_def';
	$existed = AgreementTable::getList(array(
		'select' => array('ID'),
		'filter' => array('=CODE' => $code),
		'limit' => 1
	));
	if ($agreement = $existed->fetch())
	{
		return $agreement['ID'];
	}

	$addResult = AgreementTable::add(array(
		"CODE" => $code,
		"NAME" => Loc::getMessage('CRM_USER_CONSENT_DEF_NAME'),
		"TYPE" => Agreement::TYPE_STANDARD,
		"LANGUAGE_ID" => $lang,
		"DATA_PROVIDER" => self::DATA_PROVIDER_CODE,
	));
	if (!$addResult->isSuccess())
	{
		return null;
	}

	return $addResult->getId();
}

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