CBPAllTaskService::ParseFields: Bitrix method

      
<?php 
//  CBPAllTaskService :: ParseFields()
//  /dist/bitrix/modules/bizproc/classes/general/taskservice.php:367

    
protected static function ParseFields(&$arFields$id 0)
    {
        global 
$DB;

        
$id intval($id);
        
$updateMode = ($id true false);
        
$addMode = !$updateMode;

        if (
$addMode && !is_set($arFields"USERS"))
            throw new 
Exception("USERS");

        if (
is_set($arFields"USERS"))
        {
            
$arUsers $arFields["USERS"];
            if (!
is_array($arUsers))
                
$arUsers = array($arUsers);

            
$arFields["USERS"] = array();
            foreach (
$arUsers as $userId)
            {
                
$userId intval($userId);
                if (
$userId && !in_array($userId$arFields["USERS"]))
                    
$arFields["USERS"][] = $userId;
            }

            if (
count($arFields["USERS"]) <= 0)
                throw new 
Exception(GetMessage("BPTS_AI_AR_USERS"));
        }

        if (
is_set($arFields"WORKFLOW_ID") || $addMode)
        {
            
$arFields["WORKFLOW_ID"] = trim($arFields["WORKFLOW_ID"]);
            if (
strlen($arFields["WORKFLOW_ID"]) <= 0)
                throw new 
Exception("WORKFLOW_ID");
        }

        if (
is_set($arFields"ACTIVITY") || $addMode)
        {
            
$arFields["ACTIVITY"] = trim($arFields["ACTIVITY"]);
            if (
strlen($arFields["ACTIVITY"]) <= 0)
                throw new 
Exception("ACTIVITY");
        }

        if (
is_set($arFields"ACTIVITY_NAME") || $addMode)
        {
            
$arFields["ACTIVITY_NAME"] = trim($arFields["ACTIVITY_NAME"]);
            if (
strlen($arFields["ACTIVITY_NAME"]) <= 0)
                throw new 
Exception("ACTIVITY_NAME");
        }

        if (
is_set($arFields"NAME") || $addMode)
        {
            
$arFields["NAME"] = trim($arFields["NAME"]);
            if (
strlen($arFields["NAME"]) <= 0)
                throw new 
Exception("NAME");

            
$arFields["NAME"] = htmlspecialcharsback($arFields["NAME"]);
        }

        if (
is_set($arFields"DESCRIPTION"))
            
$arFields["DESCRIPTION"] = htmlspecialcharsback($arFields["DESCRIPTION"]);

        if (
is_set($arFields"PARAMETERS"))
        {
            if (
$arFields["PARAMETERS"] == null)
            {
                
$arFields["PARAMETERS"] = false;
            }
            else
            {
                
$arParameters $arFields["PARAMETERS"];
                if (!
is_array($arParameters))
                    
$arParameters = array($arParameters);
                if (
count($arParameters) > 0)
                    
$arFields["PARAMETERS"] = serialize($arParameters);
            }
        }

        if (
is_set($arFields"OVERDUE_DATE"))
        {
            if (
$arFields["OVERDUE_DATE"] == null)
                
$arFields["OVERDUE_DATE"] = false;
            elseif (!
$DB->IsDate($arFields["OVERDUE_DATE"], falseLANG"FULL"))
                throw new 
Exception("OVERDUE_DATE");
        }
    }