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

	$arResult = array();

	if (is_array($arState["STATE_PARAMETERS"]) && count($arState["STATE_PARAMETERS"]) > 0)
	{
		foreach ($arState["STATE_PARAMETERS"] as $arStateParameter)
		{
			$arStateParameter["PERMISSION"] = CBPHelper::convertToExtendedGroups($arStateParameter["PERMISSION"]);

			if (count($arStateParameter["PERMISSION"]) <= 0
				|| count(array_intersect($arGroups, $arStateParameter["PERMISSION"])) > 0)
			{
				$arResult[] = array(
					"NAME" => $arStateParameter["NAME"],
					"TITLE" => (($arStateParameter["TITLE"] <> '') ? $arStateParameter["TITLE"] : $arStateParameter["NAME"]),
				);
			}
		}
	}

	return $arResult;
}