CBPDocument :: GetAllowableOperations: Bitrix method

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

    
public 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($arGroupsCBPHelper::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[] = strtolower($operation);
                }
            }
        }

        return 
$result;
    }