SaleTarget::splitUsersByPermission

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. SaleTarget
  4. splitUsersByPermission
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/widget/custom/saletarget.php
  • Класс: Bitrix\Crm\Widget\Custom\SaleTarget
  • Вызов: SaleTarget::splitUsersByPermission
private function splitUsersByPermission($targetUserId, $userIds, $permission)
{
	$targetUserId = (int)$targetUserId;
	$resultIds = array();

	if (
		$permission !== \CCrmPerms::PERM_SELF
		&& $permission !== \CCrmPerms::PERM_DEPARTMENT
		&& $permission !== \CCrmPerms::PERM_SUBDEPARTMENT
	)
	{
		return $resultIds;
	}

	$targetDepartments = $this->getUserDepartments($targetUserId, $permission);

	foreach ($userIds as $checkUserId)
	{
		$checkUserId = (int)$checkUserId;
		if ($checkUserId === $targetUserId)
		{
			$resultIds[] = $checkUserId;
			continue;
		}
		if ($permission !== \CCrmPerms::PERM_SELF)
		{
			$checkDepartments = $this->getUserDepartments($checkUserId, \CCrmPerms::PERM_DEPARTMENT);
			$sect = array_intersect($targetDepartments, $checkDepartments);

			if ($sect)
			{
				$resultIds[] = $checkUserId;
			}
		}
	}

	return $resultIds;
}

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