CCrmPerms::IsAccessEnabled

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmPerms
  4. IsAccessEnabled
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_perms.php
  • Класс: \CCrmPerms
  • Вызов: CCrmPerms::IsAccessEnabled
public function IsAccessEnabled(CCrmPerms $userPermissions = null)
{
	if($userPermissions === null)
	{
		$userPermissions = self::GetCurrentUserPermissions();
	}

	$result = (
		CCrmLead::IsAccessEnabled($userPermissions)
		|| CCrmContact::IsAccessEnabled($userPermissions)
		|| CCrmCompany::IsAccessEnabled($userPermissions)
		|| CCrmDeal::IsAccessEnabled($userPermissions)
		|| CCrmQuote::IsAccessEnabled($userPermissions)
		|| CCrmInvoice::IsAccessEnabled($userPermissions)
	);

	if (!$result)
	{
		$dynamicTypesMap = Container::getInstance()->getDynamicTypesMap();
		// avoiding exceptions as this method has usages across the product.
		try
		{
			$dynamicTypesMap->load([
				'isLoadStages' => false,
				'isLoadCategories' => false,
			]);
		}
		catch (Exception $exception)
		{
		}
		catch (Error $error)
		{
		}
		foreach ($dynamicTypesMap->getTypes() as $type)
		{
			if (
				Container::getInstance()->getUserPermissions($userPermissions->GetUserID())
					->canReadType($type->getEntityTypeId())
			)
			{
				$result = true;
				break;
			}
		}
	}

	return $result;
}

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