CAllCrmDeal::RebuildEntityAccessAttrs

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

	$dbResult = self::GetListEx(
		[],
		[
			'@ID' => $IDs,
			'CHECK_PERMISSIONS' => 'N',
		],
		false,
		false,
		[
			'ID',
			'ASSIGNED_BY_ID',
			'OPENED',
			'STAGE_ID',
			'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['STAGE_ID']))
		{
			$attrs['STAGE_ID'] = $fields['STAGE_ID'];
		}

		$entityAttrs = self::BuildEntityAttr($assignedByID, $attrs);
		$securityRegisterOptions = (new \Bitrix\Crm\Security\Controller\RegisterOptions())
			->setEntityAttributes($entityAttrs)
			->setEntityFields($fields)
		;
		Crm\Security\Manager::getEntityController(CCrmOwnerType::Deal)
			->register(
				DealCategory::convertToPermissionEntityType(
					isset($fields['CATEGORY_ID']) ? (int)$fields['CATEGORY_ID'] : 0
				),
				$ID,
				$securityRegisterOptions
			)
		;
	}
}

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