CCrmPerms::CheckEnityAccess

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmPerms
  4. CheckEnityAccess
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_perms.php
  • Класс: \CCrmPerms
  • Вызов: CCrmPerms::CheckEnityAccess
public function CheckEnityAccess($permEntity, $permType, $arEntityAttr)
{
	if (!is_array($arEntityAttr))
		$arEntityAttr = array();

	$enableCummulativeMode = COption::GetOptionString('crm', 'enable_permission_cumulative_mode', 'Y') === 'Y';

	$permAttr = $this->GetPermType($permEntity, $permType, $arEntityAttr);
	if ($permAttr == self::PERM_NONE)
	{
		return false;
	}
	if ($permAttr == self::PERM_ALL)
	{
		return true;
	}
	if ($permAttr == self::PERM_OPEN)
	{
		if((in_array('O', $arEntityAttr) || in_array('U'.$this->userId, $arEntityAttr)))
		{
			return true;
		}

		//For backward compatibility (is not comulative mode)
		if(!$enableCummulativeMode)
		{
			return false;
		}
	}
	if ($permAttr >= self::PERM_SELF && in_array('U'.$this->userId, $arEntityAttr))
	{
		return true;
	}

	$arAttr = self::GetUserAttr($this->userId);

	if ($permAttr >= self::PERM_DEPARTMENT && is_array($arAttr['INTRANET']))
	{
		// PERM_OPEN: user may access to not opened entities in his department
		foreach ($arAttr['INTRANET'] as $iDepartment)
		{
			if (in_array($iDepartment, $arEntityAttr))
			{
				return true;
			}
		}
	}
	if ($permAttr >= self::PERM_SUBDEPARTMENT && is_array($arAttr['SUBINTRANET']))
	{
		// PERM_OPEN: user may access to not opened entities in his intranet
		foreach ($arAttr['SUBINTRANET'] as $iDepartment)
		{
			if (in_array($iDepartment, $arEntityAttr))
			{
				return true;
			}
		}
	}
	return false;
}

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