SaleTarget::getUserDepartments

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. SaleTarget
  4. getUserDepartments
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/widget/custom/saletarget.php
  • Класс: Bitrix\Crm\Widget\Custom\SaleTarget
  • Вызов: SaleTarget::getUserDepartments
private function getUserDepartments($userId, $permission)
{
	$departments = array();
	$permissions = \CCrmPerms::GetUserAttr($userId);
	if (
		isset($permissions['INTRANET'])
		&& (
			$permission === \CCrmPerms::PERM_DEPARTMENT || $permission === \CCrmPerms::PERM_SUBDEPARTMENT
		)
	)
	{
		foreach ($permissions['INTRANET'] as $code)
		{
			if (mb_strpos($code, 'D') === 0)
			{
				$departments[] = (int)mb_substr($code, 1);
			}
		}
	}
	if (isset($permissions['SUBINTRANET']) && $permission === \CCrmPerms::PERM_SUBDEPARTMENT)
	{
		foreach ($permissions['SUBINTRANET'] as $code)
		{
			if (mb_strpos($code, 'D') === 0)
			{
				$departments[] = (int)mb_substr($code, 1);
			}
		}
	}

	return $departments;
}

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