CAllCrmCompany::RebuildEntityAccessAttrs

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmCompany
  4. RebuildEntityAccessAttrs
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_company.php
  • Класс: \CAllCrmCompany
  • Вызов: CAllCrmCompany::RebuildEntityAccessAttrs
static function RebuildEntityAccessAttrs($IDs)
{
	if(!is_array($IDs))
	{
		$IDs = array($IDs);
	}

	$dbResult = self::GetListEx(
		[],
		['@ID' => $IDs, 'CHECK_PERMISSIONS' => 'N'],
		false,
		false,
		['ID', 'ASSIGNED_BY_ID', 'OPENED', 'IS_MY_COMPANY', 'CATEGORY_ID', ]
	);

	if(!is_object($dbResult))
	{
		return;
	}

	while($fields = $dbResult->Fetch())
	{
		$ID = intval($fields['ID']);
		$assignedByID = isset($fields['ASSIGNED_BY_ID']) ? intval($fields['ASSIGNED_BY_ID']) : 0;
		if($assignedByID <= 0)
		{
			continue;
		}

		$attrs = [];
		if(isset($fields['OPENED']))
		{
			$attrs['OPENED'] = $fields['OPENED'];
		}

		if(isset($fields['IS_MY_COMPANY']))
		{
			$attrs['IS_MY_COMPANY'] = $fields['IS_MY_COMPANY'];
		}

		$permissionEntityType = (new PermissionEntityTypeHelper(CCrmOwnerType::Company))
			->getPermissionEntityTypeForCategory((int)$fields['CATEGORY_ID'])
		;

		$entityAttrs = self::BuildEntityAttr($assignedByID, $attrs);
		$securityRegisterOptions = (new \Bitrix\Crm\Security\Controller\RegisterOptions())
			->setEntityAttributes($entityAttrs)
			->setEntityFields($fields)
		;
		Crm\Security\Manager::getEntityController(CCrmOwnerType::Company)
			->register(
				$permissionEntityType,
				$ID,
				$securityRegisterOptions
			)
		;
	}
}

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