Bitrix24Manager::isAccessEnabled

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Bitrix24Manager
  4. isAccessEnabled
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/bitrix24manager.php
  • Класс: Bitrix\Crm\Integration\Bitrix24Manager
  • Вызов: Bitrix24Manager::isAccessEnabled
static function isAccessEnabled($entityTypeID, $userID = 0)
{
	if(!is_integer($entityTypeID))
	{
		$entityTypeID = (int)$entityTypeID;
	}

	if(!\CCrmOwnerType::IsDefined($entityTypeID))
	{
		throw new Main\ArgumentOutOfRangeException('entityTypeID',
			\CCrmOwnerType::FirstOwnerType,
			\CCrmOwnerType::LastOwnerType
		);
	}

	if(!is_integer($userID))
	{
		$userID = (int)$userID;
	}

	if($userID <= 0)
	{
		$userID = \CCrmSecurityHelper::GetCurrentUserID();
	}

	if(self::$entityAccessFlags === null)
	{
		self::$entityAccessFlags = array();
	}

	if(!isset(self::$entityAccessFlags[$userID]))
	{
		self::$entityAccessFlags[$userID] = array();
	}

	$code = $entityTypeID === \CCrmOwnerType::Lead ? 'crm_lead' : 'crm';
	if(isset(self::$entityAccessFlags[$userID][$code]))
	{
		return self::$entityAccessFlags[$userID][$code];
	}

	if(!(ModuleManager::isModuleInstalled('bitrix24')
		&& Loader::includeModule('bitrix24')
		&& method_exists('CBitrix24BusinessTools', 'isToolAvailable')))
	{
		return (self::$entityAccessFlags[$userID][$code] = true);
	}

	return (self::$entityAccessFlags[$userID][$code] = \CBitrix24BusinessTools::isToolAvailable($userID, $code));
}

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