CAdvBanner::CheckFields: Bitrix method

      
<?php 
//  CAdvBanner :: CheckFields()
//  /dist/bitrix/modules/advertising/classes/general/advertising.php:1726

    
public static function CheckFields($arFields$BANNER_ID$CHECK_RIGHTS="Y")
    {
        global 
$strError;
        
$maxLongString 65534;
        
$str "";
        if (
$CHECK_RIGHTS=="Y")
        {
            
$isAdmin CAdvContract::IsAdmin();
            
$isManager CAdvContract::IsManager();
        }
        else
        {
            
$isAdmin true;
            
$isManager true;
        }

        
$arrKeys array_keys($arFields);
        if (!
in_array("CONTRACT_ID"$arrKeys) && $BANNER_ID>0)
        {
            
$rsBanner CAdvBanner::GetByID($BANNER_ID"N");
            
$arBanner $rsBanner->Fetch();
            
$CONTRACT_ID intval($arBanner["CONTRACT_ID"]);
        }
        else
        {
            
$CONTRACT_ID intval($arFields["CONTRACT_ID"]);
        }

        if (
in_array("TEMPLATE"$arrKeys))
        {
            if (
strlen($arFields['TEMPLATE']) > $maxLongString)
            {
                
$str.= GetMessage("AD_ERROR_LONG_STRING")."<br>";
            }
        }

        if (
$CONTRACT_ID>0)
        {
            
$access false;
            if (
$isAdmin || $isManager)
            {
                
$access true;
            }
            else
            {
                
$arrPERM CAdvContract::GetUserPermissions($CONTRACT_ID);
                
$arrPERM $arrPERM[$CONTRACT_ID];
                if (
in_array("ADD"$arrPERM))
                    
$access true;
            }

            if (
$access)
            {
                if (
strlen($arFields["DATE_SHOW_FROM"])>0)
                {
                    if (!
CheckDateTime($arFields["DATE_SHOW_FROM"]))
                        
$str.= GetMessage("AD_ERROR_WRONG_DATE_SHOW_FROM_BANNER")."<br>";
                }
                if (
strlen($arFields["DATE_SHOW_TO"])>0)
                {
                    if (!
CheckDateTime($arFields["DATE_SHOW_TO"]))
                        
$str .= GetMessage("AD_ERROR_WRONG_DATE_SHOW_TO_BANNER")."<br>";
                }

                if (
in_array("arrIMAGE_ID"$arrKeys))
                {
                    
$arIMAGE $arFields["arrIMAGE_ID"];
                    
$arIMAGE["MODULE_ID"] = "advertising";
                    
$strRes CFile::CheckImageFile($arIMAGE000, array("FLASH""IMAGE"));
                    if (
strlen($strRes)>0)
                        
$str .= $strRes."<br>";
                }

                if (
in_array("arrFlashIMAGE_ID"$arrKeys))
                {
                    
$arIMAGE $arFields["arrFlashIMAGE_ID"];
                    
$arIMAGE["MODULE_ID"] = "advertising";
                    
$strRes CFile::CheckImageFile($arIMAGE000, array("IMAGE"));
                    if (
strlen($strRes)>0)
                        
$str .= $strRes."<br>";
                }

                if (
in_array("TEMPLATE_FILES"$arrKeys) && is_array($arFields["TEMPLATE_FILES"]))
                {
                    foreach (
$arFields["TEMPLATE_FILES"] as $unit)
                    {
                        if (
is_array($unit))
                        {
                            foreach (
$unit as $file)
                            {
                                
$file["MODULE_ID"] = "advertising";
                                
$strRes CAdvBanner_all::CheckFile($file000, array("IMAGE""VIDEO"));
                                if (
strlen($strRes) > 0)
                                    
$str .= $strRes."<br>";
                            }
                        }
                    }
                }

                if (
$arFields["FLYUNIFORM"] == "Y")
                {
                    if (
strlen($arFields["DATE_SHOW_FROM"])<=or
                        
strlen($arFields["DATE_SHOW_TO"])<=0)
                        
$str .= GetMessage("AD_ERROR_FROMTO_DATE_HAVETOBE_SET")."<br>";

                    if (
$arFields["FIX_SHOW"] != "Y")
                        
$str .= GetMessage("AD_ERROR_FIXSHOW_HAVETOBE_SET")."<br>";

                    if (
intval($arFields["MAX_SHOW_COUNT"])<=0)
                        
$str .= GetMessage("AD_ERROR_MAX_SHOW_COUNT_HAVETOBE_SET")."<br>";
                }
            }
            else
            {
                if (
$BANNER_ID>0)
                    
$str .= GetMessage("AD_ERROR_NOT_ENOUGH_PERMISSIONS_BANNER")."<br>";
                else
                    
$str .= GetMessage("AD_ERROR_NOT_ENOUGH_PERMISSIONS_CONTRACT")."<br>";
            }
        }
        else
        {
            
$str .= GetMessage("AD_ERROR_INCORRECT_CONTRACT_ID")."<br>";
        }

        
$strError .= $str;
        if (
strlen($str)>0)
            return 
false;
        else
            return 
true;
    }