• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/document.php
  • Класс: CBPDocument
  • Вызов: CBPDocument::getAllowableOperations
static function getAllowableOperations($userId, $arGroups, $arStates, $appendExtendedGroups = false)
{
	if (!is_array($arStates))
		throw new Exception("arStates");
	if (!is_array($arGroups))
		throw new Exception("arGroups");

	$arGroups = CBPHelper::convertToExtendedGroups($arGroups);
	if ($appendExtendedGroups)
	{
		$arGroups = array_merge($arGroups, CBPHelper::getUserExtendedGroups($userId));
	}
	if (!in_array("group_u".$userId, $arGroups))
		$arGroups[] = "group_u".$userId;

	$result = null;

	foreach ($arStates as $arState)
	{
		if (is_array($arState["STATE_PERMISSIONS"]) && count($arState["STATE_PERMISSIONS"]) > 0)
		{
			if ($result == null)
				$result = array();

			foreach ($arState["STATE_PERMISSIONS"] as $operation => $arOperationGroups)
			{
				$arOperationGroups = CBPHelper::convertToExtendedGroups($arOperationGroups);

				if (count(array_intersect($arGroups, $arOperationGroups)) > 0)
					$result[] = mb_strtolower($operation);
			}
		}
	}

	return $result;
}