ControllerBased::getUserDepartmentIDs

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ControllerBased
  4. getUserDepartmentIDs
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/security/controller/querybuilder/controllerbased.php
  • Класс: Bitrix\Crm\Security\Controller\QueryBuilder\ControllerBased
  • Вызов: ControllerBased::getUserDepartmentIDs
protected function getUserDepartmentIDs(int $userId): array
{
	static $userDepartmentIDs = [];

	if (isset($userDepartmentIDs[$userId]))
	{
		return $userDepartmentIDs[$userId];
	}

	$allUserAttrs = \Bitrix\Crm\Service\Container::getInstance()
		->getUserPermissions($userId)
		->getAttributesProvider()
		->getUserAttributes()
	;

	$userDepartmentIDs[$userId] = [];

	$intranetAttrs = array_merge(
		isset($allUserAttrs['INTRANET']) ? $allUserAttrs['INTRANET'] : [],
		isset($allUserAttrs['SUBINTRANET']) ? $allUserAttrs['SUBINTRANET'] : []
	);

	foreach ($intranetAttrs as $attr)
	{
		if ($this->tryParseDepartment($attr, $value) && $value > 0)
		{
			$userDepartmentIDs[$userId][] = (int)$value;
		}
	}

	return $userDepartmentIDs[$userId];
}

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