ControllerBased::getDepartmentsUsers

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

	if (empty($departmentIds))
	{
		return [];
	}

	$cacheKey = md5(implode(',', $departmentIds));

	if (!isset($users[$cacheKey]))
	{

		$dbResult = UserTable::getList([
			'filter' => [
				'@UF_DEPARTMENT' => $departmentIds,
			],
			'select' => [
				'ID',
			],
		]);

		$userIds = [];
		while ($userFields = $dbResult->fetch())
		{
			$userIds[] = (int)$userFields['ID'];
		}
		$departments = \CIBlockSection::GetList(
			[],
			[
				'IBLOCK_ID' => \Bitrix\Main\Config\Option::get('intranet', 'iblock_structure', 0),
				'ID' => $departmentIds,
				'CHECK_PERMISSIONS' => 'N',
			],
			false,
			[
				'ID',
				'UF_HEAD',
			]
		);
		while ($departmentFields = $departments->fetch())
		{
			if ($departmentFields['UF_HEAD'])
			{
				$userIds[] = (int)$departmentFields['UF_HEAD'];
			}
		}

		$users[$cacheKey] = array_unique($userIds);
	}

	return $users[$cacheKey];
}

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