CBPDocument::GetAllowableEvents: Bitrix method

      
<?php 
//  CBPDocument :: GetAllowableEvents()
//  /dist/bitrix/modules/bizproc/classes/general/document.php:148

    
public 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($arGroupsCBPHelper::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" => ((strlen($arStateParameter["TITLE"]) > 0) ? $arStateParameter["TITLE"] : $arStateParameter["NAME"]),
                    );
                }
            }
        }

        return 
$arResult;
    }