• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/access.php
  • Класс: CAccess
  • Вызов: CAccess::GetUserCodes
static function GetUserCodes($USER_ID, $arFilter = [], bool $updateCodes = true)
{
	global $DB;

	if ($updateCodes)
	{
		$access = new CAccess();
		$access->UpdateCodes(['USER_ID' => $USER_ID]);
	}

	$arWhere = [];
	foreach ($arFilter as $key => $val)
	{
		$key = strtoupper($key);
		switch ($key)
		{
			case "ACCESS_CODE":
				if (!is_array($val))
				{
					$val = [$val];
				}
				$arIn = [];
				foreach ($val as $code)
				{
					if (trim($code) <> '')
					{
						$arIn[] = "'" . $DB->ForSQL(trim($code)) . "'";
					}
				}
				if (!empty($arIn))
				{
					$arWhere[] = "access_code in(" . implode(",", $arIn) . ")";
				}
				break;
			case "PROVIDER_ID":
				$arWhere[] = "provider_id='" . $DB->ForSQL($val) . "'";
				break;
		}
	}

	$sWhere = '';
	if (!empty($arWhere))
	{
		$sWhere = " and " . implode(" and ", $arWhere);
	}

	return $DB->Query("select * from b_user_access where user_id=" . intval($USER_ID) . $sWhere);
}