CAdvType::CheckFields: Bitrix method

      
<?php 
//  CAdvType :: CheckFields()
//  /dist/bitrix/modules/advertising/classes/general/advertising.php:5126

    
public static function CheckFields($arFields$OLD_SID$CHECK_RIGHTS)
    {
        global 
$strError;
        
$str "";
        
$SID $arFields["SID"];
        if (
$CHECK_RIGHTS=="Y")
        {
            
$isAdmin CAdvContract::IsAdmin();
        }
        else
        {
            
$isAdmin true;
        }
        if (
$isAdmin)
        {
            
$arrKeys array_keys($arFields);
            if (
in_array("SID"$arrKeys))
            {
                if(
strlen(trim($SID))<=0)
                {
                    
$str .= GetMessage("AD_ERROR_FORGOT_SID")."<br>";
                }
                else
                {
                    if (
preg_match("/[^A-Za-z_0-9]/"$SID))
                    {
                        
$str .=  GetMessage("AD_ERROR_INCORRECT_SID")."<br>";
                    }
                    else
                    {
                        if (
$OLD_SID!=$SID)
                        {
                            
$arFilter = array("SID" => $SID." & ~".$OLD_SID"SID_EXACT_MATCH" => "Y");
                            
$rs CAdvType::GetList($v1$v2$arFilter$v3);
                            
$rows 0;
                            if (
is_object($rs))
                            {
                                
$rs->NavStart();
                                
$rows intval($rs->SelectedRowsCount());
                            }

                            if (
$rows>=|| $SID == "ALL" || $OLD_SID == "ALL")
                            {
                                
$str .= str_replace("#SID#", ($OLD_SID == "ALL" $OLD_SID $SID), GetMessage("AD_ERROR_SID_EXISTS"));
                            }
                        }
                    }
                }
            }
        }
        else
        {
            if (
strlen($OLD_SID)>0$str .= GetMessage("AD_ERROR_NOT_ENOUGH_PERMISSIONS_TYPE")."<br>";
            else 
$str .= GetMessage("AD_ERROR_NOT_ENOUGH_PERMISSIONS_FOR_CREATE_TYPE")."<br>";
        }

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